Quantcast
Channel: Qt DevNet forums: Installation and Deployment
Viewing all articles
Browse latest Browse all 2113

Forward Declaration in a Static Library

$
0
0
Hello, 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: //libraryWrapper.h class ImageSender; //forward declaration   class LibraryWrapper{   public: LibraryWrapper(); ~LibraryWrapper();   private: ImageSender* _sender; } The library source file is: //LibraryWrapper.cpp #include "LibraryWrapper.h" #include "imagesender.h"   LibraryWrapper::LibraryWrapper(){  _sender = new ImageSender(); }   ~ImageSender(){ //delete _sender; } 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. //LibraryWrapper.pro 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: #include "stdafx.h" #include "imageudpsenderwrapper.h"   using namespace System;   int main(array<System::String ^> ^args) {  ImageUdpSenderWrapper* _sender = new ImageUdpSenderWrapper();     return 0; } Thanks!

Viewing all articles
Browse latest Browse all 2113

Trending Articles