0

I have a project with several linked libraries. One particular library links to another and calls a symbol, which the linker claims is undefined.

I've linked to the library that should have this symbol in the .pro file as such:

win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../SourceLibrary/release/ -lSourceLibrary
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../SourceLibrary/debug/ -lSourceLibrary
else:unix: LIBS += -L$$OUT_PWD/../SourceLibrary/ -lSourceLibrary

INCLUDEPATH += $$PWD/../SourceLibrary
DEPENDPATH += $$PWD/../SourceLibrary

This links properly using MINGW, so I'm not concerned about typos in library names or function definitions/declarations.

After examining SourceLibrary in Dependencies, I noticed that the required symbols are indeed not there.

This caused me to examine the Makefile for SourceLibrary, however the file with the required symbols was seemingly referenced in the same fashion as the other files that had symbols.

I also checked the intermediary .obj file that was supposed to contain the symbols with dumpbin, and the file indeed had these, and with the same mangling as the linker error report.

Further investigation using dumpbin /ALL revealed that the symbols were in the SourceLibrary.dll file, contradicting Dependencies, as well as the linker error.

In summary, I don't understand why both the linker and Dependencies don't see symbols that should be in a library. I suspect MSVC/MINGW compiler differences, but obviously only have a suspicion at this point.

Andres Salas
  • 153
  • 9
  • 1
    There are definitely differences between how MSVC and MinGW export/import symbols. For starters MinGW uses .a files and MSVC uses .lib files to link with the library. If you want to use a MinGW-built DLL file with MSVC you should probably create a .lib file first. – Brecht Sanders Jun 18 '20 at 22:24
  • @BrechtSanders I should clarify, I'm building the project using MSVC separately from my MINGW build, not trying to use libraries from MINGW in MSVC. – Andres Salas Jun 18 '20 at 22:46
  • 1
    Does the project's header file(s) require some kind of compiler define for the shared library to use dllexport? – Brecht Sanders Jun 19 '20 at 06:47
  • It ended up being that. My question, after further research, was answered by this: https://stackoverflow.com/a/12574423 – Andres Salas Jun 19 '20 at 20:14
  • What process should I take for this? It feels odd to answer the question with a link to another, should this be flagged as a duplicate? – Andres Salas Jun 19 '20 at 20:15

0 Answers0