Solved I need to transfer project from Linux to FreeBSD and have a problem with compilation

I transfered files compiled for centOS to OPNsense and make chmod +x to it and got error:
Exec format error. Binary file not executable.

Therefore files compiled for centOS doesn't want works on OPNsense . Or should run it with another method?
 
It does. We can tell you how to enable the Linux Compatibility on FreeBSD which may not work on OPNSense. OPNSense is a highly customized derivative, it may use FreeBSD as a base but it is configured and maintained completely differently.
ok, first, let's make enable the Linux Compatibility on FreeBSD. After that I'll try to make it on the OPNSense
Now projecct compiled on the CentOS doesn't run on FreeBSD. I have installed freeBSD also.
 
Did you read the handbook on how to enable the Linux compatibility? Does your Linux executable require any additional libraries?
 
But this software from my work, for commercial project. Sorry, I can't due to NDA tell more about it.
And I don't know really more about this software.
In that case, there should be someone you can ask and who's better qualified to do the necessary porting...
 
  • Thanks
Reactions: a6h
Does your Linux executable require any additional libraries?
seems, no require.

# pkg install emulators/linux_base-c7
For Linux® compatibility to be enabled at boot time, add this line to /etc/rc.conf:
Code:
linux_enable="YES"
As I understand, I should make 2 things-
1 - install on the FreeBSD emulator like above
2 - write to /etc/rc.conf: linux_enable="YES"
And should works?
 
And should works?
That will enable the Linux compatibility, yes. I don't know if it will work for your executable though. I don't have access to your code and you haven't provided enough detail about it to make an educated guess. So you're going to have to try it yourself.
 
Can't run first command:
pkg: No packages available to install matching 'emulators/linux_base-c7' have been found in the repositories
 
Code:
root@OPNsense:/etc # pkg -vv
Version                 : 1.12.0
PKG_DBDIR = "/var/db/pkg";
PKG_CACHEDIR = "/var/cache/pkg";
PORTSDIR = "/usr/ports";
INDEXDIR = "";
INDEXFILE = "INDEX-11";
HANDLE_RC_SCRIPTS = false;
DEFAULT_ALWAYS_YES = false;
ASSUME_ALWAYS_YES = false;
REPOS_DIR [
    "/etc/pkg/",
    "/usr/local/etc/pkg/repos/",
]
PLIST_KEYWORDS_DIR = "";
SYSLOG = true;
ABI = "FreeBSD:11:amd64";
ALTABI = "freebsd:11:x86:64";
DEVELOPER_MODE = false;
VULNXML_SITE = "http://vuxml.freebsd.org/freebsd/vuln.xml.bz2";
FETCH_RETRY = 3;
PKG_PLUGINS_DIR = "/usr/local/lib/pkg/";
PKG_ENABLE_PLUGINS = true;
PLUGINS [
]
DEBUG_SCRIPTS = false;
PLUGINS_CONF_DIR = "/usr/local/etc/pkg/";
PERMISSIVE = false;
REPO_AUTOUPDATE = true;
NAMESERVER = "";
HTTP_USER_AGENT = "pkg/1.12.0";
EVENT_PIPE = "";
FETCH_TIMEOUT = 30;
UNSET_TIMESTAMP = false;
SSH_RESTRICT_DIR = "";
PKG_ENV {
}
PKG_SSH_ARGS = "";
DEBUG_LEVEL = 0;
ALIAS {
    all-depends = "query %dn-%dv";
    annotations = "info -A";
    build-depends = "info -qd";
    cinfo = "info -Cx";
    comment = "query -i \"%c\"";
    csearch = "search -Cx";
    desc = "query -i \"%e\"";
    download = "fetch";
    iinfo = "info -ix";
    isearch = "search -ix";
    prime-list = "query -e '%a = 0' '%n'";
    prime-origins = "query -e '%a = 0' '%o'";
    leaf = "query -e '%#r == 0' '%n-%v'";
    list = "info -ql";
    noauto = "query -e '%a == 0' '%n-%v'";
    options = "query -i \"%n - %Ok: %Ov\"";
    origin = "info -qo";
    provided-depends = "info -qb";
    rall-depends = "rquery %dn-%dv";
    raw = "info -R";
    rcomment = "rquery -i \"%c\"";
    rdesc = "rquery -i \"%e\"";
    required-depends = "info -qr";
    roptions = "rquery -i \"%n - %Ok: %Ov\"";
    shared-depends = "info -qB";
    show = "info -f -k";
    size = "info -sq";
}
CUDF_SOLVER = "";
SAT_SOLVER = "";
RUN_SCRIPTS = true;
CASE_SENSITIVE_MATCH = false;
LOCK_WAIT = 1;
LOCK_RETRIES = 5;
SQLITE_PROFILE = false;
WORKERS_COUNT = 0;
READ_LOCK = false;
PLIST_ACCEPT_DIRECTORIES = false;
IP_VERSION = 0;
AUTOMERGE = true;
VERSION_SOURCE = "";
CONSERVATIVE_UPGRADE = true;
PKG_CREATE_VERBOSE = false;
AUTOCLEAN = false;
DOT_FILE = "";
REPOSITORIES {
}
VALID_URL_SCHEME [
    "pkg+http",
    "pkg+https",
    "https",
    "http",
    "file",
    "ssh",
    "ftp",
    "ftps",
    "pkg+ssh",
    "pkg+ftp",
    "pkg+ftps",
]
ALLOW_BASE_SHLIBS = false;
WARN_SIZE_LIMIT = 1048576;
METALOG = "";
OSVERSION = 1102000;
IGNORE_OSVERSION = false;


