[Solved] dll import problem



  • Hi.

    I'm trying to add a library to my project.
    In .pro I ve already add the library:
    @LIBS += -L$$PWD\libs\Vicon\ -lViconDataStreamSDK_CPP
    INCLUDEPATH += $$PWD\libs\Vicon\include@

    In .cpp already add the header file:
    @#include "Client.h"@

    This header has a lot of classes inside of a namespace which i called:
    @using namespace ViconDataStreamSDK::CPP;@

    Everything seems ok, I call the classes, but when debugging an error occur with dll import:

    engine.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: class ViconDataStreamSDK::CPP::Output_Connect __thiscall ViconDataStreamSDK::CPP::Client::Connect(class ViconDataStreamSDK::CPP::String const &)" (_imp?Connect@Client@CPP@ViconDataStreamSDK@@QAE?AVOutput_Connect@23@ABVString@23@@Z) referenced in function "public: void __thiscall Engine::ConnectVicon(void)" (?ConnectVicon@Engine@@QAEXXZ)

    engine.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall ViconDataStreamSDK::CPP::Client::Client(void)" (_imp??0Client@CPP@ViconDataStreamSDK@@QAE@XZ) referenced in function "public: void __thiscall Engine::ConnectVicon(void)" (?ConnectVicon@Engine@@QAEXXZ)

    It seems is connected with this part of my header file Client.h:

    @#ifdef _EXPORTING
    #define CLASS_DECLSPEC __declspec(dllexport)
    #else
    #define CLASS_DECLSPEC __declspec(dllimport)
    #endif // _EXPORTING@

    And I have .dll and the .lib files inside the correct folders.....
    Any ideia whats going on?

    Thank you.



  • Are you sure the library is properly named? ViconDataStreamSDK_CPP.lib?



  • Yes.... can deceive because the CPP but both of them are in the folder of debugging and in the folder of the .pro path

    ViconDataStreamSDK_CPP.dll
    and
    ViconDataStreamSDK_CPP -> Object File Library

    Could it be because they were made with Visual Studio C++ and Im using Qt IDE? Any conflict?



  • Are you sure this lib and dll were built with Visual Studio? Not MinGW/Cygwin and therefore GCC as a compiler?



  • Not sure, but in the Software Development Kit they just say this:

    Windows – C++
    Your application should
    #include “Client.h”
    Link against “ViconDataStreamSDK_CPP.lib”
    Redistribute:
    “ViconDataStreamSDK_CPP.dll”
    “Microsoft.VC8.CRT” (x86) or “Microsoft.VC9.CRT” (x64).

    And I've put both the dlls in the correct folders.



  • Well then you have a "mangling":http://en.wikipedia.org/wiki/Name_mangling problem: your DLL was built against an older version of Visual Studio which exported the symbols for C++ in a different way.
    You will only be able to link against that DLL with code compiled using:

    • Visual Studio 2005 aka VC80 for the 32 bits version

    • Visual Studio 2008 aka VC90 for the 64 bits version

    If you use a newer version of Visual Studio, then you will have to get newer versions of that library.
    Enjoy the joys of programming on the Windows platform :D



  • Problem was solved.

    With new dll, the problem was solved.

    Thank you all



  • Have the same problem, sent you a pm JLamas.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.