I'm having problems cross-compiling a library for 32bit FreeBSD architecture on a 64bit FreeBSD-system. I'm happy about any hint/advice. Compiling for same architecture (64bit) works fine.
I built ports lang/gcc9 & lang/gcc9-devel. In the configuration of the port, I enabled "multilib", which should build for 32 and 64 bit. If I search for available libstdc on the system, I find the following:
[root@build /usr/local/share/ohNet-build4FreeBSD/ohNet-ohNet_1.17.2776]# find / -iname "*libstdc*"
/usr/local/share/gcc-9.2.0/python/libstdcxx
/usr/local/lib32/gcc9/libstdc++.so.6.0.27
/usr/local/lib32/gcc9/libstdc++.so
/usr/local/lib32/gcc9/libstdc++.so.6
/usr/local/lib32/gcc9/libstdc++.so.6.0.27-gdb.py
/usr/local/lib32/gcc9/libstdc++.a
/usr/local/lib32/gcc9/libstdc++fs.a
/usr/local/lib/gcc9/libstdc++.so.6.0.27
/usr/local/lib/gcc9/libstdc++fs.a
/usr/local/lib/gcc9/libstdc++.so.6
/usr/local/lib/gcc9/libstdc++.so
/usr/local/lib/gcc9/libstdc++.a
/usr/local/lib/gcc9/libstdc++.so.6.0.27-gdb.py
/usr/ports/lang/libstdc++_stldoc_4.2.2
When compiling for 64bit, my project builds fine. When compiling for 32bit, I set the following env-variables:
export CROSS_COMPILE_CFLAGS=-m32
export CROSS_COMPILE_LINKFLAGS=-m32
and the build fails with
/usr/local/bin/ld: skipping incompatible /usr/local/lib/gcc9/gcc/x86_64-portbld-freebsd11.2/9.2.1/../../../libstdc++.a when searching for -lstdc++
/usr/local/bin/ld: cannot find -lstdc++
If I understand correctly, the compiler fails to find the compatible 32-bit libraries, although they are there (see above). Please advise for the correct way to fix this.