Menu

#60 lot of undefined reference on static build

v1.0_(example)
closed-invalid
nobody
None
7
2015-08-08
2015-08-08
intelligide
No

I try to build quazip to static lib. SO, i do:

C:\Users\Yoann\Downloads\quazip-0.7.1>qmake "CONFIG += staticlib" "INCLUDEPATH + = C:/Qt/zlib-1.2.8/" "LIBS += -LC:/Qt/zlib-1.2.8 -lz"

but I get an error:

./.obj\qztest.o:qztest.cpp:(.text+0xc01): undefined reference to `_imp___ZN6QuaZip16setFileNameCodecEP10QTextCodec'
./.obj\qztest.o:qztest.cpp:(.text+0xc1c): undefined reference to `_imp___ZN6QuaZip4openENS_4ModeEP19zlib_filefunc_def_s'
./.obj\qztest.o:qztest.cpp:(.text+0xd8e): undefined reference to `_imp___ZN10QuaZipFileC1EP6QuaZipP7QObject'
./.obj\qztest.o:qztest.cpp:(.text+0xe19): undefined reference to `_imp___ZN13QuaZipNewInfoC1ERK7QStringS2_'
./.obj\qztest.o:qztest.cpp:(.text+0xeb2): undefined reference to `_imp___ZN10QuaZipFile4openE6QFlagsIN9QIODevice12OpenModeFlagEERK13QuaZipNewInfoPKcjiibiii'
./.obj\qztest.o:qztest.cpp:(.text+0x110e): undefined reference to `_imp___ZN10QuaZipFileD1Ev'
./.obj\qztest.o:qztest.cpp:(.text+0x119b): undefined reference to `_imp___ZN10QuaZipFile5closeEv'
./.obj\qztest.o:qztest.cpp:(.text+0x1295): undefined reference to `_imp___ZN10QuaZipFileD1Ev'
./.obj\qztest.o:qztest.cpp:(.text+0x1575): undefined reference to `_imp___ZN6QuaZip10setCommentERK7QString'
./.obj\qztest.o:qztest.cpp:(.text+0x15a5): undefined reference to `_imp___ZN6QuaZip5closeEv'
./.obj\qztest.o:qztest.cpp:(.text+0x1a01): undefined reference to `_imp___ZN10QuaZipFileD1Ev'
./.obj\qztest.o:qztest.cpp:(.text+0x1bc5): undefined reference to `_imp___ZN6QuaZipC1EP9QIODevice'
./.obj\qztest.o:qztest.cpp:(.text+0x1c36): undefined reference to `_imp___ZN6QuaZipD1Ev'
./.obj\qztest.o:qztest.cpp:(.text+0x1c68): undefined reference to `_imp___ZN6QuaZipD1Ev'
./.obj\qztest.o:qztest.cpp:(.text+0x1c94): undefined reference to `_imp___ZN6QuaZipC1ERK7QString'
./.obj\qztest.o:qztest.cpp:(.text+0x1cc5): undefined reference to `_imp___ZN6QuaZipD1Ev'
./.obj\qztest.o:qztest.cpp:(.text+0x1cd7): undefined reference to `_imp___ZN6QuaZipD1Ev'

Thanks

Discussion

  • Sergey A. Tachenov

    The QuaZIP library builds fine, the failure is when you build the tests. You can either ignore that or use DEFINES+=QUAZIP_STATIC in order to compile the tests or, for that matter, anything else that is linked to the QuaZIP library (as mentioned in README.txt). When compiling the library, it is done automatically, but when you want to actually use it, the macro is needed to be defined manually. This is because the project that uses the library has no idea how it was compiled, and, consequently, whether to dllimport functions or not. I really should automate this process somehow, but I just can't think of an elegant way to do that.

     
  • Sergey A. Tachenov

    • status: open --> closed-invalid
     
  • intelligide

    intelligide - 2015-08-08

    OK but now, i try to use quazip in a custom project:

    QT += core widgets network xml
    
    TEMPLATE = lib
    CONFIG += plugin
    TARGET = AddonManager
    
    DEFINES += QUAZIP_STATIC
    
    INCLUDEPATH += . include include/plugin C:/Qt/quazip/include/quazip
    
    LIBS += -LC:/Qt/quazip/lib/libquazip.a
    
    SOURCES += \
        src/main.cpp
    

    But I get others errors.

    error: undefined reference to `QuaZip::QuaZip(QString const&)'
    

    How I can fix it?
    Thanks

     
  • Sergey A. Tachenov

    It should be

    LIBS += -LC:/Qt/quazip/lib
    LIBS += -lquazip
    

    RTFM.

     
MongoDB Logo MongoDB