Forward Declaration in a Static Library
I am trying to compile a static library to use with a non-Qt application. I wish to create a wrapper in this library to minimize the number of includes the final static library needs.
These are the basics of the code:
class ImageSender; //forward declaration
The library source file is:
_sender = new ImageSender();
I successfully compile this and can link to it in my non-qt project. If I comment out _sender = new ImageSender(); (line 6 in LibraryWrapper.cpp), I do not get any errors when I compile and run the non-qt application.
QT += network
QT -= gui
TEMPLATE = lib
CONFIG += staticlib
HEADERS += imageudpsenderwrapper.h \
SOURCES += imageudpsenderwrapper.cpp \
TARGET = ../../../ShutterSoftware/build/ImageUdpSenderLibrary
The only thing I can think of is adding imagesender.h to the HEADERS += in the .pro file, but when I do this it asks for its dependencies, which I think defeats the purpose of the forward declaration....
Just to show the application linking to the static library:
using namespace System;
int main(array<System::String ^> ^args)
ImageUdpSenderWrapper* _sender = new ImageUdpSenderWrapper();
Building your library requires all headers to be listed and that's correct.
However when using it in your application you'll only use imageudpsenderwrapper.h which is want you want to do.
Unless I misunderstood your problem
Thanks for your help. My issue was omitting the library headers in the .pro.
You're welcome !
Now that you have it compiling, please update the thread title prepending [solved] so other forum users may know a solution has been found :)