[Solved] Calling VS DLLs :(



  • Hi
    Can somebody give me a clue - I'm trying to call a VS2010 DLL from Qt5.2.1 (for VS2010).
    I've successfully called the DLL from VS and I've successfully called a Qt DLL from a Qt host app. But when I try to call the VS DLL from Qt the same way I call the Qt DLL, I get the "LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall MyCDllClass::MyCDllClass(void)" plus the same messages for the destructor and the Test() method.

    To use the DLL in Qt, I simply use Add Library -> External, then select the .lib file and then with Add Existing Files, I add the header of the DLL, which looks like

    @#ifndef MyCDllClass_H
    #define MyCDllClass_H

    #ifdef MYCDLLCLASS
    #define DLLCLASS __declspec(dllexport)
    #else
    #define DLLCLASS __declspec(dllimport)
    #endif

    class DLLCLASS MyCDllClass
    {
    public:
    MyCDllClass(void);
    ~MyCDllClass(void);

    void Test();
    };

    #endif
    @


  • Moderators

    Don't use Add Existing Files to include external library headers. Use INCLUDEPATH in your .pro file instead.



  • Ok, thanks, I'll definitely try that and see how it works!

    In the end the problem was mismatched files and that I had to uncheck the "Add -d suffix for debug version". Stupid of me. Sorry for the bother, but while things didn't work, everything started to mess up and I spent half a day tearing my hair, so finally decided to call for help.
    And, as expected, a while later I find it's my own stupid mistake.

    Thanks and cheers ;)


  • Moderators

    [quote author="MwRain" date="1396431194"]Sorry for the bother, but while things didn't work, everything started to mess up and I spent half a day tearing my hair, so finally decided to call for help.
    And, as expected, a while later I find it's my own stupid mistake.[/quote]

    No problem, I guess those kind of situations happen to every programmer occasionally ;)


Log in to reply
 

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