Mingw-32bit Vs MSVC2013-64bit Shared library issue
Hello,
I have a shared library that works perfectly with mingw-32bit compiler. On MSVC2013-64bit compiler however I get a strange problem.
Code:
unresolved external symbol *__declspec(dllimport) .....
The problem is caused by a class in my shared library that is defined as:
Code:
class TEST_IMPORT_EXPORT className { .... }
TEST_IMPORT_EXPORT is defined as :
Code:
#ifdef BUILD_TEST_DLL
#define TEST_IMPORT_EXPORT Q_DECL_EXPORT
#else
#define TEST_IMPORT_EXPORT Q_DECL_IMPORT
#endif
I was wondering why the error says something about "dllImport" so I changed class definition to
Code:
class Q_DECL_EXPORT className { .... }
and the MSVC2013-64bit works fine!
But I for sure think its not the right way to fix this issue. Can someone provide me more info as to what might be going on here?!
Thanks :)
Regards
Vikram
Re: Mingw-32bit Vs MSVC2013-64bit Shared library issue
Have you checked that BUILD_TEST_DLL is set when you are building the library?
Cheers,
_
Re: Mingw-32bit Vs MSVC2013-64bit Shared library issue
Aparently the first thing I did was that! It is set for sure..
Re: Mingw-32bit Vs MSVC2013-64bit Shared library issue
On Windows you have this coming from Qt:
Code:
# define Q_DECL_EXPORT __declspec(dllexport)
# define Q_DECL_IMPORT __declspec(dllimport)
as you can see, you ended up with the value of Q_DECL_IMPORT, which can only mean that your code:
Code:
#ifdef BUILD_TEST_DLL
#define TEST_IMPORT_EXPORT Q_DECL_EXPORT
#else
#define TEST_IMPORT_EXPORT Q_DECL_IMPORT
#endif
was preprocessed when BUILD_TEST_DLL was not defined.
If you add BUILD_TEST_DLL in your PRO file DEFINES, then you must rerun qmake to rewrite the Makefile or the value will not make it to the compiler.