[Solved] LINK : fatal error LNK1181: cannot open input file 'moduleA.lib'



  • This is my situation: I developed a library with two modules using these settings:
    @
    moduleA.pro :
    CONFIG += warn_on dll
    TEMPLATE = lib
    TARGET = moduleA

    moduleB.pro :
    CONFIG += warn_on dll
    TEMPLATE = lib
    TARGET = moduleB
    INCLUDEPATH += ..\moduleA
    LIBS += -L..\moduleA\release\ -lmoduleA
    @

    Note: module B depends on module A

    I have two environments to compile the same code:

    a) Windows7 32bit + Qt5.3.1 + MinGw32 : The compilation is clean and I got moduleA.dll and moduleB.dll working perfectly.

    b) Windows7 64bit + Qt5.3.1 64bit + MSV2013 : The module A is compiled pretty clean but I got the next error message while the compiler try to link the module B: LINK : fatal error LNK1181: cannot open input file 'moduleA.lib'

    I was looking for the file moduleA.lib in the whole filesystem but I just could find the file moduleA.dll. I am starting to believe that Qt5.3.1 (64bit) only can create static libraries but it's just a hypothesis.

    What is wrong in the b) environment?

    Thanks.


  • Lifetime Qt Champion

    Hi,

    Nothing is wrong with b. However there's a catch with MSVC. Are you properly exporting your classes/functions ?



  • Hi,

    When I was making the port of the code from Linux to Windows for the first time I had several issues related to how to export my classes. But after the fix, the compilation using MinGW was pretty clean.

    This is how I do it:
    @
    #if defined(QT_SHARED) || defined(QT_PLUGIN)
    #define MYPROJECT_EXPORT Q_DECL_EXPORT
    #endif

    class MYPROJECT_EXPORT ClassExample : public QObject
    {
    }
    @

    The thing that I can't understand is this: Why MVS2013 is looking for a .lib file if I am building a shared library (dll)?


  • Lifetime Qt Champion

    You should rather have something like

    @
    #if defined(BUILD_MYPROJECT_LIB)

    define MYPROJECT_EXPORT Q_DECL_EXPORT

    #else

    define MYPROJECT_EXPORT Q_DECL_IMPORT

    #endif
    @

    QT_SHARED has no implication on the build type of your library. You can created a static library using a dynamic Qt.

    The exportation is done at build time. So you have to define BUILD_MYPROJECT_LIB when compiling your library



  • Thank you for the hint! :)


  • Lifetime Qt Champion

    You're welcome !

    Since you seem to have your libs working, please update the thread title prepending [solved] so other forum users may know a solution has been found :)


Log in to reply
 

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