Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

why I need add the same .a and .dylib file to my Mac qt project



  • I developed a Mac qt project,in my project, I need use the boost_system sdk, so I add it use the 'add Library...' by right click my project, after that,in my .pro file,the qt help add information like this:
    macx: LIBS += -L$$PWD/../../../../../../usr/local/Cellar/boost/1.67.0_1/lib/ -lboost_system

    INCLUDEPATH += $$PWD/../../../../../../usr/local/Cellar/boost/1.67.0_1/include
    DEPENDPATH += $$PWD/../../../../../../usr/local/Cellar/boost/1.67.0_1/include

    macx: PRE_TARGETDEPS += $$PWD/../../../../../../usr/local/Cellar/boost/1.67.0_1/lib/libboost_system.a

    I use the 'otool -L' with my executable file which in my .app,it shows :

    otool -L /Users/lee/Desktop/VisualStudio/FUEditor/Build/FUEditor.app/Contents/MacOS/FUEditor
    /Users/lee/Desktop/VisualStudio/FUEditor/Build/FUEditor.app/Contents/MacOS/FUEditor:
    /usr/local/opt/boost/lib/libboost_system.dylib (compatibility version 0.0.0, current version 0.0.0)

    and my app work fine,
    In my understanding, I can use one of .a and .dylib,In my understanding,the .a and .dylib has same functions, .a is staic loaded,will became a part of executable file which in my .app,and .dylib is dynamic loaded, not be a part of executable file which in my .app,so I decide use the libboost_system.a only that my app can use in other Mac,so I change my .pro :

    macx: LIBS += -L$$PWD/../../../../../../usr/local/Cellar/boost/1.67.0_1/lib/libboost_system.a
    INCLUDEPATH += $$PWD/../../../../../../usr/local/Cellar/boost/1.67.0_1/include
    DEPENDPATH += $$PWD/../../../../../../usr/local/Cellar/boost/1.67.0_1/include
    macx: PRE_TARGETDEPS += $$PWD/../../../../../../usr/local/Cellar/boost/1.67.0_1/lib/libboost_system.a

    and I rebuild my project,it shows error:

    Undefined symbols for architecture x86_64:
    "boost::system::generic_category()", referenced from:
    boost::system::error_category::std_category::equivalent(int, std::__1::error_condition const&) const in ObjMesh.o
    boost::system::error_category::std_category::equivalent(std::__1::error_code const&, int) const in ObjMesh.o
    boost::system::error_category::std_category::equivalent(int, std::__1::error_condition const&) const in AttrController.o
    boost::system::error_category::std_category::equivalent(std::__1::error_code const&, int) const in AttrController.o
    boost::system::error_category::std_category::equivalent(int, std::__1::error_condition const&) const in basemeshviewer.o
    boost::system::error_category::std_category::equivalent(std::__1::error_code const&, int) const in basemeshviewer.o
    boost::system::error_category::std_category::equivalent(int, std::__1::error_condition const&) const in fueditor.o
    ...
    ld: symbol(s) not found for architecture x86_64

    it's seem the libboost_system.a depent on the libboost_system.dylib,libboost_system.a and libboost_system.dylib are not independent of each other, in my knowledge,the .a and .dylib file are independent of each other,Am I wrong?
    thanks a lot!


  • Lifetime Qt Champion

    @Princein said in why I need add the same .a and .dylib file to my Mac qt project:

    macx: LIBS += -L$$PWD/../../../../../../usr/local/Cellar/boost/1.67.0_1/lib/libboost_system.a

    I don't know why both were added, but this line is wrong. If you add libs using -l you have to remove "lib" prefix. Another thing wrong with this line: -L specifies a directory where libs can be found not a specific lib.


Log in to reply