I want to link some .a files into a .dll file with MinGW ld, but it works bad:
the .a files are big, like 0.98 MB, but when I do:
ld liba.a libb.a libc.a -shared -o final.dll
but it doesn't work well! I got an only 5 kb file final.dll.
What should I do?
You cannot link libraries like this:
ld liba.a libb.a libc.a -shared -o final.dll;ldwill never select any object module from any of them, because it never has any unresolved reference to satisfy. To achieve your objective, a possible workaround would be:and, to clean up afterwards:
Do note the use of
gccrather thanldhere; invokinglddirectly is almost always a bad idea, (and if you used it asld -o ../final.dll *.o, instead of thegcccommand I've shown here, your link will surely fail due to unresolved references). Also note that I'm assuming that yourgccandarare the MinGW tools, and that you have a unixyrm, (such as MSYS provides); if your tools are not these, then you may needmingw32-gcc,mingw32-ar, (or whatever else may be appropriate for you), and some alternative command to expunge the temporary directory.