[Qt-interest] Problem with linking external libraries (Win32)

Markus Straub markus.straub.at at gmail.com
Mon Jan 25 11:50:48 CET 2010


John McClurkin wrote:
> Markus Straub wrote:
>> Dear list,
>>
>> I recently bumped into a problem when trying to compile and run a 
>> project on Win32 which was developed on Linux and fail to solve it.
>>
>> I seem to be unable to use the DLL provided by InterSense (isense.dll) 
>> under Win32, whereas I have no problems with libisense.so under Linux.
>>
>> In both OSes I copied the shared library to the common path, 
>> /usr/local/lib and c:\windows\system32 respectively. Compiling and 
>> linking the same code within QtCreator also works fine on both, even 
>> without the LIBS directive in the .pro file
>> (win32:LIBS += c:\windows\system32\isense.dll). All required headers are 
>> included as well.
>>
>> The problem arises when running the program: on Windows I only get the 
>> message "Could not load isense", on Linux it just works.
>>
>>
>> Now I am wondering what I am missing, why is my program not able to find 
>> the dll at runtime (if that is what the error message means).
>> A small testprogram compiled with Visual Studio 6 could successfully use 
>> isense.dll, so I guess the problem is caused by my project configuration.
>>
>>
>> Any hints would be appreciated.
>>
>> Best regards,
>> Markus Straub
> This is probably a compiler issue. On Linux, the InterSense library was 
> undoubtedly compiled with gcc, the same compiler used for Qt. For 
> Windows, the InterSense libraries were probably compiled with Visual 
> Studio. You describe your windows project as a Win32 project, so I'm 
> assuming you are using MinGW. You can't link libraries compiled with 
> Visual Studio (or Borland for that matter) with programs compiled with 
> MinGW.
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest

Finally I solved the problem:

The .dll was definitely compiled with Visual Studio but this was not the 
problem. It now happily works with my program that I compile with MinGW 
in QtCreator. The solution was to not use LoadLibrary() but 
LoadLibraryA() for loading the .dll .. so the root of the problem was 
character encoding.



More information about the Qt-interest-old mailing list