[CMake] Win32: DLL fails to find Qt symbols but .so builds in
Linux
Mike Jackson
imikejackson at gmail.com
Fri Nov 23 08:39:20 EST 2007
is COMMS_EXP being defined somewhere for WIN32?
You usually have a block of code like the following:
#if defined (_WIN32) && defined (BUILD_SHARED_LIBS)
#pragma warning(disable: 4251)
#if defined(Comms_EXPORTS)
#define COMMS_EXP __declspec(dllexport)
#else
#define COMMS_EXP __declspec(dllimport)
#endif /* Comms_EXPORTS */
#else /* defined (_WIN32) && defined (BUILD_SHARED_LIBS) */
#define COMMS_EXP
#endif
--
Mike Jackson Senior Research Engineer
Innovative Management & Technology Services
On Nov 23, 2007, at 7:21 AM, Stephen Collyer wrote:
> I'm building some simple shared libraries and an executable
> that links against them under both Win32 and Linux. All of
> the libraries and exe build and link correctly under Linux,
> but when building the DLLs under Win32 I get link errors.
>
> e.g. I have a class that looks like this:
>
> #include <QMutex>
> #include <QQueue>
> #include <QString>
> #include <QWaitCondition>
>
> ...
>
> class COMMS_EXP Comms
> {
> public:
> ...
>
> private:
> QQueue<QString> messageq;
> QMutex qmutex;
> QWaitCondition message_available;
> };
>
> with a cmake command like this:
>
> ADD_LIBRARY(Comms Comms.cpp)
>
> When I build the appropriate project in VS, I get LNK2019 messages
> relating to QMutex, QWaitCondition, and so on (I've attached a small
> section of these).
>
> I'm not at all clear what's going on here, and I don't even
> understand why VS has a "link" stage when building a DLL.
> Can anyone explain ? The only possibility I can think of is
> that the linker is looking for the export lists from the
> Qt libraries (i.e. the .lib files) but is failing to find them.
>
> --
> Regards
>
> Steve Collyer
> Netspinner Ltd
> ------ Build started: Project: Comms, Configuration: Debug Win32
> ------
> Compiling...
> Comms.cpp
> Compiling manifest to resources...
> Linking...
> Creating library Debug\Comms.lib and object Debug\Comms.exp
> Comms.obj : error LNK2019: unresolved external symbol "__declspec
> (dllimport) public: __thiscall QMutex::~QMutex(void)" (__imp_??
> 1QMutex@@QAE at XZ) referenced in function __unwindfunclet$??
> 0Comms@@QAE at XZ$0
> Comms.obj : error LNK2019: unresolved external symbol "__declspec
> (dllimport) public: __thiscall QWaitCondition::QWaitCondition
> (void)" (__imp_??0QWaitCondition@@QAE at XZ) referenced in function
> "public: __thiscall Comms::Comms(void)" (??0Comms@@QAE at XZ)
> C
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
More information about the CMake
mailing list