0
votes

I'm developing project in Qt Creator and I need to draw image in class-member function that is compiled as static lib with no error, but when I try to use this function I get following error:

error: undefined reference to 'QImage::QImage(int, int, QImage::Format)'

error: undefined reference to 'QImage::isNull() const'

error: undefined reference to 'QImage::fill(unsigned int)'

error: undefined reference to 'QImage::setPixel(int, int, unsigned int)'

error: undefined reference to 'QImage::save(QString const&, char const*, int)

error: undefined reference to 'QImage::~QImage()'

error: undefined reference to 'QImage::~QImage()'

So the question is can I use QImage with static build lib?

In .pro file I have:

TEMPLATE = lib

CONFIG += staticlib

QT += gui

Edited: I'm using GCC 4.9 compiler for Android, if compile using MSVC2015 for Windows errors looks like:

-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QImage::QImage(int,int,enum QImage::Format)" (__imp_??0QImage@@QAE@HHW4Format@0@@Z)

-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall QImage::~QImage(void)" (__imp_??1QImage@@UAE@XZ)

-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall QImage::setPixel(int,int,unsigned int)" (__imp_?setPixel@QImage@@QAEXHHI@Z)

And etc.

1
Are you statically linking the executable against Qt's gui lib too?cbuchart
No, the executable is linked dynamically.RaGor

1 Answers

1
votes

The static library that you have created is not linked to Qt. It's just a collection of object files. The executable this static library is bound to has to be linked to Qt - and that Qt must be a static build in your case.