Linking errors

When I tried to port one of my programs from Linux to FreeBSD, g++ threw a few errors:

Code:
g++46 csmp.cpp -o csmp -m32
/usr/local/bin/ld: skipping incompatible /usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/../../../libstdc++.so when searching for -lstdc++
/usr/local/bin/ld: skipping incompatible /usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/../../../libstdc++.a when searching for -lstdc++
/usr/local/bin/ld: cannot find -lstdc++
/usr/local/bin/ld: skipping incompatible //usr/lib/libm.so when searching for -lm
/usr/local/bin/ld: skipping incompatible //usr/lib/libm.a when searching for -lm
/usr/local/bin/ld: cannot find -lm
/usr/local/bin/ld: skipping incompatible /usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/../../../libgcc_s.so when searching for -lgcc_s
/usr/local/bin/ld: skipping incompatible //usr/lib/libgcc_s.so when searching for -lgcc_s
/usr/local/bin/ld: cannot find -lgcc_s
/usr/local/bin/ld: skipping incompatible /usr/local/lib/gcc46/gcc/x86_64-portbld-freebsd10.0/4.6.4/libgcc.a when searching for -lgcc
/usr/local/bin/ld: skipping incompatible //usr/lib/libgcc.a when searching for -lgcc
/usr/local/bin/ld: cannot find -lgcc
/usr/local/bin/ld: skipping incompatible /lib/libc.so.7 when searching for /lib/libc.so.7
/usr/local/bin/ld: cannot find /lib/libc.so.7
/usr/local/bin/ld: skipping incompatible /usr/lib/libc_nonshared.a when searching for /usr/lib/libc_nonshared.a
/usr/local/bin/ld: cannot find /usr/lib/libc_nonshared.a
/usr/local/bin/ld: skipping incompatible /usr/lib/libssp_nonshared.a when searching for /usr/lib/libssp_nonshared.a
/usr/local/bin/ld: cannot find /usr/lib/libssp_nonshared.a
collect2: ld returned 1 exit status
*** Error code 1

Am I doing the right thing by running g++46? Under Linux I just had to run g++.
What do the error messages mean and how should I fix the system?

Thank you!
 
Have you tried removing the -m32 option? It looks as if you are on an amd64 system, with lang/gcc46 built to emit amd64 code. The -m32 option tells g++46 to build a 32-bit version, but you don't have the necessary 32-bit libraries to link against (you only have 64-bit libraries).
 
Need to build the 32 bit version for the other users. So I need to install the 32 bit libraries then. How can I do that?
 
user00 said:
Need to build the 32 bit version for the other users. So I need to install the 32 bit libraries then. How can I do that?
Did you install the 32-bit libraries (/usr/lib32) when you installed FreeBSD? Installing them is the default, so you would have had to de-select that option to bypass their installation.
 
I don't recall seeing that option or de-selecting anything during install. On the contrary, I am sure I turned on the option to install sources, and that was it.
 
user00 said:
I don't recall seeing that option or de-selecting anything during install. On the contrary, I am sure I turned on the option to install sources, and that was it.
If you have a populated /usr/lib32 directory, then you have the 32-bit libraries.
 
user00 said:
Is this the answer? https://d.puremagic.com/issues/show_bug.cgi?id=11801
"FreeBSD does not support multilib environments". Does that mean that I cannot cross-complile 32 bit executable in a 64 bit FreeBSD?
Not sure. I found this thread dumb 32bit vs 64bit questions... which may help you.

One solution would be to create a FreeBSD-10.0 i386 VM and build your 32-bit program in that environment. Since the amd64 installation has 32-bit compatability built in by default, you should be able to run your program on that environment too.
 
FreeBSD can certainly cross compile 32-bit code in a 64-bit host but it's generally limited to cross compiling world and kernel for different architectures. With ports all bets are off and it depends on how well the program and its FreeBSD port cope with non default settings of TARGET and TARGET_ARCH. There's a lot of work still to be done in this area.
 
Back
Top