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. QT + DLL + LIB + MSVC + unresolved externals

QT + DLL + LIB + MSVC + unresolved externals

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.9k Views
  • 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 Offline
    B Offline
    bu7ch3r
    wrote on last edited by
    #1

    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
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #2

      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
      0
      • B Offline
        B Offline
        bu7ch3r
        wrote on last edited by
        #3

        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
        0
        • B Offline
          B Offline
          bu7ch3r
          wrote on last edited by
          #4

          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
          0

          • Login

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