Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    QT + DLL + LIB + MSVC + unresolved externals

    General and Desktop
    2
    4
    2661
    Loading More Posts
    • 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.
    • B
      bu7ch3r last edited by

      I have a header file with a function:

      @
      __inline void foo(WCHAR * moscraciun)
      {
      UNREFERRENCED_PARAMETER(moscraciun);
      }
      @

      In another header I have:

      @
      __inline __declspec(dllexport) void foo(WCHAR*);
      @

      After compile I have: dll and lib;
      I have looked in dll and in the lib files and all functions are there decorated, everything seems ok.

      I have another header with definition:

      @
      __inline __declspec(dllimport) void foo(WCHAR*);
      @

      this header is metamorphic __declspc(dllimport) is preprocessor defined and converts normaly according to build specs

      in my code I am loading the lib with #pragma comment(lyb, mylib.lib), it is set in the project at additional librearies so it's ok

      I call foo() and i get:

      @
      error LNK2019: unresolved external symbol "void __cdecl foo(unsigned short*)" (?foo_decorat) referenced in function "public: virtual void __thiscall CCLassName::MethodName" (?Method name decorated)
      @

      The problem is that a project works with this dll and lib but it has only MFC. The one that doesn't work has Qt.

      [EDIT: code formatting, Volker]

      for(int i = 200; i > 0;)
      try
      {
      //do something
      }
      catch(...)
      {
      i--;//try again
      }

      1 Reply Last reply Reply Quote 0
      • G
        giesbert last edited by

        an inline function can not be exported.
        You should decide, whether it is inline or exported :-)

        Nokia Certified Qt Specialist.
        Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

        1 Reply Last reply Reply Quote 0
        • B
          bu7ch3r last edited by

          The dll with the lib is compiled in visual studio. Also I am compiling the qt project in VS. When I compile a MFC project in VS everything works ok.

          for(int i = 200; i > 0;)
          try
          {
          //do something
          }
          catch(...)
          {
          i--;//try again
          }

          1 Reply Last reply Reply Quote 0
          • B
            bu7ch3r last edited by

            Ok, forget about the __inline. I have made a small solution with 3 projects. A c++ MFC project, a Qt project and a c++ dll project.
            Dll has a simple foo function exported with __declspecs(dllexport).
            lib shows that function.
            In dll project I have 2 headers one with the definition and one with the body.

            Now the MFC project copiles and link ok and calls foo. Qt project doesn't.

            I think I am doing something wrong.
            The Qt project was made in Qt creator, a simple project. I saved and moved all project dir in my Visual solution dir. I have imported the Qt proj using Qt addin than in project settings beside the Qt libs(core, gui etc) I have entered my lib. Also I am calling foo() in mainwindow class(in constructor) and added #include of the header with the definition of the function. Finally I have compiled but got unresolved externals.

            for(int i = 200; i > 0;)
            try
            {
            //do something
            }
            catch(...)
            {
            i--;//try again
            }

            1 Reply Last reply Reply Quote 0
            • First post
              Last post