PDA

View Full Version : so shared library problem



mtrpoland
13th August 2007, 20:22
Guys, quite newbie stuff:
I have a .so shared library with my brand new InfoBox widget placed in a MTR namespace.
Then I have a test program:


#include <QApplication>
#include <QtCore>
#include <QtGui>

int main(int argc, char* argv[]) {
QApplication app(argc, argv);
MTR::InfoBox ib;
ib.show();
app.exec();
return 0;
}


its .pro:


TEMPLATE = app
CONFIG += qt
LIBS += -L/home/mtr/Programowanie/Projekty/MTRInfoBox -lMTRInfoBox
SOURCES += main.cpp


as you see I link the directory of my .so file as well as its name without "lib" prefix and .so* suffix.

I do not receive any messages that libMTRInfoBox.so.1.0.1 file hasn't been found.

Anyway I receive a message as if my test program did not know MTR::InfoBox class. Furthermore it doesn't recognize MTR namespace.

All in all I must have made some mistake somewhere...

jpn
13th August 2007, 21:01
The application must include a header which declares MTR::InfoBox (just like you include Qt headers which declare Qt classes).

mtrpoland
13th August 2007, 21:12
I have added
#include <MTRInfoBox>
and I received:

main.cpp:4:22: error: MTRInfoBox: No such file or directory
then I tried:

#include <MTR::InfoBox> and I received

main.cpp:4:24: error: MTR::InfoBox: No such file or directory

The libMTRInfoBox.so.1.0.1 file is placed in /home/mtr/Programowanie/Projekty/MTRInfoBox folder.

jpn
13th August 2007, 21:51
You should have a header file together with libMTRInfoBox.so.1.0.1.

First, you must add


INCLUDEPATH += /home/mtr/Programowanie/Projekty/MTRInfoBox

to the .pro file to make it possible to include a header file from /home/mtr/Programowanie/Projekty/MTRInfoBox.

Then, you should use the exact name of the header file in include directive, not "MTR::InfoBox". I don't know what is the header called but let's say its name is mtrinfobox.h:

#include "mtrinfobox.h"