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

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.
You were not right. I don't cheating you. I understand that OPNsense is not FreeBSD. Also I tryed to run on the freeBSD your recommendations. Like install emulators/linux_base-c7
and write
linux_enable="YES"
WO seccess result.
I think- you cheating me- you told me that if compile on the CentOS- all will works fine on the FreeBSD- isn't it? And were result? No result. Instead of that you accuse me that I cheat you....

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.
Don't need to buy it. I have no possibility ask my collegue to port it. This guy doesn't work more... I need to run those code on freeBSD or OPNsense.

And I can't to do it. For this reason, I asked all of you to hel me to do it.

Sorry guys.
 
And I can't to do it.
Tell that to whomever gave you this task in the first place. There is no shame in admitting you're unqualified for it. It's your boss's responsibility to find someone that is.

For this reason, I asked all of you to help me to do it.
That's fine, we can do that. But only if you actually understand what we're trying to tell you. You don't appear to grasp even some basic knowledge on the matter. That's also fine, but this is not a subject that can be spoonfed. There are so many variables, we simply cannot tell you to do A, B, then C and it'll magically work. Porting isn't easy, even for seasoned coders.
 
That's fine, we can do that. But only if you actually understand what we're trying to tell you.
Thanks for undestanding.
Let's try to run this code.
I really have no a lot of expeirence of Linux develop, but I have a strong skills in C/C++ development.
But only if you actually understand what we're trying to tell you
I understood and understand what you tell me.
1- freeBSD it is no OPNsense.
2- for running software on the freeBSD we should enable compatable on the freeBSD- doesn't work
I have a little bit expeirence with Lunux and able to understand your advise.

Did you read the Linux compat page?
What do you mean? Wich page? Where discribed how to enable Linux compatable on the freeBSD?

kldload linux.ko
kldstat
file /your/path/to/binary
readelf -h /your/path/to/binary
What shold I do with this commands? And where should it run? More detail, pls.

Guys, let's forget for my commercial project. Let's imagine simle file hello_word.c with some specific Linux libraries like in the first post.
and I need to compile it under Lunux (CentOS) and this output file should works on FreeBSD. Not OPNsense. I mean, I can't right now compile this hello_word.c on the freeBSD directly.
Let's it will be first step of understanding my problems.
 
You're trying to get this to run on FreeBSD, right? And kldstat doesn't even exist on Linux (it would be lsmod).
Not right. For why should I run it for FreeBSD? What should I fugure out by those commands on Freebsd? But I can do it. 10 min.

This, of course, is a self assessment.
Ofcourse, but 15 years expierence in programming commercial software let me think that I write on the C very well. But ofcourse this subjective assessment. I just point if I have no enought knowledge in Linux, I practical developer.
 
You're trying to get this to run on FreeBSD, right? And kldstat doesn't even exist on Linux (it would be lsmod).
Running on the freeBSD 11.2
 

Attachments

  • 22.jpg
    22.jpg
    56.4 KB · Views: 169
  • 23.jpg
    23.jpg
    64.6 KB · Views: 188
Well, looking at these screenshots(!), this is "branded" as an SVR4 binary, not as a Linux binary. So what gpb already cited might help. If not, show the exact output when trying to run the program. Preferably not a screenshot, just copy&paste ...

15 years expierence in programming commercial software
One of the things that irritated me (apart from my basic premise that seasoned developers can do some technical research) is confusing headers with libraries, as well as assuming there were the same system headers with different names on different systems, so all you have to do is change an include... But maybe things like that could happen if you work for so many years with just a single target platform and probably IDE ...
 
Well, looking at these screenshots(!), this is "branded" as an SVR4 binary, not as a Linux binary. So what gpb already cited might help. If not, show the exact output when trying to run the program. Preferably not a screenshot, just copy&paste ...
I'll try to do it.

I work only with microcontrollers. For this reason I don't have a lot of expierence with Linux.

And, guys, thanks for help!
 
When run on the FreeBSD 11.2 my files, error is:
ELF interpreter /lib64/ld-linux-x86-64.so.2 not found, error 2 abort

This expected. I compiled this file on the CentOS
 
When run on the FreeBSD 11.2 my files, error is:
ELF interpreter /lib64/ld-linux-x86-64.so.2 not found, error 2 abort

This expected. I compiled this file on the CentOS
No, it isn't. Every dynamically linked program needs a program interpreter, and above is the one for Linux/amd64. This is included in emulators/linux_base-c7 and you've been told multiple times to install this port/package, so I don't understand what happened here.
Just want to ask-
is there for centOS compiler for Freebsd? Cross compiler?
This is running in circles. No doubt it would be possible to build one, but it won't do any good, cause with a cross compiler, you'd still have to use the system headers matching the target system. Even with just experience with microcontrollers, you should know that a header file describes an interface, which must have some implementation at runtime. So you can't just use a system header for Linux (describing a Linux-specific interface!) and expect it to work on a different system.
 
