libstdc++ - not linking statically using qmake - c++

I compile a dynamic and static version of my library on Debian 7. My user wants to use the library on RHEL6, so after reading many posts it seemed linking libstdc++ statically should fix the issue.
I am using qmake, so in the .pro file I added
unix: QMAKE_CXXFLAGS_RELEASE += -static-libstdc++ -static-libgcc -fvisibility=hidden -w
Then I execute following command:
qmake MyLibrary.pro -spec linux-g++-64 "CONFIG += release"
and the output is
g++ -c -m64 -pipe -O2 -static-libstdc++ -static-libgcc -fvisibility=hidden -w -Wall -W -D_REENTRANT -fPIC -DMYLIBRARY_LIBRARY -DQT_NO_DEBUG -DQT_PLUGIN -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4 -IMyLibrary/Curl/include -I. -o LexAbstraction.o MyLibrary/LexAbstraction.cpp
g++ -c -m64 -pipe -O2 -static-libstdc++ -static-libgcc -fvisibility=hidden -w -Wall -W -D_REENTRANT -fPIC -DMYLIBRARY_LIBRARY -DQT_NO_DEBUG -DQT_PLUGIN -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4 -IMyLibrary/Curl/include -I. -o MyLibrary.o MyLibrary/MyLibrary.cpp
g++ -c -m64 -pipe -O2 -static-libstdc++ -static-libgcc -fvisibility=hidden -w -Wall -W -D_REENTRANT -fPIC -DMYLIBRARY_LIBRARY -DQT_NO_DEBUG -DQT_PLUGIN -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4 -IMyLibrary/Curl/include -I. -o LexBotan.o MyLibrary/LexBotan.cpp
g++ -c -m64 -pipe -O2 -static-libstdc++ -static-libgcc -fvisibility=hidden -w -Wall -W -D_REENTRANT -fPIC -DMYLIBRARY_LIBRARY -DQT_NO_DEBUG -DQT_PLUGIN -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4 -IMyLibrary/Curl/include -I. -o LexCrypter.o MyLibrary/LexCrypter.cpp
g++ -c -m64 -pipe -O2 -static-libstdc++ -static-libgcc -fvisibility=hidden -w -Wall -W -D_REENTRANT -fPIC -DMYLIBRARY_LIBRARY -DQT_NO_DEBUG -DQT_PLUGIN -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4 -IMyLibrary/Curl/include -I. -o LexHelper.o MyLibrary/LexHelper.cpp
rm -f libMyLibrary.so
g++ -m64 -Wl,-O1 -shared -o libMyLibrary.so LexAbstraction.o MyLibrary.o LexBotan.o LexCrypter.o LexHelper.o -L/usr/lib/x86_64-linux-gnu -lpthread
But when I execute
ldd -v libMyLibrary.so | grep GLIBCXX
It gives following output:
libstdc++.so.6 (GLIBCXX_3.4.15) => /usr/lib/x86_64-linux-gnu/libstdc++.so.6
libstdc++.so.6 (GLIBCXX_3.4.9) => /usr/lib/x86_64-linux-gnu/libstdc++.so.6
libstdc++.so.6 (GLIBCXX_3.4) => /usr/lib/x86_64-linux-gnu/libstdc++.so.6

-static-libstdc++ and -static-libgcc are linkage options, but you are
passing them for compilation (where they are ignored) and not for linkage.
C++ compile options go in QMAKE_CXXFLAGS_{RELEASE|DEBUG}. Linkage
options go in QMAKE_LFLAGS_{RELEASE|DEBUG}.
-fvisibility is a compile option, so it should remain in QMAKE_CXXFLAGS_RELEASE

Related

