Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Issue when using class created with my Dll
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Issue when using class created with my Dll

Scheduled Pinned Locked Moved General and Desktop
dll
23 Posts 2 Posters 5.7k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • BlackMambaB Offline
    BlackMambaB Offline
    BlackMamba
    wrote on last edited by BlackMamba
    #1

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

    • #include "obo_global.h"
    • class OBOSHARED_EXPORT Obo
      {
      public:
      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;
      std::vector<EI
      > res = myObo.generate();
      // until here it works fine
      EI myEI; // crashes at compile time
      return a.exec();
      }

    What did I do wrong here?
    Thanks

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mcosta
      wrote on last edited by mcosta
      #2

      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?

      Once your problem is solved don't forget to:

      • Mark the thread as SOLVED using the Topic Tool menu
      • Vote up the answer(s) that helped you to solve the issue

      You can embed images using (http://imgur.com/) or (http://postimage.org/)

      1 Reply Last reply
      0
      • BlackMambaB Offline
        BlackMambaB Offline
        BlackMamba
        wrote on last edited by BlackMamba
        #3

        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

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mcosta
          wrote on last edited by mcosta
          #4

          How is defined El ??

          Seems El doesn't have a default constructor

          Once your problem is solved don't forget to:

          • Mark the thread as SOLVED using the Topic Tool menu
          • Vote up the answer(s) that helped you to solve the issue

          You can embed images using (http://imgur.com/) or (http://postimage.org/)

          BlackMambaB 1 Reply Last reply
          0
          • M mcosta

            How is defined El ??

            Seems El doesn't have a default constructor

            BlackMambaB Offline
            BlackMambaB Offline
            BlackMamba
            wrote on last edited by BlackMamba
            #5

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

            }

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mcosta
              wrote on last edited by
              #6

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

              Once your problem is solved don't forget to:

              • Mark the thread as SOLVED using the Topic Tool menu
              • Vote up the answer(s) that helped you to solve the issue

              You can embed images using (http://imgur.com/) or (http://postimage.org/)

              1 Reply Last reply
              0
              • BlackMambaB Offline
                BlackMambaB Offline
                BlackMamba
                wrote on last edited by BlackMamba
                #7

                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 :(

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mcosta
                  wrote on last edited by
                  #8

                  @BlackMamba said:

                  OBOSHARED_EXPORT

                  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.

                  Once your problem is solved don't forget to:

                  • Mark the thread as SOLVED using the Topic Tool menu
                  • Vote up the answer(s) that helped you to solve the issue

                  You can embed images using (http://imgur.com/) or (http://postimage.org/)

                  1 Reply Last reply
                  0
                  • BlackMambaB Offline
                    BlackMambaB Offline
                    BlackMamba
                    wrote on last edited by
                    #9

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

                    1 Reply Last reply
                    0
                    • BlackMambaB Offline
                      BlackMambaB Offline
                      BlackMamba
                      wrote on last edited by BlackMamba
                      #10

                      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
                        DEFINES += Obo_LIBRARY
                        SOURCES += Obo.cpp
                        HEADERS += Obo.h
                        Obo_global.h
                        unix {
                        target.path = /usr/lib
                        INSTALLS += target
                        }

                      and the .pri file :

                      • SOURCES +=
                        ...
                        $$PWD/src/OboInterface/EI.cpp
                        HEADERS +=
                        $$PWD/src/OboInterface/EI.h
                        ...
                        DEPENDPATH += $$PWD/src/OboInterface
                        INCLUDEPATH+= $$PWD/src/OboInterface
                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        mcosta
                        wrote on last edited by
                        #11

                        Ok,

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

                        Once your problem is solved don't forget to:

                        • Mark the thread as SOLVED using the Topic Tool menu
                        • Vote up the answer(s) that helped you to solve the issue

                        You can embed images using (http://imgur.com/) or (http://postimage.org/)

                        1 Reply Last reply
                        0
                        • BlackMambaB Offline
                          BlackMambaB Offline
                          BlackMamba
                          wrote on last edited by
                          #12

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

                          1 Reply Last reply
                          0
                          • M Offline
                            M Offline
                            mcosta
                            wrote on last edited by mcosta
                            #13

                            How is defined El??

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

                            Once your problem is solved don't forget to:

                            • Mark the thread as SOLVED using the Topic Tool menu
                            • Vote up the answer(s) that helped you to solve the issue

                            You can embed images using (http://imgur.com/) or (http://postimage.org/)

                            1 Reply Last reply
                            0
                            • BlackMambaB Offline
                              BlackMambaB Offline
                              BlackMamba
                              wrote on last edited by BlackMamba
                              #14

                              With an empty class, I have the same issue :

                              • #ifndef EI_H
                                #define EI_H

                              class EI
                              {
                              public:
                              EI();
                              ~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"

                              class OBOSHARED_EXPORT EI
                              {
                              public:
                              EI();
                              ~EI();
                              };

                              #endif // EI_H

                              same error :(

                              1 Reply Last reply
                              0
                              • M Offline
                                M Offline
                                mcosta
                                wrote on last edited by
                                #15

                                I mean the implementation of El.

                                Can you post the crash dump?

                                Once your problem is solved don't forget to:

                                • Mark the thread as SOLVED using the Topic Tool menu
                                • Vote up the answer(s) that helped you to solve the issue

                                You can embed images using (http://imgur.com/) or (http://postimage.org/)

                                BlackMambaB 1 Reply Last reply
                                0
                                • BlackMambaB Offline
                                  BlackMambaB Offline
                                  BlackMamba
                                  wrote on last edited by
                                  #16

                                  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

                                  1 Reply Last reply
                                  0
                                  • M mcosta

                                    I mean the implementation of El.

                                    Can you post the crash dump?

                                    BlackMambaB Offline
                                    BlackMambaB Offline
                                    BlackMamba
                                    wrote on last edited by
                                    #17

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

                                    1 Reply Last reply
                                    0
                                    • M Offline
                                      M Offline
                                      mcosta
                                      wrote on last edited by
                                      #18

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

                                      Once your problem is solved don't forget to:

                                      • Mark the thread as SOLVED using the Topic Tool menu
                                      • Vote up the answer(s) that helped you to solve the issue

                                      You can embed images using (http://imgur.com/) or (http://postimage.org/)

                                      BlackMambaB 1 Reply Last reply
                                      0
                                      • M mcosta

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

                                        BlackMambaB Offline
                                        BlackMambaB Offline
                                        BlackMamba
                                        wrote on last edited by
                                        #19

                                        @mcosta Please read my last answer ;)

                                        1 Reply Last reply
                                        0
                                        • M Offline
                                          M Offline
                                          mcosta
                                          wrote on last edited by
                                          #20

                                          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

                                          Once your problem is solved don't forget to:

                                          • Mark the thread as SOLVED using the Topic Tool menu
                                          • Vote up the answer(s) that helped you to solve the issue

                                          You can embed images using (http://imgur.com/) or (http://postimage.org/)

                                          1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved