undefined reference to `__cudaPopCallConfiguration' - c++

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.

Related

How to rectify `undefined reference to `MPI::Comm::Comm()'` when compiling with Makefile?

I am trying to compile a code by Makefile. I received the code from github. I tried to implement the solution from links:
[https://github.com/LLNL/scr/issues/130][1]
[https://stackoverflow.com/questions/62461718/mpi-complile-error-undefined-reference-to-mpiwinfree][2], etc.
These solutions are not working for me or they are too technical. I am sorry to say as I am not from a programming background, it is difficult for me to understand.
The make file are as follows:
Makefile.include
.SUFFIXES: .cxx .cu .f90 .o
.PHONY: docs
CUDA_INSTALL_PATH = /usr/local/cuda
DEVICE = cpu
#~ DEVICE = gpu
CXX = mpicxx -g -O3 -std=c++11 -fPIC -fopenmp -ffast-math -funroll-loops -rdynamic -Wfatal-errors -I../include
NVCC = nvcc -Xcompiler "-fopenmp -O3" -std=c++11 -use_fast_math -I../include
FC = mpif90 -g -O3 -fPIC -fopenmp -funroll-loops -rdynamic -I../include
LFLAGS = -D$(DEVICE) -lstdc++ -ldl -lm
#~ LFLAGS += -lmpi_cxx
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 Makefile:
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
clean:
make -C .. clean
When I am trying to compile it. It gives me 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 -std=c++11 -fPIC -fopenmp -ffast-math -funroll-loops -rdynamic -Wfatal-errors -I../include -c parallel_wrapper_ij.cxx -o parallel_wrapper_ij.o -Dcpu -lstdc++ -ldl -lm
mpicxx -g -O3 -std=c++11 -fPIC -fopenmp -ffast-math -funroll-loops -rdynamic -Wfatal-errors -I../include -c ../kernel/cpuLaplace.cxx -o ../kernel/cpuLaplace.o -Dcpu -lstdc++ -ldl -lm
mpicxx -g -O3 -std=c++11 -fPIC -fopenmp -ffast-math -funroll-loops -rdynamic -Wfatal-errors -I../include -c ../kernel/cpuBiotSavart.cxx -o ../kernel/cpuBiotSavart.o -Dcpu -lstdc++ -ldl -lm
mpicxx -g -O3 -std=c++11 -fPIC -fopenmp -ffast-math -funroll-loops -rdynamic -Wfatal-errors -I../include -c ../kernel/cpuStretching.cxx -o ../kernel/cpuStretching.o -Dcpu -lstdc++ -ldl -lm
mpicxx -g -O3 -std=c++11 -fPIC -fopenmp -ffast-math -funroll-loops -rdynamic -Wfatal-errors -I../include -c ../kernel/cpuGaussian.cxx -o ../kernel/cpuGaussian.o -Dcpu -lstdc++ -ldl -lm
mpicxx -g -O3 -std=c++11 -fPIC -fopenmp -ffast-math -funroll-loops -rdynamic -Wfatal-errors -I../include -c ../kernel/cpuCoulombVdW.cxx -o ../kernel/cpuCoulombVdW.o -Dcpu -lstdc++ -ldl -lm
ar -cr libfmm.a parallel_wrapper_ij.o ../kernel/cpuLaplace.o ../kernel/cpuBiotSavart.o ../kernel/cpuStretching.o ../kernel/cpuGaussian.o ../kernel/cpuCoulombVdW.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 -Dcpu -lstdc++ -ldl -lm
./libfmm.a(parallel_wrapper_ij.o): In function `MPI::Op::Init(void (*)(void const*, void*, int, MPI::Datatype const&), bool)':
/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/ompi/mpi/cxx/op_inln.h:121: undefined reference to `ompi_mpi_cxx_op_intercept'
./libfmm.a(parallel_wrapper_ij.o): In function `MPI::Intracomm::Clone() const':
/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/ompi/mpi/cxx/intracomm_inln.h:23: undefined reference to `MPI::Comm::Comm()'
./libfmm.a(parallel_wrapper_ij.o): In function `MPI::Graphcomm::Clone() const':
/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/ompi/mpi/cxx/intracomm.h:25: undefined reference to `MPI::Comm::Comm()'
./libfmm.a(parallel_wrapper_ij.o): In function `MPI::Cartcomm::Sub(bool const*) const':
/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/ompi/mpi/cxx/intracomm.h:25: undefined reference to `MPI::Comm::Comm()'
./libfmm.a(parallel_wrapper_ij.o): In function `MPI::Intracomm::Create_graph(int, int const*, int const*, bool) const':
/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/ompi/mpi/cxx/intracomm.h:25: undefined reference to `MPI::Comm::Comm()'
./libfmm.a(parallel_wrapper_ij.o): In function `MPI::Cartcomm::Clone() const':
/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/ompi/mpi/cxx/intracomm.h:25: undefined reference to `MPI::Comm::Comm()'
./libfmm.a(parallel_wrapper_ij.o):/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/ompi/mpi/cxx/intracomm.h:25: more undefined references to `MPI::Comm::Comm()' follow
./libfmm.a(parallel_wrapper_ij.o):(.data.rel.ro._ZTVN3MPI8DatatypeE[_ZTVN3MPI8DatatypeE]+0x78): undefined reference to `MPI::Datatype::Free()'
./libfmm.a(parallel_wrapper_ij.o):(.data.rel.ro._ZTVN3MPI3WinE[_ZTVN3MPI3WinE]+0x48): undefined reference to `MPI::Win::Free()'
collect2: error: ld returned 1 exit status
Makefile:48: recipe for target 'test_parallel_ij' failed
make: *** [test_parallel_ij] Error 1
I am unable to solve the error. I couldn't compile the code. I will be greatly helped if I can get some clue to compile it.
Thanks a lot.
[1]: https://github.com/LLNL/scr/issues/130
[2]: MPI complile error, undefined reference to `MPI::Win::Free()

Makefile undefined reference to my namespace objects/functions/constructors

My code compiles well in codeblocks, but my makefile can't compile because of undefined reference to items with my namespace Chess
how should i specify the namespace in makefile or fix it?
here's the errors example:
King.cpp:35: undefined reference to `Chess::Board::getPiece(Chess::Position const&) const'
here's my makefile
CXXFLAGS = -ISFML-2.4.2/include -std=c++11
LXXFLAGS = -LSFML-2.4.2/lib -lsfml-graphics-d -lsfml-audio-d -lsfml-network-d -lsfml-window-d -lsfml-system-d -std=c++11
main.exe: main.o bishop.o king.o knight.o pawn.o position.o queen.o rook.o gui.o piece.o board.o Bishop.hpp Board.hpp
g++ -std=c++11 main.o bishop.o king.o knight.o pawn.o position.o queen.o rook.o gui.o piece.o -o main $(LXXFLAGS)
main.o: main.cpp GUI.hpp Board.hpp
g++ -fexceptions -g -std=c++11 -std=c++11 main.cpp -c $(CXXFLAGS)
bishop.o: Bishop.cpp Bishop.hpp Board.hpp
g++ -fexceptions -g -std=c++11 -std=c++11 Bishop.cpp -c $(CXXFLAGS)
king.o: King.cpp King.hpp Rook.hpp Board.hpp
g++ -fexceptions -g -std=c++11 -std=c++11 King.cpp -c $(CXXFLAGS)
pawn.o: Pawn.cpp Pawn.hpp Board.hpp
g++ -fexceptions -g -std=c++11 -std=c++11 Pawn.cpp -c $(CXXFLAGS)
position.o: Position.cpp Position.hpp
g++ -fexceptions -g -std=c++11 -std=c++11 Position.cpp -c $(CXXFLAGS)
queen.o: Queen.cpp Queen.hpp Board.hpp
g++ -fexceptions -g -std=c++11 -std=c++11 Queen.cpp -c $(CXXFLAGS)
rook.o: Rook.cpp Rook.hpp Board.hpp
g++ -fexceptions -g -std=c++11 -std=c++11 Rook.cpp -c $(CXXFLAGS)
knight.o: Knight.cpp Knight.hpp Board.hpp
g++ -fexceptions -g -std=c++11 -std=c++11 Knight.cpp -c $(CXXFLAGS)
gui.o: GUI.cpp GUI.hpp Queen.hpp Rook.hpp Bishop.hpp Knight.hpp
g++ -fexceptions -g -std=c++11 -std=c++11 GUI.cpp -c $(CXXFLAGS)
piece.o: Piece.cpp Piece.hpp Board.hpp
g++ -fexceptions -g -std=c++11 -std=c++11 Piece.cpp -c $(CXXFLAGS)
board.o: Board.cpp Board.hpp Pawn.hpp Rook.hpp Knight.hpp Queen.hpp King.hpp
g++ -fexceptions -g -std=c++11 -std=c++11 Board.cpp -c $(CXXFLAGS)
You forgot to include board.o when compiling main.exe

Confusion with Makefile linking a library that seems to link but I can't call

I am trying yo build a Makefile for a project that uses the soplex library (which also depends on libz and libgmp).
So I have this little Makefile:
SOPLEXPATH =../../lib/soplex-3.0.0/lib/
SOPLEXINCLUDE =../../lib/soplex-3.0.0/src/
SOPLEXDEP =../../lib/soplex-3.0.0/src/
CC = g++
CPPFLAGS = -g -std=c++0x -O3 -I $(SOPLEXINCLUDE)
#CPPFLAGS += -DNDEBUG
CPPFLAGS += -pg -ggdb
CPPFLAGS += -Wall -Werror=return-type
LIBS = -L $(SOPLEXPATH) -lz -lgmp -lsoplex
SRCS = $(wildcard ./src/core/*.cpp)
OBJS = $(addsuffix .o, $(basename $(SRCS)))
DEPS = $(addsuffix .d, $(basename $(SRCS)))
all : kea
kea : $(OBJS)
$(CC) $(CPPFLAGS) $(LIBS) -o bin/kea-core $(OBJS)
clean :
rm -f bin/kea-core $(OBJS) $(DEPS) *~
-include $(DEPS)
%.d: %.c
#$(CC) -MM -MT $(subst .d,.o,$#) -MT $# $(CPPFLAGS) $< > $#
And all seems to compile to object files (.o) correctly, but then the linker complains about not finding the function soplex::SoPlex::SoPlex() (the constructor of SoPlex):
g++ -g -std=c++0x -O3 -I ../../lib/soplex-3.0.0/src/ -pg -ggdb -Wall -Werror=return-type -c -o src/core/ecircuit.o src/core/ecircuit.cpp
g++ -g -std=c++0x -O3 -I ../../lib/soplex-3.0.0/src/ -pg -ggdb -Wall -Werror=return-type -c -o src/core/solver_soplex.o src/core/solver_soplex.cpp
g++ -g -std=c++0x -O3 -I ../../lib/soplex-3.0.0/src/ -pg -ggdb -Wall -Werror=return-type -c -o src/core/main.o src/core/main.cpp
g++ -g -std=c++0x -O3 -I ../../lib/soplex-3.0.0/src/ -pg -ggdb -Wall -Werror=return-type -L ../../lib/soplex-3.0.0/lib/ -lz -lgmp -lsoplex -o bin/kea-core ./src/core/ecircuit.o ./src/core/solver_soplex.o ./src/core/main.o
./src/core/solver_soplex.o: In function `SolvSoplex::SolvSoplex(ECircuit&, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >&, SolvSoplex::Mode)':
/home/diego/Projects/kea-landscape-tool/src/core/solver_soplex.cpp:9: undefined reference to `soplex::SoPlex::SoPlex()'
/home/diego/Projects/kea-landscape-tool/src/core/solver_soplex.cpp:9: undefined reference to `soplex::SoPlex::~SoPlex()'
collect2: error: ld returned 1 exit status
Makefile:20: recipe for target 'kea' failed
make: *** [kea] Error 1
Since all the .o files are created I tried to compile by hand doing:
g++ -g -std=c++0x -O3 -I ../../lib/soplex-3.0.0/src/ -Wall -Werror=return-type -pg -ggdb -L/home/diego/Projects/kea-landscape-tool/../../lib/soplex-3.0.0/lib/ -lsoplex -lz -lgmp -o bin/kea-core src/core/main.o src/core/ecircuit.o src/core/solver_soplex.o
And it failed with the same error.
then I tried switching the position of the -L and -l.. flags like this, and it compiled: g++ -g -std=c++0x -O3 -I ../../lib/soplex-3.0.0/src/ -Wall -Werror=return-type -pg -ggdb -o bin/kea-core src/core/main.o src/core/ecircuit.o src/core/solver_soplex.o -L/home/diego/Projects/kea-landscape-tool/../../lib/soplex-3.0.0/lib/ -lsoplex -lz -lgmp
Seeing that, I tried to change the rule in the Makefile as follows:
kea : $(OBJS)
$(CC) $(CPPFLAGS) -o bin/kea-core $(OBJS) $(LIBS)
But it just failed miserably triggering about 100 errors all inside soplex.cpp (as in, it depends on -lgmp and -lz, but it could not find them? Too long to paste here)
I am pretty confused, any idea on how to fix this?
thanks.
Try putting the $LIBS at the end of the command.
Change this:
LIBS = -L $(SOPLEXPATH) -lz -lgmp -lsoplex
Into this:
LIBS = -L $(SOPLEXPATH) -lsoplex -lgmp -lz
You always need to put B after A, if A calls functions in B. With static libraries as least.

Getting error: "nvlink error : Undefined reference to '_ZN8Strategy8backtestEPddd'"

I am getting the following error when running make for my CUDA (v7.5) application:
nvlink error : Undefined reference to '_ZN8Strategy8backtestEPddd'
I'm not sure why. It seems something is likely wrong with my Makefile. Here it is -- any ideas what might be causing the error? Thank you in advance!
CC = nvcc
CFLAGS = -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field
LFLAGS = -L/usr/local/lib -Llib $(shell pkg-config --libs libmongoc-1.0 libbson-1.0)
INCLUDES = -I/usr/include -I/usr/local/include -Iinclude $(shell pkg-config --cflags libmongoc-1.0 libbson-1.0)
LIBS = -lgsl -lcblas
BIN = ./bin
OBJDIR = ./obj
OBJ = factories/optimizationStrategyFactory.o positions/callPosition.o positions/putPosition.o \
positions/position.o strategies/reversalsOptimizationStrategy.o strategies/optimizationStrategy.o \
strategies/strategy.o factories/optimizerFactory.o optimizers/reversalsOptimizer.o optimizers/optimizer.o \
factories/dataParserFactory.o dataParsers/oandaDataParser.o dataParsers/dataParser.o \
studies/study.o studies/smaStudy.o studies/emaStudy.o studies/rsiStudy.o \
studies/stochasticOscillatorStudy.o studies/polynomialRegressionChannelStudy.o
all: prepareData optimize
prepareData: src/prepareData.cu $(addprefix lib/,$(OBJ))
#mkdir -p $(BIN)
$(CC) $(CFLAGS) $(INCLUDES) -o $(BIN)/$# src/prepareData.cu $(addprefix $(OBJDIR)/,$(addprefix lib/,$(OBJ))) $(LFLAGS) $(LIBS)
optimize: src/optimize.cu $(addprefix lib/,$(OBJ))
#mkdir -p $(BIN)
$(CC) $(CFLAGS) $(INCLUDES) -o $(BIN)/$# src/optimize.cu $(addprefix $(OBJDIR)/,$(addprefix lib/,$(OBJ))) $(LFLAGS) $(LIBS)
%.o: %.cu
#mkdir -p $(OBJDIR)/lib/strategies $(OBJDIR)/lib/positions $(OBJDIR)/lib/factories $(OBJDIR)/lib/optimizers $(OBJDIR)/lib/dataParsers $(OBJDIR)/lib/studies
$(CC) $(CFLAGS) $(INCLUDES) -o $(OBJDIR)/$# --device-c $<
clean:
rm -rf $(BIN) $(OBJDIR)
And here is the full compiler output:
rm -rf ./bin ./obj
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./obj/lib/factories/optimizationStrategyFactory.o --device-c lib/factories/optimizationStrategyFactory.cu
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./obj/lib/positions/callPosition.o --device-c lib/positions/callPosition.cu
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./obj/lib/positions/putPosition.o --device-c lib/positions/putPosition.cu
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./obj/lib/positions/position.o --device-c lib/positions/position.cu
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./obj/lib/strategies/reversalsOptimizationStrategy.o --device-c lib/strategies/reversalsOptimizationStrategy.cu
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./obj/lib/strategies/optimizationStrategy.o --device-c lib/strategies/optimizationStrategy.cu
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./obj/lib/strategies/strategy.o --device-c lib/strategies/strategy.cu
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./obj/lib/factories/optimizerFactory.o --device-c lib/factories/optimizerFactory.cu
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./obj/lib/optimizers/reversalsOptimizer.o --device-c lib/optimizers/reversalsOptimizer.cu
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./obj/lib/optimizers/optimizer.o --device-c lib/optimizers/optimizer.cu
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./obj/lib/factories/dataParserFactory.o --device-c lib/factories/dataParserFactory.cu
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./obj/lib/dataParsers/oandaDataParser.o --device-c lib/dataParsers/oandaDataParser.cu
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./obj/lib/dataParsers/dataParser.o --device-c lib/dataParsers/dataParser.cu
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./obj/lib/studies/study.o --device-c lib/studies/study.cu
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./obj/lib/studies/smaStudy.o --device-c lib/studies/smaStudy.cu
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./obj/lib/studies/emaStudy.o --device-c lib/studies/emaStudy.cu
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./obj/lib/studies/rsiStudy.o --device-c lib/studies/rsiStudy.cu
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./obj/lib/studies/stochasticOscillatorStudy.o --device-c lib/studies/stochasticOscillatorStudy.cu
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./obj/lib/studies/polynomialRegressionChannelStudy.o --device-c lib/studies/polynomialRegressionChannelStudy.cu
nvcc -std=c++11 -m64 -arch=compute_35 -code=sm_35 --compiler-options=-Wall,-Wno-unused-function,-Wno-unused-local-typedef,-Wno-unused-private-field -I/usr/include -I/usr/local/include -Iinclude -I/usr/local/include/libmongoc-1.0 -I/usr/local/include/libbson-1.0 -o ./bin/prepareData src/prepareData.cu ./obj/lib/factories/optimizationStrategyFactory.o ./obj/lib/positions/callPosition.o ./obj/lib/positions/putPosition.o ./obj/lib/positions/position.o ./obj/lib/strategies/reversalsOptimizationStrategy.o ./obj/lib/strategies/optimizationStrategy.o ./obj/lib/strategies/strategy.o ./obj/lib/factories/optimizerFactory.o ./obj/lib/optimizers/reversalsOptimizer.o ./obj/lib/optimizers/optimizer.o ./obj/lib/factories/dataParserFactory.o ./obj/lib/dataParsers/oandaDataParser.o ./obj/lib/dataParsers/dataParser.o ./obj/lib/studies/study.o ./obj/lib/studies/smaStudy.o ./obj/lib/studies/emaStudy.o ./obj/lib/studies/rsiStudy.o ./obj/lib/studies/stochasticOscillatorStudy.o ./obj/lib/studies/polynomialRegressionChannelStudy.o -L/usr/local/lib -Llib -L/usr/local/lib -lsasl2 -lssl -lcrypto -lz -lmongoc-1.0 -lbson-1.0 -lgsl -lcblas
nvlink info : Function '_ZN12CallPosition13getProfitLossEv' has address taken but no possible call to it
nvlink info : Function '_ZN12CallPosition18getTransactionTypeEv' has address taken but no possible call to it
nvlink info : Function '_ZN11PutPosition13getProfitLossEv' has address taken but no possible call to it
nvlink info : Function '_ZN11PutPosition18getTransactionTypeEv' has address taken but no possible call to it
nvlink info : Function '_ZN8PositionD1Ev' has address taken but no possible call to it
nvlink info : Function '_ZN8PositionD0Ev' has address taken but no possible call to it
nvlink info : Function '_ZN12CallPositionD1Ev' has address taken but no possible call to it
nvlink info : Function '_ZN12CallPositionD0Ev' has address taken but no possible call to it
nvlink info : Function '_ZN11PutPositionD1Ev' has address taken but no possible call to it
nvlink info : Function '_ZN11PutPositionD0Ev' has address taken but no possible call to it
nvlink info : Function '_ZN29ReversalsOptimizationStrategy8backtestEPddd' has address taken but no possible call to it
nvlink info : Function '_ZN20OptimizationStrategy4tickEPd' has address taken but no possible call to it
nvlink info : Function '_ZN8Strategy8backtestEPddd' has address taken but no possible call to it
nvlink error : Undefined reference to '_ZN8Strategy8backtestEPddd' in './obj/lib/strategies/optimizationStrategy.o'
make: *** [prepareData] Error 255
Note this started happening around the time I added --device-c (which some code changes require).
Turns out objects passed to CUDA kernels cannot have virtual functions. See this thread.
However, it seems that objects instantiated and used only within the kernel can have virtual functions.

C++11 link issue with pthread

I have wrote a simple code which uses c++11 thread. It compiles correct but when I try to run it I have the following error:
terminate called after throwing an instance of 'std::system_error'
what(): Enable multithreading to use std::thread: Operation not permitted
Aborted (core dumped)
I am using gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1). This is the output of the makefile which I am using
g++ -std=c++11 -DHAVE_CONFIG_H -I. -I../../../.. -I../../../.. -I/usr/local_machine/openmpi-1.6.5/include -pthread -DMPIPP_H -DENABLE_MPI=1 -O3 -Wall -DNDEBUG -funroll-loops -finline-functions -pthread -fomit-frame-pointer -ffast-math -mfpmath=sse -msse3 -MT threadtest-threadtest.o -MD -MP -MF .deps/threadtest-threadtest.Tpo -c -o threadtest-threadtest.o `test -f 'threadtest.cc' || echo './'`threadtest.cc
mv -f .deps/threadtest-threadtest.Tpo .deps/threadtest-threadtest.Po
/bin/bash ../../../../libtool --tag=CXX --mode=link g++ -std=c++11 -O3 -Wall -DNDEBUG -funroll-loops -finline-functions -pthread -fomit-frame-pointer -ffast-math -mfpmath=sse -msse3 -o threadtest threadtest-threadtest.o -pthread -L/usr/local_machine/openmpi-1.6.5/lib -lmpi -ldl -lm -Wl,--export-dynamic -lrt -lnsl -lutil -lm -ldl ../../../../lib/libdunecommon.la -lm
libtool: link: g++ -std=c++11 -O3 -Wall -DNDEBUG -funroll-loops -finline-functions -pthread -fomit-frame-pointer -ffast-math -mfpmath=sse -msse3 -o threadtest threadtest-threadtest.o -pthread -Wl,--export-dynamic -L/usr/local_machine/openmpi-1.6.5/lib /usr/local_machine/openmpi-1.6.5/lib/libmpi.so -lrt -lnsl -lutil -ldl ../../../../lib/.libs/libdunecommon.a -llapack -lblas -lgfortran -lquadmath -lm -pthread -Wl,-rpath -Wl,/usr/local_machine/openmpi-1.6.5/lib -Wl,-rpath -Wl,/usr/local_machine/openmpi-1.6.5/lib
As you can see there is the flag -pthread. What am I doing wrong? Because if I compile a simple code as
g++ threadstest.cc -o threadstest -pthread -std=c++11
everything works fine therefore in my makefile there is something which interferes with -pthread but I don't understand what it is.
Additional information: a workaround which works is to add -Wl,--no-as-needed at the linking stage.
the answer for similar question "Compiling multithread code with g++ (-Wl,--no-as-needed NOT working)"
is
-pthread is a flag for the compiler, not the linker, the right one for the linker is -lpthread