undefined reference to `__cudaPopCallConfiguration'

I am trying to compile a cuda code that I have received from Github (https://github.com/exafmm/exafmm-alpha).
The Makefile.include contains:
.SUFFIXES: .cxx .cu .f90 .o
.PHONY: docs
CUDA_INSTALL_PATH = /usr/local/cuda
#DEVICE = cpu
DEVICE = gpu
CXX = mpicxx -g -O3 -lstdc++ -fPIC -fopenmp -ffast-math -funroll-loops -rdynamic -Wfatal-errors -I../include
NVCC = nvcc -Xcompiler "-fopenmp -O3" -lstdc++ -use_fast_math -I../include
FC = mpif90 -g -O3 -fPIC -fopenmp -funroll-loops -rdynamic -I../include
FCC = mpif90 -c -O3 -fPIC -fopenmp -funroll-loops -rdynamic -I../include
LFLAGS = -D$(DEVICE) -lstdc++ -ldl -lm
LFLAGS += -lmpi_cxx
LFLAGS += -lpthread
ifeq ($(DEVICE),gpu)
LFLAGS += -lcudart
endif
OBJECT = ../kernel/$(DEVICE)Laplace.o ../kernel/$(DEVICE)BiotSavart.o\
../kernel/$(DEVICE)Stretching.o ../kernel/$(DEVICE)Gaussian.o\
../kernel/$(DEVICE)CoulombVdW.o
.cxx.o:
$(CXX) -c $? -o $# $(LFLAGS)
.cu.o:
$(NVCC) -c $? -o $# $(LFLAGS)
.f90.o:
$(FC) -c $? -o $#
And the Makefile is:
include ../Makefile.include
lib_parallel_ij: parallel_wrapper_ij.o $(OBJECT)
ar -cr libfmm.a parallel_wrapper_ij.o $(OBJECT)
ranlib libfmm.a
test_parallel_ij: test_parallel_ij.o
make lib_parallel_ij
$(FC) $? -L. -lfmm $(LFLAGS)
mpirun -np 2 ./a.out
When I tried to compile the code, I get the following errors.
mpif90 -g -O3 -fPIC -fopenmp -funroll-loops -rdynamic -I../include -c test_parallel_ij.f90 -o test_parallel_ij.o
make lib_parallel_ij
make[1]: Entering directory '/home/bidesh/panelCode/UVLM/NVLM_FMM/solver_single_rotor_try/exafmm-alpha-vortex/wrapper'
mpicxx -g -O3 -lstdc++ -fPIC -fopenmp -ffast-math -funroll-loops -rdynamic -Wfatal-errors -I../include -c parallel_wrapper_ij.cxx -o parallel_wrapper_ij.o -Dgpu -lstdc++ -ldl -lm -lmpi_cxx -lpthread -lcudart
nvcc -Xcompiler "-fopenmp -O3" -lstdc++ -use_fast_math -I../include -c ../kernel/gpuLaplace.cu -o ../kernel/gpuLaplace.o -Dgpu -lstdc++ -ldl -lm -lmpi_cxx -lpthread -lcudart
nvcc -Xcompiler "-fopenmp -O3" -lstdc++ -use_fast_math -I../include -c ../kernel/gpuBiotSavart.cu -o ../kernel/gpuBiotSavart.o -Dgpu -lstdc++ -ldl -lm -lmpi_cxx -lpthread -lcudart
../kernel/gpuBiotSavart.cu(542): warning #177-D: variable "SQRT4PI" was declared but never referenced
../kernel/gpuBiotSavart.cu(548): warning #550-D: variable "r" was set but never used
nvcc -Xcompiler "-fopenmp -O3" -lstdc++ -use_fast_math -I../include -c ../kernel/gpuStretching.cu -o ../kernel/gpuStretching.o -Dgpu -lstdc++ -ldl -lm -lmpi_cxx -lpthread -lcudart
nvcc -Xcompiler "-fopenmp -O3" -lstdc++ -use_fast_math -I../include -c ../kernel/gpuGaussian.cu -o ../kernel/gpuGaussian.o -Dgpu -lstdc++ -ldl -lm -lmpi_cxx -lpthread -lcudart
nvcc -Xcompiler "-fopenmp -O3" -lstdc++ -use_fast_math -I../include -c ../kernel/gpuCoulombVdW.cu -o ../kernel/gpuCoulombVdW.o -Dgpu -lstdc++ -ldl -lm -lmpi_cxx -lpthread -lcudart
ar -cr libfmm.a parallel_wrapper_ij.o ../kernel/gpuLaplace.o ../kernel/gpuBiotSavart.o ../kernel/gpuStretching.o ../kernel/gpuGaussian.o ../kernel/gpuCoulombVdW.o
ranlib libfmm.a
make[1]: Leaving directory '/home/bidesh/panelCode/UVLM/NVLM_FMM/solver_single_rotor_try/exafmm-alpha-vortex/wrapper'
mpif90 -g -O3 -fPIC -fopenmp -funroll-loops -rdynamic -I../include test_parallel_ij.o -L. -lfmm -Dgpu -lstdc++ -ldl -lm -lmpi_cxx -lpthread -lcudart
./libfmm.a(gpuLaplace.o): In function `LaplaceL2P_GPU(int*, int*, double*, double*)':
tmpxft_0000397c_00000000-6_gpuLaplace.cudafe1.cpp:(.text+0xc2): undefined reference to `__cudaPopCallConfiguration'
....
./libfmm.a(gpuLaplace.o): In function `Kernel::LaplaceL2P()':
tmpxft_0000397c_00000000-6_gpuLaplace.cudafe1.cpp:(.text+0x3e06): undefined reference to `__cudaPushCallConfiguration'
....
./libfmm.a(gpuCoulombVdW.o): In function `__sti____cudaRegisterAll()':
tmpxft_00003a87_00000000-6_gpuCoulombVdW.cudafe1.cpp:(.text.startup+0x189): undefined reference to `__cudaRegisterFatBinaryEnd'
....
I tried to find the installation of cuda:
whereis cuda
cuda: /usr/lib/cuda /usr/include/cuda.h /usr/local/cuda
I could not fix the error, can anyone give any hint to fix it?
Thank you.

Python: Install sip

I wanted to install the python module sip (version 4.17) according to the documentation on my Windows 7 machine:
Download from the official page as described in the documentation
Unzip the repository to the folder C:\Python27\Lib\site-packages\sip-4.17
Configure the package with the command python.exe configure.py in this folder
Building the module mingw32-make fails.
Mingw's make returns the following error message:
mingw32-make[1]: Entering directory 'C:/Python27/Lib/site-packages/sip-4.17/sipgen'
gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -o main.o main.c
gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -o transform.o transform.c
gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -o gencode.o gencode.c
gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -o extracts.o extracts.c
gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -o export.o export.c
gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -o heap.o heap.c
gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -o parser.o parser.c
gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -o lexer.o lexer.c
g++ -mthreads -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-subsystem,console -Wl,-s -o sip.exe main.o transform.o gencode.o extracts.o export.o heap.o parser.o lexer.o
mingw32-make[1]: Leaving directory 'C:/Python27/Lib/site-packages/sip-4.17/sipgen'
mingw32-make[1]: Entering directory 'C:/Python27/Lib/site-packages/sip-4.17/siplib'
gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -IC:\Python27\include -o siplib.o siplib.c
gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -IC:\Python27\include -o apiversions.o apiversions.c
gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -IC:\Python27\include -o descriptors.o descriptors.c
gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -IC:\Python27\include -o qtlib.o qtlib.c
gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -IC:\Python27\include -o threads.o threads.c
gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -IC:\Python27\include -o objmap.o objmap.c
gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -IC:\Python27\include -o voidptr.o voidptr.c
gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -IC:\Python27\include -o array.o array.c
g++ -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -IC:\Python27\include -o bool.o bool.cpp
g++ -mthreads -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -shared -Wl,-subsystem,console -Wl,-s -o sip.pyd siplib.o apiversions.o descriptors.o qtlib.o threads.o objmap.o voidptr.o array.o bool.o -LC:\Python27\libs -lpython27
C:\Python27\libs/libpython27.a: error adding symbols: File format not recognized
collect2.exe: error: ld returned 1 exit status
Makefile:36: recipe for target 'sip.pyd' failed
mingw32-make[1]: *** [sip.pyd] Error 1
mingw32-make[1]: Leaving directory 'C:/Python27/Lib/site-packages/sip-4.17/siplib'
Makefile:3: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
I have no clue why it failed to compile the code saying File format not recognized. Is it the same mistake as in g++ output: file not recognized: File format not recognized?
Thank you for your help in advance!
Comment:
I followed the following questions too but I want to install it using the zip file - so I know what is installed.
Can't configure pyQt
How to install SIP & PyQT on windows 7
How did you configure SIP? You need to choose a configuration option (see documentation in the docs file of the SIP archive). I got this to work once I chose --platform win32-g++.

Qmake - how to configure include path order?

I have Qt-Creator on OpenSUSE. In it a have a C++ project with compiler 'clang'. There I have this '.pro' configuration:
INCLUDEPATH += "/✪Data_Disk⚜✼/Build/include/c++/v1/"
LIBS += "-stdlib=libc++"
LIBS += "/✪Data_Disk⚜✼/Build/lib/libc++abi.a"
QMAKE_CXXFLAGS += -std=c++14 -stdlib=libc++
TARGET = testCpp
SOURCES += main.cpp
And when I compile I got this output:
clang++ -c -pipe -Qunused-arguments -std=c++14 -stdlib=libc++ -g -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/unsupported/linux-clang -I../testCpp -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include -I/✪Data_Disk⚜✼/Build/include/c++/v1 -I. -I../testCpp -I. -o main.o ../testCpp/main.cpp
I want it to be either:
clang++ -c -pipe -Qunused-arguments -std=c++14 -stdlib=libc++ -g -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/✪Data_Disk⚜✼/Build/include/c++/v1 -I/usr/share/qt4/mkspecs/unsupported/linux-clang -I../testCpp -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include -I. -I../testCpp -I. -o main.o ../testCpp/main.cpp
Or:
clang++ -c -pipe -Qunused-arguments -std=c++14 -stdlib=libc++ -g -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/✪Data_Disk⚜✼/Build/include/c++/v1 -o main.o ../testCpp/main.cpp
In other words - I want to either include this path (
-I/✪Data_Disk⚜✼/Build/include/c++/v1
) before the system defined ones or to completely remove them and leave only it. Any ideas?
If you look into qmake source, for example Win32MakefileGenerator::writeStandardParts() or UnixMakefileGenerator::writeMakeParts() you will see that the flags are included in the following order:
QMAKE_CC
QMAKE_CXX
QMAKE_CFLAGS
QMAKE_CXXFLAGS
INCLUDEPATH
...
INCLUDEPATH always goes after the first four. You can use QMAKE_CXXFLAGS and add -I path there:
QMAKE_CXXFLAGS += -I/✪Data_Disk⚜✼/Build/include/c++/v1

Using external shared library in R

I have written a few c++ function for integration into an R package by Rcpp, and these functions reply on the boost filesystem library. I have specified these in src/Makevar:
PKG_LIBS = -lboost_system -lboost_filesystem
And the package compiles ok:
==> R CMD INSTALL --preclean --no-multiarch --with-keep.source txtutils2
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include" -fPIC -std=c++11 -c RcppExports.cpp -o RcppExports.o
* installing to library ‘/Library/Frameworks/R.framework/Versions/3.1/Resources/library’
* installing *source* package ‘txtutils2’ ...
** libs
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include" -fPIC -std=c++11 -c bedcollc.cpp -o bedcollc.o
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include" -fPIC -std=c++11 -c bedcollr.cpp -o bedcollr.o
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include" -fPIC -std=c++11 -c countlines.cpp -o countlines.o
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include" -fPIC -std=c++11 -c fileSize.cpp -o fileSize.o
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include" -fPIC -std=c++11 -c ncols.cpp -o ncols.o
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include" -fPIC -std=c++11 -c printlines.cpp -o printlines.o
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include" -fPIC -std=c++11 -c readbed.cpp -o readbed.o
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include" -fPIC -std=c++11 -c readcol.cpp -o readcol.o
clang++ -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RcppArmadillo/include" -fPIC -std=c++11 -c readcols.cpp -o readcols.o
clang++ -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -o txtutils2.so RcppExports.o bedcollc.o bedcollr.o countlines.o fileSize.o ncols.o printlines.o readbed.o readcol.o readcols.o -lboost_system -lboost_filesystem -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing to /Library/Frameworks/R.framework/Versions/3.1/Resources/library/txtutils2/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (txtutils2)
But when I try to load it, something goes wrong:
> library(txtutils2)
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/Library/Frameworks/R.framework/Versions/3.1/Resources/library/txtutils2/libs/txtutils2.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.1/Resources/library/txtutils2/libs/txtutils2.so, 6): Library not loaded: libboost_system.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.1/Resources/library/txtutils2/libs/txtutils2.so
Reason: image not found
Error: package or namespace load failed for ‘txtutils2’
I am on osx 10.10, if that matters.
General instructions on usage of external shared libs in R is also most welcome.
As far as I know, what you have met is not the problem of Rcpp even not the problem of R. It may be about linking on OSX.
I don't use Mac, so I just give you some advice. Try
otool -L yourpackagename.so
You should see a link to the boost library you use. You need to check whether the path is right.

Combine two GCC commands / Make one Makefile out of two (QT and GCC Plugin)

I wrote a GCC Plugin which works very well. I created a Makefile which executes the following command to create the Plugin:
$ g++ -I$(INCLUDE_PATHS) -fPIC -shared $(SOURCE_PATHS) -o Plugin.so
I execute the Plugin with following command:
$ g++ -S -fplugin=./Plugin.so /TestProgramm.cpp
This works pretty well. Now I want to display a QT GUI when calling the Plugin. I wrote the GUI in Eclipse, so i got an auto-generated MakeFile. When executing the GUI, Eclipse executes following commands:
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I$(QT_INCLUDE_PATHS) -o debug/GUI.o GUI.cpp
g++ -Wl,-rpath,/opt/QtSDK/Desktop/Qt/4.8.1/gcc/lib -o GraphGUI debug/GUI.o debug/main.o debug/GraphGUI.o debug/moc_GraphGUI.o -L/opt/QtSDK/Desktop/Qt/4.8.1/gcc/lib -lQtGui -L/opt/QtSDK/Desktop/Qt/4.8.1/gcc/lib -L/usr/X11R6/lib -lQtCore -lpthread
GraphGUI and GUI are the classes of the GUI I wrote.
Now I want to combine these statements in my own Makefile, so that the Compiler compiles my Plugin and my GUI. I started working with Makefiles a few days ago, so I only got the basics about Makefiles. Hope somebody can help me.
Here is my Makefile:
GCC := g++
FILENAME := Explorer.so
GCC_INCLUDE := -I/usr/lib/gcc/i686-linux-gnu/4.6/plugin/include
QT_INCLUDE := -I/opt/QtSDK/Desktop/Qt/4.8.1/gcc/mkspecs/default \
-I/opt/QtSDK/Desktop/Qt/4.8.1/gcc/include/QtCore \
-I/opt/QtSDK/Desktop/Qt/4.8.1/gcc/include/QtGui \
-I/opt/QtSDK/Desktop/Qt/4.8.1/gcc/include
SOURCE_FILES = ## Some .cpp files for the plugin ##
$(FILENAME):
#$(GCC) $(GCC_INCLUDE) -fPIC -shared $(SOURCE_FILES) -o $# $^
clean:
#rm $(FILENAME)
I tried creating object files of the GUI and then include them in the command which creates the Plugin; like this:
$(GCC) -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED $(QT_INCLUDE) -Idebug -I. -o debug/GUI.o src/Visualize/GUI.cpp
$(GCC) -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED $(QT_INCLUDE) -Idebug -I. -o debug/GraphGUI.o src/Visualize/GraphGUI.cpp
# /opt/QtSDK/Desktop/Qt/4.8.1/gcc/bin/moc -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED $(QT_INCLUDE) -Idebug -I. src/Visualize/GraphGUI.h -o debug/moc_GraphGUI.cpp
# $(GCC) -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED $(QT_INCLUDE) -Idebug -I. -o debug/moc_GraphGUI.o debug/moc_GraphGUI.cpp
$(GCC) $(PLUGIN_INCLUDE) -fPIC -shared $(SOURCE_FILES) debug/GraphGUI.o debug/GUI.o -o $# $^
If i execute it like this, I get undefined symbol: _ZN11QMainWindowC2EP7QWidget6QFlagsIN2Qt10WindowTypeEE error. If I execute the two commands beginning with "#" too, I get "undefined reference to main". I just copied these commands from eclipse; I don't actually know what they are doing.