Strange Linking Error
-
I am not using Qbs. I am using qmake. Here is the project file:
#-------------------------------------------------
Project created by QtCreator 2015-03-05T10:35:37
#-------------------------------------------------
include(../top_srcdir.pri)
#include(../ace_path.pri)
#include(../dna.pri) # defines dna dependency
#include(../configuration.pri) # defines configuration dependency
#include(../AvionicsBus.pri) # defines AvionicsBus dependency
#include(../aop_comm.pri)
#include(../aop_measure.pri)
#include(../aop_data.pri)
#include(../aop_logger.pri)
#include(../aop_serial.pri)
#include(../aop_util.pri)
#include(../aop_xml.pri)QT -= core gui
TARGET = aop_interface
TEMPLATE = lib
CONFIG += staticlib c++11 create_prl link_prlINCLUDEPATH =
$$aop_interface_includes
$$avionics_bus_includes
$$dna_includes
$$aop_measure_includes
$$aop_data_includes
$$route_container_includes
$$aop_serial_includes
$$aop_util_includes
$$aop_logger_includes
$$aop_comm_includes
$$configuration_includes
$$aop_xml_includes
include(../ace_path.pri)
include(../dna.pri)
SOURCES += $$files($$aop_srcdir/core/aop_interface/.cpp, true)
HEADERS += $$files($$aop_srcdir/core/aop_interface/.hpp, true)unix {
target.path = /usr/lib
INSTALLS += target
}This project file brings in dna.pri which defines an internal library dependency:
include(top_srcdir.pri)
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/ -ldnaINCLUDEPATH += $$aop_srcdir/core/dna
DEPENDPATH += $$aop_srcdir/core/dnawin32-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.aIts 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)
-
@DRoscoe said:
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?
-
The main SUBDIRS project builds the library:
CONFIG += c++11 ordered
TEMPLATE = subdirsSUBDIRS +=
aop_logger
aop_xml
aop_serial
aop_util
aop_measure
MathUtilities
DataCollection
DebugLogger
MoreMath
AvionicsBus
AircraftDataModel
WindModel
TableLookups
configuration
dna
aop_data
aop_comm
tap_data
AtosUtils
tap_messaging
BufferedSharedMemory
RouteContainer
aop_interface
tap_new_display_appIt 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 libraryQT += qml quick widgets
INCLUDEPATH = $$aop_util_includes
$$aop_logger_includes
$$tap_data_includes
$$aop_serial_includes
$$tap_messaging_includes
$$aop_data_includes
$$aop_measure_includes
$$aop_interface_includes
$$aop_xml_includes
include(../ace_path.pri)
include(../dna.pri)
include(../aop_logger.pri)
include(../aop_interface.pri)
include(../aop_util.pri)
include(../aop_xml.pri)
include(../aop_serial.pri)
include(../aop_measure.pri)
include(../AvionicsBus.pri)
SOURCES += $$files(.cpp)
HEADERS += $$files(.hpp)RESOURCES += qml.qrc
QML_IMPORT_PATH =
include(deployment.pri)
-
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!
-
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?