Question

I have a library which I'm compiling in MSVC2012 to be dynamically linked against. Each declaration is preceded by __declspec(dllexport) via a macro LIBAPI. This builds fine and creates a dll + a lib which symbols such as _funcname (from examining with dumpbin.exe).

Over in Qt Creator (backed by same MSVC toolchain) I include the same headers used to build the library but an extra define that changes the LIBAPI macro to __declspec(dllimport). Here is where I'm getting linker errors because it is looking for __imp_funcname. If I redefine LIBAPI to nothing the linker will instead look for funcname (no preceding underscore).

I've verified everything else in the compile link toolchain is working correctly, only issue is this function decorator mismatch.

Question then is: how can I either force a convention when building the library (preferably to export the __imp_ style) or force Qt to find the single underscore symbols?

Was it helpful?

Solution

The answer turned out to be that I had initiated the project with the x64 version of Qt Creator, so it was using the x64 toolchain to do the compiling and linking. Making a brand new project from Qt Creator x86 add copying all files across sorted everything out

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top