If your header includes Qt code and your library #includes that header then your library requires Qt to be present in order to compile.
If your header includes Qt code and your library user has to #include the header in order to use your library then they will require Qt in order to compile their program.
If the Qt code is conditionally removed by the pre-processor then I fail to see what your problem is. Compile your library with the Qt code removed by #define and don't link the Qt libraries. If you are using Qt to create a Makefile using
QT =
QT =
To copy to clipboard, switch view to plain text mode
in the pro file will remove all reference to Qt during code generation and linking. Nothing to do with "PRL" files.
Example:
// lib.h
#ifndef LIB_H
#define LIB_H
#ifdef USE_QT
#include <QString>
inline int test
() { return QString("abc").
length();
} #endif
struct Test {
int thingy(int val);
};
#endif
// lib.h
#ifndef LIB_H
#define LIB_H
#ifdef USE_QT
#include <QString>
inline int test() { return QString("abc").length(); }
#endif
struct Test {
int thingy(int val);
};
#endif
To copy to clipboard, switch view to plain text mode
//lib.cpp
#include "lib.h"
int Test::thingy(int val)
{
return val * 2;
}
//lib.cpp
#include "lib.h"
int Test::thingy(int val)
{
return val * 2;
}
To copy to clipboard, switch view to plain text mode
TEMPLATE = lib
TARGET = test
QT =
HEADERS += lib.h
SOURCES += lib.cpp
TEMPLATE = lib
TARGET = test
QT =
HEADERS += lib.h
SOURCES += lib.cpp
To copy to clipboard, switch view to plain text mode
$ qmake
$ make
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4 -I. -o lib.o lib.cpp
rm -f libtest.so.1.0.0 libtest.so libtest.so.1 libtest.so.1.0
g++ -Wl,-O1 -shared -Wl,-soname,libtest.so.1 -o libtest.so.1.0.0 lib.o -L/usr/lib64/qt4 -lpthread
ln -s libtest.so.1.0.0 libtest.so
ln -s libtest.so.1.0.0 libtest.so.1
ln -s libtest.so.1.0.0 libtest.so.1.0
$ ldd libtest.so
linux-vdso.so.1 => (0x00007fffbf3ff000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f595a06e000)
libstdc++.so.6 => /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/libstdc++.so.6 (0x00007f5959d64000)
libm.so.6 => /lib64/libm.so.6 (0x00007f5959ae2000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f59598cc000)
libc.so.6 => /lib64/libc.so.6 (0x00007f595953d000)
/lib64/ld-linux-x86-64.so.2 (0x00007f595a4bd000)
$ qmake
$ make
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4 -I. -o lib.o lib.cpp
rm -f libtest.so.1.0.0 libtest.so libtest.so.1 libtest.so.1.0
g++ -Wl,-O1 -shared -Wl,-soname,libtest.so.1 -o libtest.so.1.0.0 lib.o -L/usr/lib64/qt4 -lpthread
ln -s libtest.so.1.0.0 libtest.so
ln -s libtest.so.1.0.0 libtest.so.1
ln -s libtest.so.1.0.0 libtest.so.1.0
$ ldd libtest.so
linux-vdso.so.1 => (0x00007fffbf3ff000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f595a06e000)
libstdc++.so.6 => /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/libstdc++.so.6 (0x00007f5959d64000)
libm.so.6 => /lib64/libm.so.6 (0x00007f5959ae2000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f59598cc000)
libc.so.6 => /lib64/libc.so.6 (0x00007f595953d000)
/lib64/ld-linux-x86-64.so.2 (0x00007f595a4bd000)
To copy to clipboard, switch view to plain text mode
Bookmarks