[CMake] Win32: DLL fails to find Qt symbols but .so builds in Linux

Clinton Stimpson clinton at elemtech.com
Fri Nov 23 11:09:44 EST 2007


Stephen Collyer wrote:
> 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)
>>     
>
> OK, I'll do a bit of thinking out loud. I'm guessing that
> when I try to build the code above into a DLL, Comms.dll,
> VS tries to find the export lists containing the various
> symbols for QQueue, QMutex, etc and patches the DLL with
> some information in some way. Now, I've taken a look at the
> various .vcproj files created by cmake, and I've noticed
> that the project for the executable (called server) that links
> against the Comms.dll has a line like this:
>
> AdditionalLibraryDirectories="..\lib\MDP\$(OutDir),..\lib\MDP,E:\qt\qt-win-opensource-src-4.3.2\lib\
> ...
>
> which directly refers to the appropriate Qt lib directory. I assume
> that this eventually derives from the lines:
>
> ADD_EXECUTABLE(server ${MOC_SRCS})
> TARGET_LINK_LIBRARIES(server Parent Child Comms ${QT_LIBRARIES})
>
> in the cmakelist file for the server executable.
>
> However, the Comms.vcproj has no equivalent AdditionalLibraryDirectories
> line.
>
> Should it have one ? And if so, how can I convince cmake to put
> one in there ?
>
>   

Are you missing a
TARGET_LINK_LIBRARIES(Comms ${QT_LIBRARIES})
after your
ADD_LIBRARY(Comms ....)
if your Comms dll makes calls to Qt?

Clint




More information about the CMake mailing list