Repositories:
  OPNsense: {
    url             : "pkg+https://pkg.opnsense.org/FreeBSD:11:amd64/20.1/latest",
    enabled         : yes,
    priority        : 11,
    mirror_type     : "SRV",
    signature_type  : "FINGERPRINTS",
    fingerprints    : "/usr/local/etc/pkg/fingerprints/OPNsense"
  }
root@OPNsense:/etc #
 
Well, SirDice will for shure not answer because he told you about unsupported derivates and you are doing on OPNsense instead on your FreeBSD box. You wrote you have one. Shall we establish a live video chat and read the handbook to you? EDIT: why do we have to explain to you a message like: package not found?
 
why do we have to explain to you a message like: package not found?
becouse for me not obvious this message. Why package not founded.

Is there any method to compile from CentOS directly for FreeBSD instead of compile for CentOS and trying to eneble compability on the FreeBSD or OPNsense ?
 
You mentioned you have a FreeBSD machine, so why not install Linux compat on it, then try to run your Linux compiled binary on it and see if that works before you try building a cross-compiling toolchain?
I'll try to do it.
 
You mentioned you have a FreeBSD machine
Tested- same result- binary files, compiled on CentOS doesn't run on the freeBSD with code error-
Exex format error. Binary file not executable.

Therefore, we have same result with OPNsense
 
After

# pkg install emulators/linux_base-c7
For Linux® compatibility to be enabled at boot time, add this line to /etc/rc.conf:

linux_enable="YES"

in the freeBSD OS-
same negative result- doesn't works.
 
Tested- same result- binary files, compiled on CentOS doesn't run on the freeBSD with code error-
Exex format error. Binary file not executable.
This obviously means he didn't ever try to read & follow the handbook or does not run a GENERIC kernel or didn't load the linux kernel module after he installed emulators/linux_base-c7. Forget it, my impression is this guy is cheating and still didn't get that OPNsense is not FreeBSD & he's doing all this on his OPNsense box. Of course you can install from FreeBSD package repository on an OPNsense host. Doesn't mean it will always work as aspected, though.
 
  • Thanks
Reactions: a6h
I don't think sarcasm of this kind will help, cause to understand it's sarcasm, you'd have to ... hm, understand?

Anyways, I still don't "buy" that story. If it's some commercial software and you have a pressing need for it to run on FreeBSD (or whatever), you'd just ask your business partner to port it.
 
Back
Top