lundi 4 décembre 2017

Unable to link archive file, but able to link individual object files

I've been working on a project to build a windows executable file using mingw-w64. I decided I wanted to test out using libtins for the project and downloaded the library file (.lib) from libtins' website. The .lib file compiled using VisualStudio2015. I wanted to statically link the library and linking failed to resolve the undefined references I was using. I later found out, by using nm on the library file, that VisualStudio2015 mangles the symbols differently than MinGW. So I then compiled libtins from source using MinGW. However, the undefined references continued to fail to resolve after trying to link with the newly compiled library. Using nm I could see that the undefined symbols in my object files matched the needed symbols found in the library yet, the files failed to link into an executable file. I then used ar to extract the object files from the library and slowly added the required object files and eventually the executable linked and ran fine.

I also found this answer and linking the whole archive also succeeded. What circumstances would cause an issue like this? I can link to the individual object files but not the library archive that holds these files, or I can link to the whole archive but not to the individual compontents within it. What can explain this behavior?

Aucun commentaire:

Enregistrer un commentaire