#!/bin/sh


QTBASE=/data/dev/qt-5/qtbase
QTNS=-DQT_NAMESPACE=Myns

git clean -dxf 
ls 

g++ -o debuggee debuggee.cpp


g++ -c -fPIC $QTNS \
-I$QTBASE/include -I$QTBASE/include/QtGui -I$QTBASE/include/QtCore \
-o dummylib.o dummylib.cpp

g++ -Wl,-rpath,$QTBASE/lib -shared -Wl,-soname,libdummy.so \
-o libdummy.so dummylib.o \
-L$QTBASE/lib -lQt5Guimyns -lQt5Coremyns -lGL -lpthread 


g++ -fPIE $QTNS \
-I$QTBASE/include -I$QTBASE/include/QtCore \
-Wl,-rpath,\$ORIGIN  -Wl,-rpath,$QTBASE/lib \
main.cpp libdummy.so -o testcase \
-L$QTBASE/lib -lQt5Guimyns -lQt5Coremyns -lGL -lpthread 


# Always succeeds:
strace -o str ./testcase

# The following fails, but succeeds if
#   - the call to accessLibrary() is removed in main.cpp          -- or --
#   - the (unused) function 'stuff' is removed from dummylib.cpp  -- or --
#   - the QVariant(QFont()) is replaced in dummylib.cpp 
./testcase