Guys, if there was a dislike button, I'd click it on all your well-intentioned attempts to help this poor man. Just my 50¢. After 15 years developing for microcontrollers, it's impossible to lack basic understanding of how an OS works.
Being obnoxious and argumentative is a bad strategy to get free help for your commercial product.
Send an email to https://lists.freebsd.org/mailman/listinfo/freebsd-jobs
+1 & above all, s/he ignores our hints and plays dumb. Read the whole thread & you'll know what I mean.
 
Being obnoxious and argumentative
In wich place I am obnoxious and argumentative?

This is running in circles. No doubt it would be possible to build one, but it won't do any good, cause with a cross compiler, you'd still have to use the system headers matching the target system. Even with just experience with microcontrollers, you should know that a header file describes an interface, which must have some implementation at runtime. So you can't just use a system header for Linux (describing a Linux-specific interface!) and expect it to work on a different system.
I agree with it. My path- is prepare sources for FreeBSD OS and need to try compile on it.

Guys, if there was a dislike button, I'd click it on all your well-intentioned attempts to help this poor man. Just my 50¢. After 15 years developing for microcontrollers, it's impossible to lack basic understanding of how an OS works.
Noone helps me to decide this problem. Of all of topic. I don't ignore your hints , but there is no hints on business. Except
Zirias
gpb

and someone guys.
Go stright ahead...

And what is the output of ldd /your/path/to/binary ran on the FreeBSD machine?
Thanks, litle bit later I'll check it.
 
And what is the output of ldd /your/path/to/binary ran on the FreeBSD machine?
When run on the FreeBSD 11.2 my files, error is:
ELF interpreter /lib64/ld-linux-x86-64.so.2 not found, error 2 abort

Output of these on the FreeBSD machine:
ldd /your/path/to/binary
Same error like above.

It was runned on the FreeBSD

When run on the CentOS my binary with a special key-
something doing than message from this binary- No devices discovered.

Really I discovered devices by transfer key to binary file.
Therefore, works.

But may be guys right- need to edit headers and compile directly for FreeBSD or OPNsense.
 

Attachments

  • Screenshot_1.jpg
    Screenshot_1.jpg
    29.2 KB · Views: 145
service abi start
ldd /usr/apps2/cofiglayer
EDIT it's hard to resist from linking this thread into Off-Topic/It's All About Jokes & Funny Pics
 
  • Like
Reactions: a6h
When run on the FreeBSD 11.2 my files, error is:
ELF interpreter /lib64/ld-linux-x86-64.so.2 not found, error 2 abort
To be able to run Linux binaries on FreeBSD, two things are required: Kernel support (i.e. linux compatibility modules), and userland support (linux userland package).

Others have already mentioned how to install the linux package, using the pkg command. This is absolutely required. If it doesn’t work, you need to find out why. You can type pkg info to list all packages that are installed. The package “linux_base-c7” should be among them. (The list is sorted alphabetically, so it should be easy to see.) If it’s not there, you need to install it. Again: This is a must.

To check for the kernel module, please enter the command kldstat on your FreeBSD machine. It prints a list of kernel modules that have been loaded. Among them there should be modules “linux.ko” and “linux64.ko”. If they are missing, you have to load them: type service abi onestart. Then check again with kldstat.

If any commands fail, please tell us exactly what you tried and what the output is. Also, please mention the exact FreeBSD version (the output from uname -a is useful).

And finally: Please copy the text of the output, rather than making screenshots. Screenshots are inconvenient to use, they cannot be searched, and copy&paste doesn’t work either.
 
The "not found" message comes from https://github.com/freebsd/freebsd/...d3890fabe075d8e07/sys/kern/imgact_elf.c#L1039, which means that either linux64.ko is not loaded or FreeBSD doesn't like this specific ELF header.

To check for the kernel module, please enter the command kldstat on your FreeBSD machine. It prints a list of kernel modules that have been loaded. Among them there should be modules “linux.ko” and “linux64.ko”. If they are missing, you have to load them: type service abi onestart. Then check again with kldstat.

And with /compat/linux/bin/uname.
 
I asked for the output on FreeBSD for df because it doesn't find anything. When you installed linux_base-c7 did you read the output? I installed that package just to provide it to you:
Will return late to this question.

Now I want to check step by step
olli@
advises.
 
You can type pkg info to list all packages that are installed. The package “linux_base-c7” should be among them.
Yes, now this package is installed. Was no before.
pkg info shows this linux_base-c7 among modules.

To check for the kernel module, please enter the command kldstat on your FreeBSD machine. It prints a list of kernel modules that have been loaded. Among them there should be modules “linux.ko” and “linux64.ko”.
Yes, there are both modules
“linux.ko”
“linux64.ko”

Also, please mention the exact FreeBSD version
I mentioned before- I use freeBSD 11.2

Now I try to run my binary, compiled on CentOS, on the freeBSD.
Now there is no error that Linux not found:
ELF interpreter /lib64/ld-linux-x86-64.so.2 not found, error 2 abort

And I have a problem with copy-paste from FreeBSD output. I don't tune a mouse in the VMware and for this reason can't mark and copy from it to windows. Sorry for screenshots.
 
I asked for the output on FreeBSD for df because it doesn't find anything. When you installed linux_base-c7 did you read the output? I installed that package just to provide it to you:
When I installed linux_base-c7, I got same messages like you.
 
Back
Top