crobar
crobar

Reputation: 2939

MXE cross compile links to system libltdl.so as well as mxe package version

I'm attempting to cross-build an application from Linux for windows using M Cross Environment which is really just a system of makefiles which help use the Mingw-w64 tools. The build system for the application is autotools.

The project links to libltdt, but in the final link command for the program, both the system libltdt.so and the cross-compiled mxe version of libltdt

I configured like this:

./configure --host=x86_64-w64-mingw32.static CXXFLAGS="-D_P_WAIT=0 -static -static-libgcc -static-libstdc++" CFLAGS="-D_P_WAIT=0" --enable-static --disable-shared

I get an error like below

libtool: link: x86_64-w64-mingw32.static-g++ -D_P_WAIT=0 -static-libgcc -static-libstdc++ -pthread -pthread -Wl,--export-all-symbols -o mbdyn.exe mbdyn.o ../mbdyn/base/.libs/libbase.a -L/opt/mxe/usr/x86_64-w64-mingw32.static/lib -L/opt/mxe/usr/mingw/lib aero/.libs/libaero.a struct/.libs/libstruct.a elec/.libs/libelec.a thermo/.libs/libthermo.a hydr/.libs/libhydr.a base/.libs/libbase.a ../libraries/libmbc/.libs/libmbc_static.a -L/usr/lib/gcc/x86_64-linux-gnu/4.8 -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../.. -lgfortran -lquadmath /usr/lib/x86_64-linux-gnu/libltdl.so -ldl ../libraries/libmbwrap/.libs/libmbwrap.a ../libraries/libann/.libs/libmbann.a -L/opt/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/5.4.0 -L/opt/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/5.4.0/../../../../x86_64-w64-mingw32.static/lib/../lib -L/opt/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/5.4.0/../../../../x86_64-w64-mingw32.static/lib /home/rcrozier/src/mbdyn/libraries/liby12/.libs/liby12.a /opt/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/5.4.0/libgfortran.a -lmingw32 -lmoldname -lmingwex -lmsvcrt /opt/mxe/usr/lib/gcc/x86_64-w64-mingw32.static/5.4.0/libquadmath.a -ladvapi32 -lshell32 -luser32 -lkernel32 /opt/mxe/usr/x86_64-w64-mingw32.static/lib/libltdl.a -pthread -L/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/libltdl.so: error adding symbols: File in wrong format
collect2: error: ld returned 1 exit status
make[2]: *** [mbdyn.exe] Error 1

In the last command there are several -L entries like -L/usr/lib/x86_64-linux-gnu

It also links explicitly to /usr/lib/x86_64-linux-gnu/libltdl.so

but I actually want to link only to, /opt/mxe/usr/x86_64-w64-mingw32.static/lib/libltdl.a which is also specified in the command.

If I remove the -L entries which aren't pointing to mxe tools directories and the reference to libltdl.so and run the command manually this completes successfully and the executeable, mbdyn.exe, is produced, and it runs on a windows machine.

Is this an issue with MXE, or have I done something wrong? How can I fix the problem.

Upvotes: 0

Views: 373

Answers (1)

crobar
crobar

Reputation: 2939

For some reason this problem disappeared for me. So it may simply be that after installing the libltdl library project through MXE you need to reboot.

Upvotes: 0

Related Questions