[SOLVED] Issue when using class created with my Dll

  • Hello,
    I created a C++ Dll Obo which compiles fine.

    • #include "obo_global.h"
    • class OBOSHARED_EXPORT Obo
      std::vector<EI*> generate();

    where EI is a class defined in another part of code.
    Now I want to test this Obo library in a separate code OboTester but don't know why but I can't use this EI class as I have a unresolved external symbol, even whith the "EI.h" included in OboTester.
    Here is the code :

    • int main(int argc, char argv[])
      QCoreApplication a(argc, argv);
      Obo myObo;
      > res = myObo.generate();
      // until here it works fine
      EI myEI; // crashes at compile time
      return a.exec();

    What did I do wrong here?

  • Hi,

    I don't know if is a type but in header file generate returns a std::vector<El*> and in main you assign it to a std::vector<El>.

    BTW, before access to element [0] you should check the vector is not empty.

    Can you post the compile/link error?

  • Hi,
    Sorry I edited with something more concrete, its not a problem of empty vector, it doesn't compile when I want to instantiate the class EI.
    The error :
    main.obj:-1: erreur : LNK2019: unresolved external symbol "public: __cdecl EI::EI(void)" (??0EI@@QEAA@XZ) referenced in function main

  • How is defined El ??

    Seems El doesn't have a default constructor

  • @mcosta
    Well, its defined in the Obo project library as a standard class.
    It has a default constructor :


  • Can you post the code and the qmake project file??

  • Well, which code? Obo is around 40k lines of code :/
    Which qMake file? The one from the library?

    Can this be related to EXporting DLL classes? I am not familiar with that at all :(

  • @BlackMamba said:


    Do you used this also for El?
    The library .pro file should be enough.

    Seems the the El constructor in not available outside the library.

  • I didn't use this for the EI class, let me try that !

  • Now it compiles but crashes immediately when I execute the code.
    Here is the pro file :

    • include(Obo.pri)
      QT -= gui
      TARGET = Obo
      TEMPLATE = lib
      SOURCES += Obo.cpp
      HEADERS += Obo.h
      unix {
      target.path = /usr/lib
      INSTALLS += target

    and the .pri file :

    • SOURCES +=
      HEADERS +=
      DEPENDPATH += $$PWD/src/OboInterface
      INCLUDEPATH+= $$PWD/src/OboInterface

  • Ok,

    where's the crash? which line? Are you able to collect a crash dump?

  • It crashes at the same line, when I try to instantiate the object :
    EI myEI;

  • How is defined El??

    Try to provide as much information as possible; otherwise we'll be not able to help you

  • With an empty class, I have the same issue :

    • #ifndef EI_H
      #define EI_H

    class EI

    #endif // EI_H

    main.obj:-1: erreur : LNK2019: unresolved external symbol "public: __cdecl EI::EI(void)" (??0EI@@QEAA@XZ) referenced in function main

    With this :

    #ifndef EI_H
    #define EI_H

    #include "obo_global.h"


    #endif // EI_H

    same error :(

  • I mean the implementation of El.

    Can you post the crash dump?

  • After some clean, good news, I have a new mistake when I add OB0SHARED_EXPORT for the EI class:
    main.obj:-1: erreur : LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl EI::EI(void)" (_imp??0EI@@QEAA@XZ) referenced in function main

  • @mcosta I gave youi the implementation, I deleted all the methods, its an empty class with ctor and dtor only.

  • Sorry, if you don't show the code I can't help you!

  • @mcosta Please read my last answer ;)

  • So, now you have the link error or still the crash??

    You said before you was able to compile and link but you get a crash and now again the link error. It's a little bit confusing

  • Now the crash ... Yes, its confusing for me too.
    Thats looks so simple, I don't understand what I am doing wrong.
    The crash means he cant find the EI cpp implementation at runtime.

  • OMG!!!!! I am soooooo stupid ... I didn't update the copy of the Obo.dll .....
    Sorry for your time mcosta !

    You gave me the right answer by adding OB0SHARED_EXPORT for the classes you need to use after ...
    Thanks !

  • Ok, no problem!

    Happy programming

Log in to reply

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