Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Strange Linking Error
This post is deleted!
Is your library linked to the application?
Are you using QMake/CMake/Qbs to build? can you post the project file??
I am not using Qbs. I am using qmake. Here is the project file:
Project created by QtCreator 2015-03-05T10:35:37
#include(../dna.pri) # defines dna dependency
#include(../configuration.pri) # defines configuration dependency
#include(../AvionicsBus.pri) # defines AvionicsBus dependency
QT -= core gui
TARGET = aop_interface
TEMPLATE = lib
CONFIG += staticlib c++11 create_prl link_prl
SOURCES += $$files($$aop_srcdir/core/aop_interface/.cpp, true)
HEADERS += $$files($$aop_srcdir/core/aop_interface/.hpp, true)
target.path = /usr/lib
INSTALLS += target
This project file brings in dna.pri which defines an internal library dependency:
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../dna/release/ -ldna
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../dna/debug/ -ldna
else:unix: LIBS += -L$$OUT_PWD/../dna/ -ldna
INCLUDEPATH += $$aop_srcdir/core/dna
DEPENDPATH += $$aop_srcdir/core/dna
win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../dna/release/libdna.a
else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../dna/debug/libdna.a
else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../dna/release/dna.lib
else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$OUT_PWD/../dna/debug/dna.lib
else:unix: PRE_TARGETDEPS += $$OUT_PWD/../dna/libdna.a
Its this library where Repository exists, which is the class the error is complaining about. I've confirmed that Repository.obj exists as does dna.lib. I am linking aop_interface.lib into my application (or at least trying to)
I cannot see anymore your original post, what was the error??
I am getting what looks like a typical "unresolved external" error that defies my attempts at resolving. Unlike several others I have already fixed, this one has a bit of information that is not normal:
aop_interface.lib(FmcIntentWaypoint.obj):-1: error: LNK2001: unresolved external symbol "public: static class dna::Repository * __cdecl ACE_Unmanaged_Singleton<class dna::Repository,class ACE_Recursive_Thread_Mutex>::instance(void)" (?instance@?$ACE_Unmanaged_Singleton@VRepository@dna@@VACE_Recursive_Thread_Mutex@@@@SAPAVRepository@dna@@XZ)
The above looks normal, but after this error, there is an additional line:
File not found: aop_interface.lib(FmcIntentWaypoint.obj)
I believe this is a clue as to why I can't resolve this problem. I looked in the DEBUG folder for the project and I do see the file in question.
Any idea what's going on?
aop_interface.libis defined and built? and where is linked?
The main SUBDIRS project builds the library:
CONFIG += c++11 ordered
TEMPLATE = subdirs
It is linked in the main application subproject:
include(../top_srcdir.pri) # defines top-level source trees
include(../ace_lib.pri) # defines ACE library
include(../tap_data.pri) # defines tap_data library
include(../tap_messaging.pri) # defines tap_messaging library
QT += qml quick widgets
INCLUDEPATH = $$aop_util_includes
SOURCES += $$files(.cpp)
HEADERS += $$files(.hpp)
RESOURCES += qml.qrc
mcosta last edited by mcosta
Is it possible to show the LIBS contents while building??
Could be also a dependency problem, are your libraries static or dynamic?
I will instrument the files to get the output you request. The libraries are all static.
The libraries are all static.
IIRC Static libraries need to be linked in the right order. This means that if the library libA uses objects of library libB you have to link in sequence
What is the best way to ensure proper linking order? Should it be handled on a per library basis? For example, MY_APP relies on library MY_LIB. MY_LIB relies on LIBa, LIBb and LIBc in that order. Should I enforce linking at MY_LIB so that MY_APP only needs to link MY_LIB, or should MY_APP link LIBa, LIBb, LIBc and then MY_LIB?
OK, I went through each project and cleaned up the dependencies and now the project builds and runs. It crashes, but that's a problem with my functional code.
I would still like to know what the best way to handle library dependencies is WRT static libraries because a lack of understanding will just lead to repeat problems later, if I change the project around. I don't have this problem when I build my project outside of Qt Creator/qmake. On the Windows side, I use cmake to create the project files and I am intimately familiar with how to work with it. I am new to Qt Creator/qmake, so I am making a lot of mistakes. I need to learn this, though, since I also need to build for MacOS and iOS and I am using qmake to generate the xCode project files.
Thank you for your help!
Should I enforce linking at MY_LIB so that MY_APP only needs to link MY_LIB
Honestly I don't know if all platforms/compilers support it.