cgyan1
3rd July 2012, 20:51
I have a bit of a problem when compiling my application which complains with an LNK2019: unresolved error.
LNK2019: unresolved external symbol "public: void __thiscall MainWindow::showMessageBox(class QString)
Basically my application is split into modules to make it easier to add/remove features and one of those modules cannot 'see' another file.
The project structure is as follows:
Project
---- bin
---- modules
---- ---- FooModule
---- ---- ---- FooModule.h
---- ---- ---- FooModule.cpp
---- src
---- ---- MainWindow.h
---- ---- MainWindow.cpp
The compiled files from both the modules folder and src folder end up in the bin folder after a successful compilation.
FooModule is actually a separate project within the main project folder and is compiled as a shared library (i.e. dll, as I'm on Windows).
MainWindow successfully creates a new FooModule and passes itself into FooModule's constructor.
At this point FooModule knows about MainWindow's header file but can't see the implementation file as when I try to call any of MainWindow's methods from FooModule's constructor I get the unresolved error about the method I just tried to call.
I'm guessing I just haven't quite got the correct info in the .pro files:
// Project.pro
QT += core gui
TARGET = Project
TEMPLATE = subdirs
CONFIG += ordered debug
SUBDIRS += modules/FooModule \
src \
// FooModule.pro
TARGET = FooModule
TEMPLATE = lib
DEFINES += FOOMODULE_LIBRARY
SOURCES += FooModule.cpp
HEADERS += FooModule.h\
FooModule_global.h
INCLUDEPATH += ../../src
DESTDIR += ../../bin
// src.pro
QT += core gui
TARGET = Project
TEMPLATE = app
CONFIG += ordered debug
INCLUDEPATH += ../modules/FooModule
SOURCES += main.cpp\
MainWindow.cpp \
HEADERS += MainWindow.h
LIBS += -L../bin -lFooModule
DESTDIR += ../bin
Can anyone see where I have gone wrong?
Thanks
LNK2019: unresolved external symbol "public: void __thiscall MainWindow::showMessageBox(class QString)
Basically my application is split into modules to make it easier to add/remove features and one of those modules cannot 'see' another file.
The project structure is as follows:
Project
---- bin
---- modules
---- ---- FooModule
---- ---- ---- FooModule.h
---- ---- ---- FooModule.cpp
---- src
---- ---- MainWindow.h
---- ---- MainWindow.cpp
The compiled files from both the modules folder and src folder end up in the bin folder after a successful compilation.
FooModule is actually a separate project within the main project folder and is compiled as a shared library (i.e. dll, as I'm on Windows).
MainWindow successfully creates a new FooModule and passes itself into FooModule's constructor.
At this point FooModule knows about MainWindow's header file but can't see the implementation file as when I try to call any of MainWindow's methods from FooModule's constructor I get the unresolved error about the method I just tried to call.
I'm guessing I just haven't quite got the correct info in the .pro files:
// Project.pro
QT += core gui
TARGET = Project
TEMPLATE = subdirs
CONFIG += ordered debug
SUBDIRS += modules/FooModule \
src \
// FooModule.pro
TARGET = FooModule
TEMPLATE = lib
DEFINES += FOOMODULE_LIBRARY
SOURCES += FooModule.cpp
HEADERS += FooModule.h\
FooModule_global.h
INCLUDEPATH += ../../src
DESTDIR += ../../bin
// src.pro
QT += core gui
TARGET = Project
TEMPLATE = app
CONFIG += ordered debug
INCLUDEPATH += ../modules/FooModule
SOURCES += main.cpp\
MainWindow.cpp \
HEADERS += MainWindow.h
LIBS += -L../bin -lFooModule
DESTDIR += ../bin
Can anyone see where I have gone wrong?
Thanks