make file error, should I specify a directory somewhere? - c++

My MakeFile
PC++ = mpicxx
CFLAGS = -O3 -D_MPI
LIBS = -llapack -lblas -lgsl -lgslcblas
CFLAGS = $(PFLAGS) $(Fmpi_define) $(GSLINC) -D_TIME #-DAS -D_TIME #-fast -xAVX # -D_TIME #-D_LOGGING #-DAS
LIBS = $(PLIBS)
GHEADERS = assert.h complex.h random.h sblas.h sfunction.h smesh.h sutil.h zeroin.h
QHEADERS = common.h inout.h intervals.h local.h matrixm.h mpi.h bcast.h number.h operators.h state.h stateim.h segment.h svdfunc.h tanmesh.h
ctqmc : ctqmc.o SMatrix1.o
$(PC++) $(CFLAGS) -o $# ctqmc.o SMatrix1.o $(LIBS)
all : ctqmc ctqmcf
ctqmcf : ctqmcf.o SMatrix1.o
$(PC++) $(CFLAGS) -o $# ctqmcf.o SMatrix1.o $(LIBS)
ctqmcf.o : ctqmc.cc
$(PC++) $(CFLAGS) -DAS -c -o ctqmcf.o $<
SMatrix1.o : SMatrix1.cc sfunction.h
$(PC++) -c $(CFLAGS) SMatrix1.cc
ctqmc.o : ctqmc.cc $(GHEADERS) $(QHEADERS)
$(PC++) $(CFLAGS) -c ctqmc.cc
clean :
rm -f ctqmc.o ctqmcf.o ctqmcf ctqmc SMatrix1.o
.SUFFIXES : .cc
.cc.o:
$(PC++) $(CFLAGS) -c $<
.SUFFIXES : .f
.f.o:
$(F77) $(FFLAGS) -c $<
returns this error when make is launched:
mpicxx -D_TIME -c ctqmc.cc
In file included from ctqmc.cc:41:
intervals.h: In member function ‘const funProxy<dcomplex>& nIntervals::exp_direct(int, int) const’:
intervals.h:58:97: warning: no return statement in function returning non-void [-Wreturn-type]
58 | const funProxy<dcomplex>& exp_direct(int type, int i) const {cerr<<"Should not happen"<<endl; }//return NULL;}
| ^
mpicxx -c -D_TIME SMatrix1.cc
mpicxx -D_TIME -o ctqmc ctqmc.o SMatrix1.o
/usr/bin/ld: ctqmc.o: warning: relocation against `gsl_multiroot_fsolver_hybrids' in read-only section `.text._ZN8FindRootC2EmPFiPK10gsl_vectorPvP
S0_EPdS3_[_ZN8FindRootC5EmPFiPK10gsl_vectorPvPS0_EPdS3_]'
/usr/bin/ld: ctqmc.o: in function `tanmesh_f(gsl_vector const*, void*, gsl_vector*)':
ctqmc.cc:(.text+0x3ed3): undefined reference to `gsl_vector_get'
/usr/bin/ld: ctqmc.cc:(.text+0x3eed): undefined reference to `gsl_vector_get'
/usr/bin/ld: ctqmc.cc:(.text+0x3f31): undefined reference to `gsl_vector_set'
/usr/bin/ld: ctqmc.cc:(.text+0x3fa2): undefined reference to `gsl_vector_set'
/usr/bin/ld: ctqmc.o: in function `xptsv_(int const*, int const*, double*, double*, double*, int const*, int*)':
ctqmc.cc:(.text._Z6xptsv_PKiS0_PdS1_S1_S0_Pi[_Z6xptsv_PKiS0_PdS1_S1_S0_Pi]+0x4d): undefined reference to `dptsv_'
/usr/bin/ld: ctqmc.o: in function `xptsv_(int const*, int const*, double*, dcomplex*, dcomplex*, int const*, int*)':
ctqmc.cc:(.text._Z6xptsv_PKiS0_PdP8dcomplexS3_S0_Pi[_Z6xptsv_PKiS0_PdP8dcomplexS3_S0_Pi]+0x4d): undefined reference to `zptsv_'
/usr/bin/ld: ctqmc.o: in function `xgemm(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::bas
ic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, int, int, double, double const*, int, double const*, int, double, doub
le*, int)':
ctqmc.cc:(.text._Z5xgemmRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_iiidPKdiS8_idPdi[_Z5xgemmRKNSt7__cxx1112basic_stringIcSt11char_tr
aitsIcESaIcEEES6_iiidPKdiS8_idPdi]+0x8c): undefined reference to `dgemm_'
/usr/bin/ld: ctqmc.o: in function `xgemm(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::bas
ic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, int, int, dcomplex const&, dcomplex const*, int, dcomplex const*, int,
dcomplex const&, dcomplex*, int)':
ctqmc.cc:(.text._Z5xgemmRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_iiiRK8dcomplexPS8_iSA_iS9_PS7_i[_Z5xgemmRKNSt7__cxx1112basic_stri
ngIcSt11char_traitsIcESaIcEEES6_iiiRK8dcomplexPS8_iSA_iS9_PS7_i]+0x80): undefined reference to `zgemm_'
/usr/bin/ld: ctqmc.o: in function `xgetrf(int, double*, int, int*)':
ctqmc.cc:(.text._Z6xgetrfiPdiPi[_Z6xgetrfiPdiPi]+0x52): undefined reference to `dgetrf_'
/usr/bin/ld: ctqmc.o: in function `xgetrf(int, dcomplex*, int, int*)':
ctqmc.cc:(.text._Z6xgetrfiP8dcomplexiPi[_Z6xgetrfiP8dcomplexiPi]+0x52): undefined reference to `zgetrf_'
/usr/bin/ld: ctqmc.o: in function `xgetrs(int, int, double*, int, int*, double*, int)':
ctqmc.cc:(.text._Z6xgetrsiiPdiPiS_i[_Z6xgetrsiiPdiPiS_i]+0x70): undefined reference to `dgetrs_'
/usr/bin/ld: ctqmc.o: in function `xgetrs(int, int, dcomplex*, int, int*, dcomplex*, int)':
ctqmc.cc:(.text._Z6xgetrsiiP8dcomplexiPiS0_i[_Z6xgetrsiiP8dcomplexiPiS0_i]+0x70): undefined reference to `zgetrs_'
/usr/bin/ld: ctqmc.o: in function `xsyev(int, double*, int, double*, double*, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::a
llocator<char> >)':
ctqmc.cc:(.text._Z5xsyeviPdiS_S_iNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_Z5xsyeviPdiS_S_iNSt7__cxx1112basic_stringIcSt11char_traitsI
cESaIcEEE]+0x87): undefined reference to `dsyev_'
/usr/bin/ld: ctqmc.o: in function `xgesdd(bool, int, int, double*, int, double*, double*, int, double*, int, double*, int, double*, int*)':
ctqmc.cc:(.text._Z6xgesddbiiPdiS_S_iS_iS_iS_Pi[_Z6xgesddbiiPdiS_S_iS_iS_iS_Pi]+0xfc): undefined reference to `dgesdd_'
/usr/bin/ld: ctqmc.o: in function `xgemv(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, int, double,
double const*, int, double const*, double, double*)':
ctqmc.cc:(.text._Z5xgemvRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiidPKdiS8_dPd[_Z5xgemvRKNSt7__cxx1112basic_stringIcSt11char_traitsIc
ESaIcEEEiidPKdiS8_dPd]+0x12e): undefined reference to `dgemv_'
/usr/bin/ld: ctqmc.o: in function `dger(double*, double, functionb<double> const&, functionb<double> const&)':
ctqmc.cc:(.text._Z4dgerPddRK9functionbIdES3_[_Z4dgerPddRK9functionbIdES3_]+0xa1): undefined reference to `dger_'
/usr/bin/ld: ctqmc.o: in function `RanGSL::RanGSL(int)':
ctqmc.cc:(.text._ZN6RanGSLC2Ei[_ZN6RanGSLC5Ei]+0x14): undefined reference to `gsl_rng_env_setup'
/usr/bin/ld: ctqmc.cc:(.text._ZN6RanGSLC2Ei[_ZN6RanGSLC5Ei]+0x1b): undefined reference to `gsl_rng_ranlux389'
/usr/bin/ld: ctqmc.cc:(.text._ZN6RanGSLC2Ei[_ZN6RanGSLC5Ei]+0x31): undefined reference to `gsl_rng_alloc'
/usr/bin/ld: ctqmc.cc:(.text._ZN6RanGSLC2Ei[_ZN6RanGSLC5Ei]+0x52): undefined reference to `gsl_rng_set'
/usr/bin/ld: ctqmc.o: in function `RanGSL::operator()()':
ctqmc.cc:(.text._ZN6RanGSLclEv[_ZN6RanGSLclEv]+0x1c): undefined reference to `gsl_rng_uniform'
/usr/bin/ld: ctqmc.o: in function `RanGSL::~RanGSL()':
ctqmc.cc:(.text._ZN6RanGSLD2Ev[_ZN6RanGSLD5Ev]+0x1c): undefined reference to `gsl_rng_free'
/usr/bin/ld: ctqmc.o: in function `FindRoot::FindRoot(unsigned long, int (*)(gsl_vector const*, void*, gsl_vector*), double*, void*)':
ctqmc.cc:(.text._ZN8FindRootC2EmPFiPK10gsl_vectorPvPS0_EPdS3_[_ZN8FindRootC5EmPFiPK10gsl_vectorPvPS0_EPdS3_]+0x44): undefined reference to `gsl_ve
ctor_alloc'
/usr/bin/ld: ctqmc.cc:(.text._ZN8FindRootC2EmPFiPK10gsl_vectorPvPS0_EPdS3_[_ZN8FindRootC5EmPFiPK10gsl_vectorPvPS0_EPdS3_]+0xb6): undefined referen
ce to `gsl_vector_set'
/usr/bin/ld: ctqmc.cc:(.text._ZN8FindRootC2EmPFiPK10gsl_vectorPvPS0_EPdS3_[_ZN8FindRootC5EmPFiPK10gsl_vectorPvPS0_EPdS3_]+0xd4): undefined referen
ce to `gsl_multiroot_fsolver_hybrids'
/usr/bin/ld: ctqmc.cc:(.text._ZN8FindRootC2EmPFiPK10gsl_vectorPvPS0_EPdS3_[_ZN8FindRootC5EmPFiPK10gsl_vectorPvPS0_EPdS3_]+0xef): undefined referen
ce to `gsl_multiroot_fsolver_alloc'
/usr/bin/ld: ctqmc.cc:(.text._ZN8FindRootC2EmPFiPK10gsl_vectorPvPS0_EPdS3_[_ZN8FindRootC5EmPFiPK10gsl_vectorPvPS0_EPdS3_]+0x11a): undefined refere
nce to `gsl_multiroot_fsolver_set'
/usr/bin/ld: ctqmc.o: in function `FindRoot::call()':
ctqmc.cc:(.text._ZN8FindRoot4callEv[_ZN8FindRoot4callEv]+0x3d): undefined reference to `gsl_multiroot_fsolver_iterate'
/usr/bin/ld: ctqmc.cc:(.text._ZN8FindRoot4callEv[_ZN8FindRoot4callEv]+0x66): undefined reference to `gsl_multiroot_test_residual'
/usr/bin/ld: ctqmc.cc:(.text._ZN8FindRoot4callEv[_ZN8FindRoot4callEv]+0xd5): undefined reference to `gsl_vector_get'
/usr/bin/ld: ctqmc.o: in function `FindRoot::~FindRoot()':
ctqmc.cc:(.text._ZN8FindRootD2Ev[_ZN8FindRootD5Ev]+0x1c): undefined reference to `gsl_multiroot_fsolver_free'
/usr/bin/ld: ctqmc.cc:(.text._ZN8FindRootD2Ev[_ZN8FindRootD5Ev]+0x2c): undefined reference to `gsl_vector_free'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
make: *** [Makefile:23: ctqmc] Error 1
I'm not an expert in using make, so I don't understand what I'm doing wrong
halp

Related

trying to compile static libmysqlcppconn8-static.a on Ubuntu 18.04.6 LTS

After looking ant trying all links on the web i just can't figure what is wrong.
g++ version :
g++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
This is my compilation line :
/usr/bin/g++ -fdiagnostics-color=always -Wall -std=c++11 -DSTATIC_CONCPP -I/home/vagrant/cpp/mysql-connector-cpp/include/ -I/home/vagrant/cpp/mysql-connector-cpp/include/mysqlx/ -I/home/vagrant/cpp/mysql-connector-cpp/common/ -I/home/vagrant/cpp/boost/ -I/home/vagrant/cpp/mysql-connector-cpp/build/cdk/protocol/mysqlx/protobuf -g /home/vagrant/cpp/mysql_conn_app/main.cpp /home/vagrant/cpp/mysql-connector-cpp/build/libmysqlcppconn8-static.a -lssl -lcrypto -lpthread -lresolv -o /home/vagrant/cpp/mysql_conn_app/main.exe
This is the error:
/tmp/ccUnnhKN.o: In function `mysqlx::abi2::r0::string::traits<char>::from_str(mysqlx::abi2::r0::string&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/vagrant/cpp/mysql-connector-cpp/include/mysqlx/devapi/common.h:220: undefined reference to `mysqlx::abi2::r0::string::Impl::from_utf8(mysqlx::abi2::r0::string&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/tmp/ccUnnhKN.o: In function `mysqlx::abi2::r0::string::traits<char>::to_str[abi:cxx11](mysqlx::abi2::r0::string const&)':
/home/vagrant/cpp/mysql-connector-cpp/include/mysqlx/devapi/common.h:225: undefined reference to `mysqlx::abi2::r0::string::Impl::to_utf8[abi:cxx11](mysqlx::abi2::r0::string const&)'
/tmp/ccUnnhKN.o: In function `mysqlx::abi2::r0::SessionSettings::SessionSettings(mysqlx::abi2::r0::string const&)':
/home/vagrant/cpp/mysql-connector-cpp/include/mysqlx/devapi/settings.h:526: undefined reference to `mysqlx::abi2::r0::common::Settings_impl::set_from_uri(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/home/vagrant/cpp/mysql-connector-cpp/build/libmysqlcppconn8-static.a(libcdk_proto_mysqlx_protocol.cc.o): In function `cdk::protocol::mysqlx::log_handler_init()':
./build/cdk/protocol/mysqlx/./cdk/protocol/mysqlx/protocol.cc:131: undefined reference to `google::protobuf::SetLogHandler(void (*)(google::protobuf::LogLevel, char const*, int, std::string const&))'
/home/vagrant/cpp/mysql-connector-cpp/build/libmysqlcppconn8-static.a(libcdk_proto_mysqlx_protocol.cc.o): In function `cdk::protocol::mysqlx::Protocol_server::snd_Ok(cdk::foundation::string const&)':
./build/cdk/protocol/mysqlx/./build/cdk/protocol/mysqlx/protobuf/mysqlx.pb.h:947: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::string&&, google::protobuf::Arena*)'
/home/vagrant/cpp/mysql-connector-cpp/build/libmysqlcppconn8-static.a(libcdk_proto_mysqlx_protocol.cc.o): In function `cdk::protocol::mysqlx::Protocol_server::snd_Error(unsigned short, cdk::foundation::string
....
what is wrong here ?
also when adding "-D_GLIBCXX_USE_CXX11_ABI=0" as suggested here:
still not working
/usr/bin/g++ -fdiagnostics-color=always -Wall -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0 -DSTATIC_CONCPP -I/home/vagrant/cpp/mysql-connector-cpp/include/ -I/home/vagrant/cpp/mysql-connector-cpp/include/mysqlx/ -I/home/vagrant/cpp/mysql-connector-cpp/common/ -I/home/vagrant/cpp/boost/ -I/home/vagrant/cpp/mysql-connector-cpp/build/cdk/protocol/mysqlx/protobuf -g /home/vagrant/cpp/mysql_conn_app/main.cpp /home/vagrant/cpp/mysql-connector-cpp/build/libmysqlcppconn8-static.a -lssl -lcrypto -lpthread -lresolv -o /home/vagrant/cpp/mysql_conn_app/main.exe
gives :
/home/vagrant/cpp/mysql-connector-cpp/build/libmysqlcppconn8-static.a(libcdk_proto_mysqlx_protocol.cc.o): In function `cdk::protocol::mysqlx::log_handler_init()':
./build/cdk/protocol/mysqlx/./cdk/protocol/mysqlx/protocol.cc:131: undefined reference to `google::protobuf::SetLogHandler(void (*)(google::protobuf::LogLevel, char const*, int, std::string const&))'
/home/vagrant/cpp/mysql-connector-cpp/build/libmysqlcppconn8-static.a(libcdk_proto_mysqlx_protocol.cc.o): In function `cdk::protocol::mysqlx::Protocol_server::snd_Ok(cdk::foundation::string const&)':
./build/cdk/protocol/mysqlx/./build/cdk/protocol/mysqlx/protobuf/mysqlx.pb.h:947: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::string&&, google::protobuf::Arena*)'
/home/vagrant/cpp/mysql-connector-cpp/build/libmysqlcppconn8-static.a(libcdk_proto_mysqlx_protocol.cc.o): In function `cdk::protocol::mysqlx::Protocol_server::snd_Error(unsigned short, cdk::foundation::string const&)':
./build/cdk/protocol/mysqlx/./build/cdk/protocol/mysqlx/protobuf/mysqlx.pb.h:1146: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::string&&, google::protobuf::Arena*)'
/home/vagrant/cpp/mysql-connector-cpp/build/libmysqlcppconn8-static.a(libcdk_proto_mysqlx_protocol.cc.o): In function `cdk::protocol::mysqlx::Expr_builder_base::set_call(cdk::protocol::mysqlx::api::Db_obj const&)':
./build/cdk/protocol/mysqlx/./build/cdk/protocol/mysqlx/protobuf/mysqlx_expr.pb.h:2562: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::string&&, google::protobuf::Arena*)'
adding protobuf + -D_GLIBCXX_USE_CXX11_ABI=0 same error:
/usr/bin/g++ -fdiagnostics-color=always -Wall -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0 -DSTATIC_CONCPP -I/home/vagrant/cpp/mysql-connector-cpp/include/ -I/home/vagrant/cpp/mysql-connector-cpp/include/mysqlx/ -I/home/vagrant/cpp/mysql-connector-cpp/common/ -I/home/vagrant/cpp/boost/ -I/home/vagrant/cpp/mysql-connector-cpp/build/cdk/protocol/mysqlx/protobuf -g /home/vagrant/cpp/mysql_conn_app/main.cpp /home/vagrant/cpp/mysql-connector-cpp/build/libmysqlcppconn8-static.a /home/vagrant/cpp/mysql-connector-cpp/build/cdk/protocol/mysqlx/protobuf/protobuf-3.19.4/cmake/libprotobufd.a /home/vagrant/cpp/mysql-connector-cpp/build/cdk/protocol/mysqlx/protobuf/protobuf-3.19.4/cmake/libprotobuf-lited.a /home/vagrant/cpp/mysql-connector-cpp/build/cdk/protocol/mysqlx/protobuf/protobuf-3.19.4/cmake/libprotocd.a -lssl -lcrypto -lpthread -lresolv -o /home/vagrant/cpp/mysql_conn_app/main.exe
gives :
/home/vagrant/cpp/mysql-connector-cpp/build/libmysqlcppconn8-static.a(libcdk_proto_mysqlx_protocol.cc.o): In function `cdk::protocol::mysqlx::log_handler_init()':
./build/cdk/protocol/mysqlx/./cdk/protocol/mysqlx/protocol.cc:131: undefined reference to `google::protobuf::SetLogHandler(void (*)(google::protobuf::LogLevel, char const*, int, std::string const&))'
/home/vagrant/cpp/mysql-connector-cpp/build/libmysqlcppconn8-static.a(libcdk_proto_mysqlx_protocol.cc.o): In function `cdk::protocol::mysqlx::Protocol_server::snd_Ok(cdk::foundation::string const&)':
./build/cdk/protocol/mysqlx/./build/cdk/protocol/mysqlx/protobuf/mysqlx.pb.h:947: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::string&&, google::protobuf::Arena*)'
/home/vagrant/cpp/mysql-connector-cpp/build/libmysqlcppconn8-static.a(libcdk_proto_mysqlx_protocol.cc.o): In function `cdk::protocol::mysqlx::Protocol_server::snd_Error(unsigned short, cdk::foundation::string const&)':
./build/cdk/protocol/mysqlx/./build/cdk/protocol/mysqlx/protobuf/mysqlx.pb.h:1146: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::string&&, google::protobuf::Arena*)'
/home/vagrant/cpp/mysql-connector-cpp/build/libmysqlcppconn8-static.a(libcdk_proto_mysqlx_protocol.cc.o): In function `cdk::protocol::mysqlx::Expr_builder_base::set_call(cdk::protocol::mysqlx::api::Db_obj const&)':
./build/cdk/protocol/mysqlx/./build/cdk/protocol/mysqlx/protobuf/mysqlx_expr.pb.h:2562: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::string&&, google::protobuf::Arena*)'
./build/cdk/protocol/mysqlx/./build/cdk/protocol/mysqlx/protobuf/mysqlx_expr.pb.h:2631: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::string&&, google::protobuf::Arena*)'
/home/vagrant/cpp/mysql-connector-cpp/build/libmysqlcppconn8-static.a(libcdk_proto_mysqlx_protocol.cc.o): In function `cdk::protocol::mysqlx::Expr_builder_base::var(cdk::foundation::string const&)':
./build/cdk/protocol/mysqlx/./build/cdk/protocol/mysqlx/protobuf/mysqlx_expr.pb.h:2013: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::string&&, google::protobuf::Arena*)'
/home/vagrant/cpp/mysql-connector-cpp/build/libmysqlcppconn8-static.a(libcdk_proto_mysqlx_protocol.cc.o):./build/cdk/protocol/mysqlx/./build/cdk/protocol/mysqlx/protobuf/mysqlx_expr.pb.h:2874: more undefined references to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::string&&, google::protobuf::Arena*)' follow
/home/vagrant/cpp/mysql-connector-cpp/build/libmysqlcppconn8-static.a(libcdk_proto_mysqlx_protocol.cc.o): In function `void google::protobuf::internal::ArenaStringPtr::Set<google::protobuf::internal::ArenaStringPtr::EmptyDefault>(google::protobuf::internal::ArenaStringPtr::EmptyDefault, char const*, google::protobuf::Arena*)':
./build/cdk/protocol/mysqlx/./cdk/extra/protobuf/protobuf-3.19.4/src/google/protobuf/arenastring.h:200: undefined reference to `google::protobuf::internal::ArenaStringPtr::Set(google::protobuf::internal::ArenaStringPtr::EmptyDefault, std::string const&, google::protobuf::Arena*)'

How to fix multiple definition of main building gtest project using make on ubuntu [duplicate]

This question already has an answer here:
Linking issue with GCC 4.6.1
(1 answer)
Closed 1 year ago.
I wanted to build a gtest project on linux using just a makefile, ie not using cmake. I followed along the tutorial here:
http://www.yolinux.com/TUTORIALS/Cpp-GoogleTest.html
But getting multiple definition of main errors - see below.
I am on ubuntu v20.04
angus#angus-VirtualBox:~/Documents/code/gtest_make_only/test/src$ uname -a
Linux angus-VirtualBox 5.11.0-38-generic #42~20.04.1-Ubuntu SMP Tue Sep 28 20:41:07 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
I installed gtest like this:
git clone https://github.com/google/googletest.git
mkdir build
cd build
sudo snap install cmake --classic
cmake .. -DBUILD_GMOCK=OFF
make
sudo make install
If I now look on my system I have
/usr/local/include - with gtest directory with header files
/usr/local/lib - contains libgtest.a and libgtest_main.a
I modified the Makefile in the example to be like this:
CXX = g++
CXXFLAGS = -g -L/usr/local/lib -lgtest -lgtest_main -lpthread
INCS = -I./ -I../../src -I/usr/local/include
OBJS = ../../src/Addition.o Addition_Test.o ../../src/Multiply.o Multiply_Test.o
testAll: $(OBJS)
$(CXX) $(CXXFLAGS) $(INCS) -o testAll Main_TestAll.cpp $(OBJS)
.cpp.o:
$(CXX) $(CXXFLAGS) -c $< -o $# $(INCS)
clean:
rm testAll *.o testAll.xml
I also had to tidy up the code sample - eg where in code has Addition.h - have to change to Addition.hpp which is the filename.
The build error below. How to fix this?
I did try by removing -lgtest_main from the Makefile, but then get error:
/home/angus/Documents/code/gtest_make_only/test/src/Main_TestAll.cpp:5: undefined reference to `testing::InitGoogleTest(int*, char**)'
build error:
angus#angus-VirtualBox:~/Documents/code/gtest_make_only/test/src$ make
g++ -g -L/usr/local/lib -lgtest -lgtest_main -lpthread -c Multiply_Test.cpp -o Multiply_Test.o -I./ -I../../src -I/usr/local/include
g++ -g -L/usr/local/lib -lgtest -lgtest_main -lpthread -I./ -I../../src -I/usr/local/include -o testAll Main_TestAll.cpp ../../src/Addition.o Addition_Test.o ../../src/Multiply.o Multiply_Test.o
/usr/bin/ld: /tmp/cc4xkhF1.o: in function `RUN_ALL_TESTS()':
/home/angus/Documents/code/gtest_make_only/test/src/Main_TestAll.cpp:4: multiple definition of `main'; /usr/local/lib/libgtest_main.a(gtest_main.cc.o):gtest_main.cc:(.text+0x0): first defined here
/usr/bin/ld: /usr/local/lib/libgtest_main.a(gtest_main.cc.o): in function `main':
gtest_main.cc:(.text+0x3a): undefined reference to `testing::InitGoogleTest(int*, char**)'
/usr/bin/ld: /usr/local/lib/libgtest_main.a(gtest_main.cc.o): in function `RUN_ALL_TESTS()':
gtest_main.cc:(.text._Z13RUN_ALL_TESTSv[_Z13RUN_ALL_TESTSv]+0x9): undefined reference to `testing::UnitTest::GetInstance()'
/usr/bin/ld: gtest_main.cc:(.text._Z13RUN_ALL_TESTSv[_Z13RUN_ALL_TESTSv]+0x11): undefined reference to `testing::UnitTest::Run()'
/usr/bin/ld: /tmp/cc4xkhF1.o: in function `main':
/home/angus/Documents/code/gtest_make_only/test/src/Main_TestAll.cpp:5: undefined reference to `testing::InitGoogleTest(int*, char**)'
/usr/bin/ld: Addition_Test.o: in function `AdditionTest_twoValues_Test::TestBody()':
/home/angus/Documents/code/gtest_make_only/test/src/Addition_Test.cpp:20: undefined reference to `testing::Message::Message()'
/usr/bin/ld: /home/angus/Documents/code/gtest_make_only/test/src/Addition_Test.cpp:20: undefined reference to `testing::internal::AssertHelper::AssertHelper(testing::TestPartResult::Type, char const*, int, char const*)'
/usr/bin/ld: /home/angus/Documents/code/gtest_make_only/test/src/Addition_Test.cpp:20: undefined reference to `testing::internal::AssertHelper::operator=(testing::Message const&) const'
/usr/bin/ld: /home/angus/Documents/code/gtest_make_only/test/src/Addition_Test.cpp:20: undefined reference to `testing::internal::AssertHelper::~AssertHelper()'
/usr/bin/ld: /home/angus/Documents/code/gtest_make_only/test/src/Addition_Test.cpp:21: undefined reference to `testing::Message::Message()'
/usr/bin/ld: /home/angus/Documents/code/gtest_make_only/test/src/Addition_Test.cpp:21: undefined reference to `testing::internal::AssertHelper::AssertHelper(testing::TestPartResult::Type, char const*, int, char const*)'
/usr/bin/ld: /home/angus/Documents/code/gtest_make_only/test/src/Addition_Test.cpp:21: undefined reference to `testing::internal::AssertHelper::operator=(testing::Message const&) const'
/usr/bin/ld: /home/angus/Documents/code/gtest_make_only/test/src/Addition_Test.cpp:21: undefined reference to `testing::internal::AssertHelper::~AssertHelper()'
/usr/bin/ld: /home/angus/Documents/code/gtest_make_only/test/src/Addition_Test.cpp:20: undefined reference to `testing::internal::AssertHelper::~AssertHelper()'
/usr/bin/ld: /home/angus/Documents/code/gtest_make_only/test/src/Addition_Test.cpp:21: undefined reference to `testing::internal::AssertHelper::~AssertHelper()'
/usr/bin/ld: Addition_Test.o: in function `__static_initialization_and_destruction_0(int, int)':
/home/angus/Documents/code/gtest_make_only/test/src/Addition_Test.cpp:16: undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, testing::internal::CodeLocation, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)'
/usr/bin/ld: Addition_Test.o: in function `testing::internal::SuiteApiResolver<AdditionTest>::GetSetUpCaseOrSuite(char const*, int)':
/usr/local/include/gtest/internal/gtest-internal.h:527: undefined reference to `testing::internal::IsTrue(bool)'
/usr/bin/ld: /usr/local/include/gtest/internal/gtest-internal.h:527: undefined reference to `testing::internal::GTestLog::GTestLog(testing::internal::GTestLogSeverity, char const*, int)'
/usr/bin/ld: /usr/local/include/gtest/internal/gtest-internal.h:527: undefined reference to `testing::internal::GTestLog::~GTestLog()'
/usr/bin/ld: /usr/local/include/gtest/internal/gtest-internal.h:527: undefined reference to `testing::internal::GTestLog::~GTestLog()'
/usr/bin/ld: Addition_Test.o: in function `testing::internal::SuiteApiResolver<AdditionTest>::GetTearDownCaseOrSuite(char const*, int)':
/usr/local/include/gtest/internal/gtest-internal.h:548: undefined reference to `testing::internal::IsTrue(bool)'
/usr/bin/ld: /usr/local/include/gtest/internal/gtest-internal.h:548: undefined reference to `testing::internal::GTestLog::GTestLog(testing::internal::GTestLogSeverity, char const*, int)'
/usr/bin/ld: /usr/local/include/gtest/internal/gtest-internal.h:548: undefined reference to `testing::internal::GTestLog::~GTestLog()'
/usr/bin/ld: /usr/local/include/gtest/internal/gtest-internal.h:548: undefined reference to `testing::internal::GTestLog::~GTestLog()'
/usr/bin/ld: Addition_Test.o: in function `testing::AssertionResult testing::internal::CmpHelperEQ<int, int>(char const*, char const*, int const&, int const&)':
/usr/local/include/gtest/gtest.h:1549: undefined reference to `testing::AssertionSuccess()'
/usr/bin/ld: Addition_Test.o: in function `testing::AssertionResult testing::internal::CmpHelperEQFailure<int, int>(char const*, char const*, int const&, int const&)':
/usr/local/include/gtest/gtest.h:1532: undefined reference to `testing::internal::EqFailure(char const*, char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)'
/usr/bin/ld: Addition_Test.o: in function `AdditionTest::~AdditionTest()':
/home/angus/Documents/code/gtest_make_only/test/src/Addition_Test.cpp:5: undefined reference to `testing::Test::~Test()'
/usr/bin/ld: Addition_Test.o:(.data.rel.ro._ZTI12AdditionTest[_ZTI12AdditionTest]+0x10): undefined reference to `typeinfo for testing::Test'
/usr/bin/ld: Addition_Test.o: in function `AdditionTest::AdditionTest()':
/home/angus/Documents/code/gtest_make_only/test/src/Addition_Test.cpp:5: undefined reference to `testing::Test::Test()'
/usr/bin/ld: Multiply_Test.o: in function `MultiplyTest_twoValues_Test::TestBody()':
/home/angus/Documents/code/gtest_make_only/test/src/Multiply_Test.cpp:18: undefined reference to `testing::Message::Message()'
/usr/bin/ld: /home/angus/Documents/code/gtest_make_only/test/src/Multiply_Test.cpp:18: undefined reference to `testing::internal::AssertHelper::AssertHelper(testing::TestPartResult::Type, char const*, int, char const*)'
/usr/bin/ld: /home/angus/Documents/code/gtest_make_only/test/src/Multiply_Test.cpp:18: undefined reference to `testing::internal::AssertHelper::operator=(testing::Message const&) const'
/usr/bin/ld: /home/angus/Documents/code/gtest_make_only/test/src/Multiply_Test.cpp:18: undefined reference to `testing::internal::AssertHelper::~AssertHelper()'
/usr/bin/ld: /home/angus/Documents/code/gtest_make_only/test/src/Multiply_Test.cpp:19: undefined reference to `testing::Message::Message()'
/usr/bin/ld: /home/angus/Documents/code/gtest_make_only/test/src/Multiply_Test.cpp:19: undefined reference to `testing::internal::AssertHelper::AssertHelper(testing::TestPartResult::Type, char const*, int, char const*)'
/usr/bin/ld: /home/angus/Documents/code/gtest_make_only/test/src/Multiply_Test.cpp:19: undefined reference to `testing::internal::AssertHelper::operator=(testing::Message const&) const'
/usr/bin/ld: /home/angus/Documents/code/gtest_make_only/test/src/Multiply_Test.cpp:19: undefined reference to `testing::internal::AssertHelper::~AssertHelper()'
/usr/bin/ld: /home/angus/Documents/code/gtest_make_only/test/src/Multiply_Test.cpp:18: undefined reference to `testing::internal::AssertHelper::~AssertHelper()'
/usr/bin/ld: /home/angus/Documents/code/gtest_make_only/test/src/Multiply_Test.cpp:19: undefined reference to `testing::internal::AssertHelper::~AssertHelper()'
/usr/bin/ld: Multiply_Test.o: in function `__static_initialization_and_destruction_0(int, int)':
/home/angus/Documents/code/gtest_make_only/test/src/Multiply_Test.cpp:14: undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, testing::internal::CodeLocation, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)'
/usr/bin/ld: Multiply_Test.o: in function `testing::internal::SuiteApiResolver<MultiplyTest>::GetSetUpCaseOrSuite(char const*, int)':
/usr/local/include/gtest/internal/gtest-internal.h:527: undefined reference to `testing::internal::IsTrue(bool)'
/usr/bin/ld: /usr/local/include/gtest/internal/gtest-internal.h:527: undefined reference to `testing::internal::GTestLog::GTestLog(testing::internal::GTestLogSeverity, char const*, int)'
/usr/bin/ld: /usr/local/include/gtest/internal/gtest-internal.h:527: undefined reference to `testing::internal::GTestLog::~GTestLog()'
/usr/bin/ld: /usr/local/include/gtest/internal/gtest-internal.h:527: undefined reference to `testing::internal::GTestLog::~GTestLog()'
/usr/bin/ld: Multiply_Test.o: in function `testing::internal::SuiteApiResolver<MultiplyTest>::GetTearDownCaseOrSuite(char const*, int)':
/usr/local/include/gtest/internal/gtest-internal.h:548: undefined reference to `testing::internal::IsTrue(bool)'
/usr/bin/ld: /usr/local/include/gtest/internal/gtest-internal.h:548: undefined reference to `testing::internal::GTestLog::GTestLog(testing::internal::GTestLogSeverity, char const*, int)'
/usr/bin/ld: /usr/local/include/gtest/internal/gtest-internal.h:548: undefined reference to `testing::internal::GTestLog::~GTestLog()'
/usr/bin/ld: /usr/local/include/gtest/internal/gtest-internal.h:548: undefined reference to `testing::internal::GTestLog::~GTestLog()'
/usr/bin/ld: Multiply_Test.o: in function `MultiplyTest::~MultiplyTest()':
/home/angus/Documents/code/gtest_make_only/test/src/Multiply_Test.cpp:5: undefined reference to `testing::Test::~Test()'
/usr/bin/ld: Multiply_Test.o:(.data.rel.ro._ZTI12MultiplyTest[_ZTI12MultiplyTest]+0x10): undefined reference to `typeinfo for testing::Test'
/usr/bin/ld: Multiply_Test.o: in function `MultiplyTest::MultiplyTest()':
/home/angus/Documents/code/gtest_make_only/test/src/Multiply_Test.cpp:5: undefined reference to `testing::Test::Test()'
collect2: error: ld returned 1 exit status
make: *** [Makefile:7: testAll] Error 1
Your command lines are all wrong.
Library specification should follow sources and object files. Correct line should look like this:
g++ -g -I./ -I../../src -o testAll Main_TestAll.cpp ../../src/Addition.o Addition_Test.o ../../src/Multiply.o Multiply_Test.o -lgtest_main -lgtest -lpthread
See this blog post for explanation.

Error when linking with libmongoclient in c++

When I start compiling the code with clang, it seems like libmongoclient doesn't exist. However, I compile the legacy version of mongo-cxx-client on this ubuntu machine. This code is working correctly on my Mac.
clang -lstdc++ -stdlib=libc++ -lcurl -lpthread -ljsoncpp -lboost_system -lboost_regex -lmongoclient -L/usr/lib main.o qqlogin.o fetcher.o -o qq_crawler
this is the code for linking. It didn't make any difference with or without the parameter -lmongoclient. I have already make sure it is under the correct path and the compile are able to search it.
main.o: In function `main':
main.cpp:(.text+0x3b): undefined reference to `mongo::client::Options::Options()'
main.cpp:(.text+0x4b): undefined reference to `mongo::client::GlobalInstance::GlobalInstance(mongo::client::Options const&)'
main.cpp:(.text+0x2d4): undefined reference to `mongo::client::GlobalInstance::~GlobalInstance()'
main.cpp:(.text+0x310): undefined reference to `mongo::client::GlobalInstance::~GlobalInstance()'
main.o: In function `thread_main(threadtool::Threadsafe_queue<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >*)':
main.cpp:(.text+0x343): undefined reference to `mongo::DBClientConnection::DBClientConnection(bool, mongo::DBClientReplicaSet*, double)'
main.o: In function `GCC_except_table14':
main.cpp:(.gcc_except_table+0x258): undefined reference to `typeinfo for mongo::DBException'
main.o: In function `mongo::DBClientConnection::connect(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)':
main.cpp:(.text._ZN5mongo18DBClientConnection7connectERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE[_ZN5mongo18DBClientConnection7connectERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE]+0x116): undefined reference to `mongo::HostAndPort::HostAndPort(mongo::StringData const&)'
main.o: In function `mongo::DBClientConnection::~DBClientConnection()':
main.cpp:(.text._ZN5mongo18DBClientConnectionD2Ev[_ZN5mongo18DBClientConnectionD2Ev]+0x12): undefined reference to `vtable for mongo::DBClientConnection'
main.cpp:(.text._ZN5mongo18DBClientConnectionD2Ev[_ZN5mongo18DBClientConnectionD2Ev]+0x1d): undefined reference to `vtable for mongo::DBClientConnection'
main.cpp:(.text._ZN5mongo18DBClientConnectionD2Ev[_ZN5mongo18DBClientConnectionD2Ev]+0x22): undefined reference to `mongo::DBClientConnection::_numConnections'
main.cpp:(.text._ZN5mongo18DBClientConnectionD2Ev[_ZN5mongo18DBClientConnectionD2Ev]+0xc4): undefined reference to `mongo::DBClientBase::~DBClientBase()'
main.cpp:(.text._ZN5mongo18DBClientConnectionD2Ev[_ZN5mongo18DBClientConnectionD2Ev]+0x15d): undefined reference to `mongo::DBClientBase::~DBClientBase()'
main.o: In function `mongo::DBException::~DBException()':
main.cpp:(.text._ZN5mongo11DBExceptionD2Ev[_ZN5mongo11DBExceptionD2Ev]+0xc): undefined reference to `vtable for mongo::DBException'
main.o: In function `mongo::UserException::UserException(int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)':
main.cpp:(.text._ZN5mongo13UserExceptionC2EiRKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE[_ZN5mongo13UserExceptionC2EiRKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE]+0x30): undefined reference to `vtable for mongo::UserException'
main.o: In function `mongo::DBException::addContext(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)':
main.cpp:(.text._ZN5mongo11DBException10addContextERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE[_ZN5mongo11DBException10addContextERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE]+0x51): undefined reference to `mongo::causedBy(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)'
main.o: In function `mongo::DBException::DBException(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int)':
main.cpp:(.text._ZN5mongo11DBExceptionC2ERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEi[_ZN5mongo11DBExceptionC2ERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEi]+0xf): undefined reference to `vtable for mongo::DBException'
main.o:(.rodata._ZTIN5mongo16ConnectExceptionE[_ZTIN5mongo16ConnectExceptionE]+0x10): undefined reference to `typeinfo for mongo::UserException'
main.o:(.rodata._ZTVN5mongo16ConnectExceptionE[_ZTVN5mongo16ConnectExceptionE]+0x30): undefined reference to `mongo::UserException::appendPrefix(std::__1::basic_stringstream<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) const'
main.o:(.rodata._ZTVN5mongo16ConnectExceptionE[_ZTVN5mongo16ConnectExceptionE]+0x40): undefined reference to `mongo::DBException::toString() const'
main.o:(.rodata._ZTVN5mongo18AssertionExceptionE[_ZTVN5mongo18AssertionExceptionE]+0x40): undefined reference to `mongo::DBException::toString() const'
main.o:(.rodata._ZTIN5mongo18AssertionExceptionE[_ZTIN5mongo18AssertionExceptionE]+0x10): undefined reference to `typeinfo for mongo::DBException'
fetcher.o: In function `fetch::Fetcher::parsed_json(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&)':
fetcher.cpp:(.text+0x1e8c): undefined reference to `Json::Reader::parse(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, Json::Value&, bool)'
fetcher.o: In function `mongo::BSONObjBuilder::BSONObjBuilder(int)':
fetcher.cpp:(.text._ZN5mongo14BSONObjBuilderC2Ei[_ZN5mongo14BSONObjBuilderC2Ei]+0x4e): undefined reference to `mongo::BSONObjBuilderValueStream::BSONObjBuilderValueStream(mongo::BSONObjBuilder*)'
fetcher.o: In function `mongo::BSONObjBuilder::append(mongo::StringData const&, mongo::Date_t)':
fetcher.cpp:(.text._ZN5mongo14BSONObjBuilder6appendERKNS_10StringDataENS_6Date_tE[_ZN5mongo14BSONObjBuilder6appendERKNS_10StringDataENS_6Date_tE]+0x29): undefined reference to `mongo::BSONObjBuilder::appendDate(mongo::StringData const&, mongo::Date_t)'
fetcher.o: In function `mongo::BSONObjBuilder::obj()':
fetcher.cpp:(.text._ZN5mongo14BSONObjBuilder3objEv[_ZN5mongo14BSONObjBuilder3objEv]+0x4c): undefined reference to `mongo::msgasserted(int, char const*)'
fetcher.o: In function `mongo::BSONObjBuilder::_done()':
fetcher.cpp:(.text._ZN5mongo14BSONObjBuilder5_doneEv[_ZN5mongo14BSONObjBuilder5_doneEv]+0x62): undefined reference to `mongo::BSONObjBuilderValueStream::endField(mongo::StringData const&)'
fetcher.o: In function `mongo::_BufBuilder<mongo::TrivialAllocator>::claimReservedBytes(int)':
fetcher.cpp:(.text._ZN5mongo11_BufBuilderINS_16TrivialAllocatorEE18claimReservedBytesEi[_ZN5mongo11_BufBuilderINS_16TrivialAllocatorEE18claimReservedBytesEi]+0x52): undefined reference to `mongo::invariantFailed(char const*, char const*, unsigned int)'
fetcher.o: In function `mongo::_BufBuilder<mongo::TrivialAllocator>::grow_reallocate(int)':
fetcher.cpp:(.text._ZN5mongo11_BufBuilderINS_16TrivialAllocatorEE15grow_reallocateEi[_ZN5mongo11_BufBuilderINS_16TrivialAllocatorEE15grow_reallocateEi]+0x663): undefined reference to `mongo::msgasserted(int, char const*)'
fetcher.cpp:(.text._ZN5mongo11_BufBuilderINS_16TrivialAllocatorEE15grow_reallocateEi[_ZN5mongo11_BufBuilderINS_16TrivialAllocatorEE15grow_reallocateEi]+0x6ed): undefined reference to `mongo::msgasserted(int, char const*)'
fetcher.o: In function `mongo::checkFieldName(mongo::StringData)':
fetcher.cpp:(.text._ZN5mongo14checkFieldNameENS_10StringDataE[_ZN5mongo14checkFieldNameENS_10StringDataE]+0x56): undefined reference to `mongo::uasserted(int, char const*)'
fetcher.o: In function `mongo::_BufBuilder<mongo::TrivialAllocator>::_BufBuilder(int)':
fetcher.cpp:(.text._ZN5mongo11_BufBuilderINS_16TrivialAllocatorEEC2Ei[_ZN5mongo11_BufBuilderINS_16TrivialAllocatorEEC2Ei]+0x5e): undefined reference to `mongo::msgasserted(int, char const*)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [qq_crawler] Error 1
Put your object files before the libraries:
clang -stdlib=libc++ main.o qqlogin.o fetcher.o -L/usr/lib -lcurl -lpthread
-ljsoncpp -lboost_system -lboost_regex -lmongoclient -o qq_crawler

Undefined reference to symbol 'exp##GLIBC_2.2.5' [duplicate]

This question already has answers here:
What is an undefined reference/unresolved external symbol error and how do I fix it?
(39 answers)
Closed 6 years ago.
I am trying to compile Bavieca (for a few weeks now tbh), at the same time becoming accustomed with compiling in Linux, learning about static and dynamic libraries etc, so I'm a little new to this area. Bavieca depends on the BLAS/LAPACK libraries. I am using the atlas respective libraries after unsuccessfully trying the dependent ones.
I can compile successfully the first two parts of the distribution (api & common), but compilation fails in the third (tools).
Makefile:
include ../Makefile.defines
INC = -I./algebra -I./alignment -I./audio -I./base -I./decoding -I./dynamicdecoder -I./estimation -I./config -I./hmm \
-I./io -I./other -I./param -I./text -I./transform -I./wfsadecoder ${INCS_DIR_CBLAS} ${INCS_DIR_LAPACK}
SRC_DIR = ../common
OBJ_DIR = ../../obj/$(ARCH)-$(OS)/common
LIB_DIR = ../../lib/$(ARCH)-$(OS)
OBJFILES_BASE = $(patsubst $(SRC_DIR)/%,$(OBJ_DIR)/%,$(patsubst %.cpp,%.o,$(wildcard $(SRC_DIR)/*/*.cpp)))
static: CPPFLAGS_ = $(CPPFLAGS)
pic: CPPFLAGS_ = $(CPPFLAGS_SHARED)
# targets (pic stands for position independent code)
static: createDirectories libcommon.a
pic: createDirectories libcommon_pic.a
clean:
rm -rf $(OBJ_DIR)
rm -rf $(LIB_DIR)/libcommon.a
rm -rf $(LIB_DIR)/libcommon_pic.a
createDirectories:
(mkdir -p $(LIB_DIR))
(mkdir -p $(OBJ_DIR)/algebra)
(mkdir -p $(OBJ_DIR)/alignment)
(mkdir -p $(OBJ_DIR)/audio)
(mkdir -p $(OBJ_DIR)/base)
(mkdir -p $(OBJ_DIR)/config)
(mkdir -p $(OBJ_DIR)/decoding)
(mkdir -p $(OBJ_DIR)/dynamicdecoder)
(mkdir -p $(OBJ_DIR)/estimation)
(mkdir -p $(OBJ_DIR)/hmm)
(mkdir -p $(OBJ_DIR)/io)
(mkdir -p $(OBJ_DIR)/other)
(mkdir -p $(OBJ_DIR)/param)
(mkdir -p $(OBJ_DIR)/sadmodule)
(mkdir -p $(OBJ_DIR)/text)
(mkdir -p $(OBJ_DIR)/transform)
(mkdir -p $(OBJ_DIR)/vtlestimator)
(mkdir -p $(OBJ_DIR)/wfsabuilder)
(mkdir -p $(OBJ_DIR)/wfsadecoder)
# ----------------------------------------------
# create the static library
#-----------------------------------------------
libcommon.a: $(OBJFILES_BASE)
$(AR) $# $?
(mv libcommon.a $(LIB_DIR))
rm -rf $(OBJ_DIR)
libcommon_pic.a: $(OBJFILES_BASE)
$(AR) $# $?
(mv libcommon_pic.a $(LIB_DIR))
rm -rf $(OBJ_DIR)
# ----------------------------------------------
# create the object files from the source files
# ----------------------------------------------
$(OBJ_DIR)/algebra/%.o: $(SRC_DIR)/algebra/%.cpp
$(XCC) $(CPPFLAGS_) $(INC) -c $< -o $#
$(OBJ_DIR)/alignment/%.o: $(SRC_DIR)/alignment/%.cpp
$(XCC) $(CPPFLAGS_) $(INC) -c $< -o $#
$(OBJ_DIR)/audio/%.o: $(SRC_DIR)/audio/%.cpp
$(XCC) $(CPPFLAGS_) $(INC) -c $< -o $#
$(OBJ_DIR)/base/%.o: $(SRC_DIR)/base/%.cpp
$(XCC) $(CPPFLAGS_) $(INC) -c $< -o $#
$(OBJ_DIR)/config/%.o: $(SRC_DIR)/config/%.cpp
$(XCC) $(CPPFLAGS_) $(INC) -c $< -o $#
$(OBJ_DIR)/decoding/%.o: $(SRC_DIR)/decoding/%.cpp
$(XCC) $(CPPFLAGS_) $(INC) -c $< -o $#
$(OBJ_DIR)/dynamicdecoder/%.o: $(SRC_DIR)/dynamicdecoder/%.cpp
$(XCC) $(CPPFLAGS_) $(INC) -c $< -o $#
$(OBJ_DIR)/estimation/%.o: $(SRC_DIR)/estimation/%.cpp
$(XCC) $(CPPFLAGS_) $(INC) -c $< -o $#
$(OBJ_DIR)/hmm/%.o: $(SRC_DIR)/hmm/%.cpp
$(XCC) $(CPPFLAGS_) $(INC) -c $< -o $#
$(OBJ_DIR)/io/%.o: $(SRC_DIR)/io/%.cpp
$(XCC) $(CPPFLAGS_) $(INC) -c $< -o $#
$(OBJ_DIR)/other/%.o: $(SRC_DIR)/other/%.cpp
$(XCC) $(CPPFLAGS_) $(INC) -c $< -o $#
$(OBJ_DIR)/param/%.o: $(SRC_DIR)/param/%.cpp
$(XCC) $(CPPFLAGS_) $(INC) -c $< -o $#
$(OBJ_DIR)/sadmodule/%.o: $(SRC_DIR)/sadmodule/%.cpp
$(XCC) $(CPPFLAGS_) $(INC) -c $< -o $#
$(OBJ_DIR)/text/%.o: $(SRC_DIR)/text/%.cpp
$(XCC) $(CPPFLAGS_) $(INC) -c $< -o $#
$(OBJ_DIR)/transform/%.o: $(SRC_DIR)/transform/%.cpp
$(XCC) $(CPPFLAGS_) $(INC) -c $< -o $#
$(OBJ_DIR)/vtlestimator/%.o: $(SRC_DIR)/vtlestimator/%.cpp
$(XCC) $(CPPFLAGS_) $(INC) -c $< -o $#
$(OBJ_DIR)/wfsabuilder/%.o: $(SRC_DIR)/wfsabuilder/%.cpp
$(XCC) $(CPPFLAGS_) $(INC) -c $< -o $#
$(OBJ_DIR)/wfsadecoder/%.o: $(SRC_DIR)/wfsadecoder/%.cpp
$(XCC) $(CPPFLAGS_) $(INC) -c $< -o $#
Makefile.defines:
# ---------------------------------------
# Arch and Operating System settings
# ---------------------------------------
MAKE = make --quiet -w
ARCH := $(shell uname -m | sed s/' '//g)
OS := $(shell uname -s)
# ---------------------------------------
# Linux compile options
# ---------------------------------------
XCC = gcc
# SIMD flags (vector based arithmetic operations)
#SIMD_FLAGS =
# SSE is enabled by default on gcc-4.0 and higher. If SSE is enabled, the C preprocessor symbol __SSE__ is defined
SIMD_FLAGS = -msse3
# AVX is available on Sandy Bridge and later Intel and AMD architectures. If AVX is enabled the C preprocessor symbol __AVX__ is defined
#SIMD_FLAGS = -march=corei7-avx
#CPPFLAGS = -g -Wno-deprecated -Wall -O2 -finline-functions $(SIMD_FLAGS)
CPPFLAGS = -g -Wno-deprecated -O2 -finline-functions $(SIMD_FLAGS)
# -fPIC generates Position Independent Code, which is needed to build shared libraries
# so they can be dynamically relocated, however it may slowdown the code, for this reason
# it should be avoided for object files that build executables or static libraries
CPPFLAGS_SHARED = $(CPPFLAGS) -fPIC
AR = ar rs
# ---------------------------------------
# CBLAS and LAPACK includes/libraries
# ---------------------------------------
BASE = /usr
INCS_DIR_CBLAS = -I$(BASE)/include/atlas
INCS_DIR_LAPACK = -I$(BASE)/include/atlas
LIBS_DIR_CBLAS = -L$(BASE)/lib/atlas-base
LIBS_DIR_LAPACK = -L$(BASE)/lib/atlas-base/atlas
LIB_CBLAS = -lcblas -lblas -lgfortran -lf2c
LIB_LAPACK = -llapack
# ----------------------------------------------------
# Java JNI (Java Native Interface) includes/libraries
# ----------------------------------------------------
JAVA_BASE = /usr/lib/jvm/java-1.7.0-openjdk-amd64
INCS_DIR_JNI = -I$(JAVA_BASE)/include -I$(JAVA_BASE)/include/linux
The output is the following:
(mkdir -p ../../obj/x86_64-Linux/tools)
(mkdir -p ../../bin/x86_64-Linux)
gcc -g -Wno-deprecated -O2 -finline-functions -msse3 -L../../lib/x86_64-Linux/ -L/usr/lib/atlas-base -L/usr/lib/atlas-base/atlas -o ../../bin/x86_64-Linux/aligner ../../obj/x86_64-Linux/tools/mainAligner.o -lcommon -llapack -lcblas -lblas -lgfortran -lf2c
/usr/bin/ld: ../../lib/x86_64-Linux//libcommon.a(HMMStateDecoding.o): undefined reference to symbol 'exp##GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [aligner] Error 1
Now, I've googled and searched and found out that I need to append -lm to the linker phase. Which I did, resulting in multiple undefined references. This is a small sample of the output in this case:
../../lib/x86_64-Linux//libcommon.a(ConfigurationFeatures.o): In function `ParameterValue':
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/./config/ParameterManager.h:92: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)'
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/./config/ParameterManager.h:92: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)'
../../lib/x86_64-Linux//libcommon.a(ConfigurationFeatures.o): In function `std::string::_Rep::_M_dispose(std::allocator<char> const&)':
/usr/include/c++/4.8/bits/basic_string.h:240: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
/usr/include/c++/4.8/bits/basic_string.h:240: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
../../lib/x86_64-Linux//libcommon.a(ConfigurationFeatures.o): In function `std::_Rb_tree_iterator<std::pair<std::string const, std::string> >::operator++()':
/usr/include/c++/4.8/bits/stl_tree.h:189: undefined reference to `std::_Rb_tree_increment(std::_Rb_tree_node_base*)'
../../lib/x86_64-Linux//libcommon.a(ConfigurationFeatures.o): In function `_Alloc_hider':
/usr/include/c++/4.8/bits/basic_string.h:275: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
/usr/include/c++/4.8/bits/basic_string.h:275: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
../../lib/x86_64-Linux//libcommon.a(ConfigurationFeatures.o): In function `std::string::operator=(std::string const&)':
/usr/include/c++/4.8/bits/basic_string.h:547: undefined reference to `std::string::assign(std::string const&)'
/usr/include/c++/4.8/bits/basic_string.h:547: undefined reference to `std::string::assign(std::string const&)'
../../lib/x86_64-Linux//libcommon.a(ConfigurationFeatures.o): In function `std::string::_Rep::_M_dispose(std::allocator<char> const&)':
/usr/include/c++/4.8/bits/basic_string.h:240: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
/usr/include/c++/4.8/bits/basic_string.h:240: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
../../lib/x86_64-Linux//libcommon.a(ConfigurationFeatures.o): In function `__gnu_cxx::new_allocator<Bavieca::ParameterValue>::deallocate(Bavieca::ParameterValue*, unsigned long)':
/usr/include/c++/4.8/ext/new_allocator.h:110: undefined reference to `operator delete(void*)'
../../lib/x86_64-Linux//libcommon.a(ConfigurationFeatures.o): In function `std::string::_Rep::_M_dispose(std::allocator<char> const&)':
/usr/include/c++/4.8/bits/basic_string.h:249: undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)'
/usr/include/c++/4.8/bits/basic_string.h:249: undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)'
/usr/include/c++/4.8/bits/basic_string.h:249: undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)'
/usr/include/c++/4.8/bits/basic_string.h:249: undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)'
../../lib/x86_64-Linux//libcommon.a(ConfigurationFeatures.o): In function `Bavieca::ConfigurationFeatures::load()':
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/../common/param/ConfigurationFeatures.cpp:110: undefined reference to `__cxa_get_exception_ptr'
../../lib/x86_64-Linux//libcommon.a(ConfigurationFeatures.o): In function `runtime_error':
/usr/include/c++/4.8/stdexcept:112: undefined reference to `vtable for std::runtime_error'
/usr/include/c++/4.8/stdexcept:112: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)'
../../lib/x86_64-Linux//libcommon.a(ConfigurationFeatures.o): In function `Bavieca::ConfigurationFeatures::load()':
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/../common/param/ConfigurationFeatures.cpp:110: undefined reference to `__cxa_begin_catch'
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/../common/param/ConfigurationFeatures.cpp:111: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/../common/param/ConfigurationFeatures.cpp:110: undefined reference to `std::runtime_error::~runtime_error()'
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/../common/param/ConfigurationFeatures.cpp:110: undefined reference to `__cxa_end_catch'
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/../common/param/ConfigurationFeatures.cpp:110: undefined reference to `std::runtime_error::~runtime_error()'
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/../common/param/ConfigurationFeatures.cpp:110: undefined reference to `__cxa_end_catch'
../../lib/x86_64-Linux//libcommon.a(ConfigurationFeatures.o): In function `runtime_error':
/usr/include/c++/4.8/stdexcept:112: undefined reference to `std::exception::~exception()'
../../lib/x86_64-Linux//libcommon.a(ConfigurationFeatures.o): In function `Bavieca::ConfigurationFeatures::load()':
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/../common/param/ConfigurationFeatures.cpp:110: undefined reference to `std::terminate()'
../../lib/x86_64-Linux//libcommon.a(ConfigurationFeatures.o): In function `~basic_string':
/usr/include/c++/4.8/bits/basic_string.h:539: undefined reference to `std::string::_Rep::_M_dispose(std::allocator<char> const&)'
../../lib/x86_64-Linux//libcommon.a(ConfigurationFeatures.o):(.gcc_except_table+0xe4): undefined reference to `typeinfo for std::runtime_error'
../../lib/x86_64-Linux//libcommon.a(ConfigurationFeatures.o): In function `__static_initialization_and_destruction_0':
/usr/include/c++/4.8/iostream:74: undefined reference to `std::ios_base::Init::Init()'
/usr/include/c++/4.8/iostream:74: undefined reference to `std::ios_base::Init::~Init()'
../../lib/x86_64-Linux//libcommon.a(ConfigurationFeatures.o):(.eh_frame+0x13): undefined reference to `__gxx_personality_v0'
../../lib/x86_64-Linux//libcommon.a(AudioFile.o): In function `Bavieca::AudioFile::load(char const*, int*)':
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/../common/audio/AudioFile.cpp:48: undefined reference to `operator new[](unsigned long)'
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/../common/audio/AudioFile.cpp:53: undefined reference to `__cxa_get_exception_ptr'
../../lib/x86_64-Linux//libcommon.a(AudioFile.o): In function `runtime_error':
/usr/include/c++/4.8/stdexcept:112: undefined reference to `vtable for std::runtime_error'
/usr/include/c++/4.8/stdexcept:112: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&)'
../../lib/x86_64-Linux//libcommon.a(AudioFile.o): In function `Bavieca::AudioFile::load(char const*, int*)':
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/../common/audio/AudioFile.cpp:53: undefined reference to `__cxa_begin_catch'
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/../common/audio/AudioFile.cpp:54: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/../common/audio/AudioFile.cpp:54: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/../common/audio/AudioFile.cpp:53: undefined reference to `std::runtime_error::~runtime_error()'
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/../common/audio/AudioFile.cpp:53: undefined reference to `__cxa_end_catch'
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/../common/audio/AudioFile.cpp:53: undefined reference to `std::runtime_error::~runtime_error()'
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/../common/audio/AudioFile.cpp:53: undefined reference to `__cxa_end_catch'
../../lib/x86_64-Linux//libcommon.a(AudioFile.o): In function `runtime_error':
/usr/include/c++/4.8/stdexcept:112: undefined reference to `std::exception::~exception()'
../../lib/x86_64-Linux//libcommon.a(AudioFile.o): In function `Bavieca::AudioFile::load(char const*, int*)':
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/../common/audio/AudioFile.cpp:53: undefined reference to `std::terminate()'
../../lib/x86_64-Linux//libcommon.a(AudioFile.o):(.gcc_except_table+0x48): undefined reference to `typeinfo for std::runtime_error'
../../lib/x86_64-Linux//libcommon.a(AudioFile.o): In function `__static_initialization_and_destruction_0':
/usr/include/c++/4.8/iostream:74: undefined reference to `std::ios_base::Init::Init()'
/usr/include/c++/4.8/iostream:74: undefined reference to `std::ios_base::Init::~Init()'
../../lib/x86_64-Linux//libcommon.a(AudioFile.o):(.eh_frame+0x53): undefined reference to `__gxx_personality_v0'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `basic_ios':
/usr/include/c++/4.8/bits/basic_ios.h:456: undefined reference to `std::ios_base::ios_base()'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `basic_ostream':
/usr/include/c++/4.8/ostream:385: undefined reference to `VTT for std::basic_ofstream<char, std::char_traits<char> >'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `basic_ios':
/usr/include/c++/4.8/bits/basic_ios.h:456: undefined reference to `vtable for std::basic_ios<char, std::char_traits<char> >'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `basic_ostream':
/usr/include/c++/4.8/ostream:385: undefined reference to `VTT for std::basic_ofstream<char, std::char_traits<char> >'
/usr/include/c++/4.8/ostream:385: undefined reference to `std::basic_ios<char, std::char_traits<char> >::init(std::basic_streambuf<char, std::char_traits<char> >*)'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `basic_ofstream':
/usr/include/c++/4.8/fstream:625: undefined reference to `vtable for std::basic_ofstream<char, std::char_traits<char> >'
/usr/include/c++/4.8/fstream:625: undefined reference to `vtable for std::basic_ofstream<char, std::char_traits<char> >'
/usr/include/c++/4.8/fstream:625: undefined reference to `std::basic_filebuf<char, std::char_traits<char> >::basic_filebuf()'
/usr/include/c++/4.8/fstream:626: undefined reference to `std::basic_ios<char, std::char_traits<char> >::init(std::basic_streambuf<char, std::char_traits<char> >*)'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `_Alloc_hider':
/usr/include/c++/4.8/bits/basic_string.h:275: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `std::string::assign(char const*)':
/usr/include/c++/4.8/bits/basic_string.h:1131: undefined reference to `std::string::assign(char const*, unsigned long)'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `~basic_ios':
/usr/include/c++/4.8/bits/basic_ios.h:276: undefined reference to `vtable for std::basic_ios<char, std::char_traits<char> >'
/usr/include/c++/4.8/bits/basic_ios.h:276: undefined reference to `std::ios_base::~ios_base()'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `~basic_string':
/usr/include/c++/4.8/bits/basic_string.h:539: undefined reference to `std::string::_Rep::_M_dispose(std::allocator<char> const&)'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `Bavieca::FileOutput::FileOutput(char const*, bool)':
/home/spgeo/Desktop/bavieca/bavieca-code/src/common/../common/io/FileOutput.cpp:26: undefined reference to `std::basic_ofstream<char, std::char_traits<char> >::~basic_ofstream()'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `basic_ofstream':
/usr/include/c++/4.8/fstream:625: undefined reference to `std::basic_filebuf<char, std::char_traits<char> >::~basic_filebuf()'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `~basic_ostream':
/usr/include/c++/4.8/ostream:93: undefined reference to `VTT for std::basic_ofstream<char, std::char_traits<char> >'
/usr/include/c++/4.8/ostream:93: undefined reference to `VTT for std::basic_ofstream<char, std::char_traits<char> >'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `std::string::_Rep::_M_dispose(std::allocator<char> const&)':
/usr/include/c++/4.8/bits/basic_string.h:240: undefined reference to `std::string::_Rep::_S_empty_rep_storage'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `~basic_ofstream':
/usr/include/c++/4.8/fstream:674: undefined reference to `vtable for std::basic_ofstream<char, std::char_traits<char> >'
/usr/include/c++/4.8/fstream:674: undefined reference to `vtable for std::basic_ofstream<char, std::char_traits<char> >'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `~basic_filebuf':
/usr/include/c++/4.8/fstream:220: undefined reference to `vtable for std::basic_filebuf<char, std::char_traits<char> >'
/usr/include/c++/4.8/fstream:220: undefined reference to `std::basic_filebuf<char, std::char_traits<char> >::close()'
/usr/include/c++/4.8/fstream:220: undefined reference to `std::__basic_file<char>::~__basic_file()'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `~basic_streambuf':
/usr/include/c++/4.8/streambuf:198: undefined reference to `vtable for std::basic_streambuf<char, std::char_traits<char> >'
/usr/include/c++/4.8/streambuf:198: undefined reference to `std::locale::~locale()'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `~basic_ostream':
/usr/include/c++/4.8/ostream:93: undefined reference to `VTT for std::basic_ofstream<char, std::char_traits<char> >'
/usr/include/c++/4.8/ostream:93: undefined reference to `VTT for std::basic_ofstream<char, std::char_traits<char> >'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `~basic_ios':
/usr/include/c++/4.8/bits/basic_ios.h:276: undefined reference to `vtable for std::basic_ios<char, std::char_traits<char> >'
/usr/include/c++/4.8/bits/basic_ios.h:276: undefined reference to `std::ios_base::~ios_base()'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `std::string::_Rep::_M_dispose(std::allocator<char> const&)':
/usr/include/c++/4.8/bits/basic_string.h:249: undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `~basic_streambuf':
/usr/include/c++/4.8/streambuf:198: undefined reference to `vtable for std::basic_streambuf<char, std::char_traits<char> >'
/usr/include/c++/4.8/streambuf:198: undefined reference to `std::locale::~locale()'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `~basic_ostream':
/usr/include/c++/4.8/ostream:93: undefined reference to `VTT for std::basic_ofstream<char, std::char_traits<char> >'
/usr/include/c++/4.8/ostream:93: undefined reference to `VTT for std::basic_ofstream<char, std::char_traits<char> >'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `~basic_ios':
/usr/include/c++/4.8/bits/basic_ios.h:276: undefined reference to `vtable for std::basic_ios<char, std::char_traits<char> >'
/usr/include/c++/4.8/bits/basic_ios.h:276: undefined reference to `std::ios_base::~ios_base()'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `~basic_filebuf':
/usr/include/c++/4.8/fstream:220: undefined reference to `std::__basic_file<char>::~__basic_file()'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `std::basic_ofstream<char, std::char_traits<char> >::open(char const*, std::_Ios_Openmode)':
/usr/include/c++/4.8/fstream:716: undefined reference to `std::basic_filebuf<char, std::char_traits<char> >::open(char const*, std::_Ios_Openmode)'
/usr/include/c++/4.8/fstream:721: undefined reference to `std::basic_ios<char, std::char_traits<char> >::clear(std::_Ios_Iostate)'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `std::basic_filebuf<char, std::char_traits<char> >::is_open() const':
/usr/include/c++/4.8/fstream:228: undefined reference to `std::__basic_file<char>::is_open() const'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `operator<< <std::char_traits<char> >':
/usr/include/c++/4.8/ostream:535: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)'
/usr/include/c++/4.8/ostream:535: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `std::basic_ios<char, std::char_traits<char> >::setstate(std::_Ios_Iostate)':
/usr/include/c++/4.8/bits/basic_ios.h:152: undefined reference to `std::basic_ios<char, std::char_traits<char> >::clear(std::_Ios_Iostate)'
/usr/include/c++/4.8/bits/basic_ios.h:152: undefined reference to `std::basic_ios<char, std::char_traits<char> >::clear(std::_Ios_Iostate)'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `std::basic_ofstream<char, std::char_traits<char> >::close()':
/usr/include/c++/4.8/fstream:755: undefined reference to `std::basic_filebuf<char, std::char_traits<char> >::close()'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `std::basic_ios<char, std::char_traits<char> >::setstate(std::_Ios_Iostate)':
/usr/include/c++/4.8/bits/basic_ios.h:152: undefined reference to `std::basic_ios<char, std::char_traits<char> >::clear(std::_Ios_Iostate)'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o): In function `__static_initialization_and_destruction_0':
/usr/include/c++/4.8/iostream:74: undefined reference to `std::ios_base::Init::Init()'
/usr/include/c++/4.8/iostream:74: undefined reference to `std::ios_base::Init::~Init()'
../../lib/x86_64-Linux//libcommon.a(FileOutput.o):(.eh_frame+0x13): undefined reference to `__gxx_personality_v0'
collect2: error: ld returned 1 exit status
make: *** [param] Error 1
Now I am in a dead-end. I have no experience or knowledge either as to what to do next. Could it be that libm is not functioning properly? The other answers in similar questions in this site didn't apply to my case.
EDIT:
Changing in Makefile.defined the "gcc" to "g++" results in the following output error: undefined reference to cblas_sgemm(CBLAS_ORDER, CBLAS_TRANSPOSE, CBLAS_TRANSPOSE, int, int, int, float, float const*, int, float const*, int, float, float*, int) collect2: error: ld returned 1 exit status make: *** [param] Error 1
It seems unable to find the cblas library, even though I've linked both the include and lib directory.
This looks like a pretty broken makefile... You are compiling a C++ library (as it needs std::string) with a C compiler (gcc). It can't work. Try replacing gcc by g++ in Makefile.defines, and in any case report your bad experience to the developers of the library.

opencv in centos 6.5

I have installed opencv recently . I am trying to do a bit if image processing using opencv and cuda. but I am getting an error like this
nvcc -o reference_hw1 reference_main.o student_func.o compare.o reference_calc.o -arch=sm_20 -Xcompiler -Wall -Xcompiler -Wextra -m64 -L /usr/lib
reference_main.o: In function `preProcess(uchar4**, unsigned char**, uchar4**, unsigned char**, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
reference_main.cpp:(.text+0xc4): undefined reference to `cv::imread(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
reference_main.cpp:(.text+0x1b7): undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
reference_main.cpp:(.text+0x1cd): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
reference_main.cpp:(.text+0x1ea): undefined reference to `cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int)'
reference_main.o: In function `postProcess(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned char*)':
reference_main.cpp:(.text+0x45a): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
reference_main.cpp:(.text+0x4a2): undefined reference to `cv::imwrite(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)'
reference_main.o: In function `generateReferenceImage(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
reference_main.cpp:(.text+0x5b2): undefined reference to `cv::imread(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
reference_main.cpp:(.text+0x5d4): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
reference_main.cpp:(.text+0x5ee): undefined reference to `cv::imwrite(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)'
reference_main.o: In function `cv::Mat::~Mat()':
reference_main.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x39): undefined reference to `cv::fastFree(void*)'
reference_main.o: In function `cv::Mat::operator=(cv::Mat const&)':
reference_main.cpp:(.text._ZN2cv3MataSERKS0_[cv::Mat::operator=(cv::Mat const&)]+0x111): undefined reference to `cv::Mat::copySize(cv::Mat const&)'
reference_main.o: In function `cv::Mat::create(int, int, int)':
reference_main.cpp:(.text._ZN2cv3Mat6createEiii[cv::Mat::create(int, int, int)]+0x96): undefined reference to `cv::Mat::create(int, int const*, int)'
reference_main.o: In function `cv::Mat::release()':
reference_main.cpp:(.text._ZN2cv3Mat7releaseEv[cv::Mat::release()]+0x47): undefined reference to `cv::Mat::deallocate()'
compare.o: In function `compareImages(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, double, double)':
compare.cpp:(.text+0x4e): undefined reference to `cv::imread(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
compare.cpp:(.text+0x6c): undefined reference to `cv::imread(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
compare.cpp:(.text+0x8c): undefined reference to `cv::operator-(cv::Mat const&, cv::Mat const&)'
compare.cpp:(.text+0xa5): undefined reference to `cv::abs(cv::MatExpr const&)'
compare.cpp:(.text+0x15a): undefined reference to `cv::Mat::reshape(int, int) const'
compare.cpp:(.text+0x15f): undefined reference to `cv::noArray()'
compare.cpp:(.text+0x17b): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
compare.cpp:(.text+0x1a9): undefined reference to `cv::minMaxLoc(cv::_InputArray const&, double*, double*, cv::Point_<int>*, cv::Point_<int>*, cv::_InputArray const&)'
compare.cpp:(.text+0x20c): undefined reference to `cv::operator-(cv::Mat const&, cv::Scalar_<double> const&)'
compare.cpp:(.text+0x22d): undefined reference to `cv::operator*(cv::MatExpr const&, double)'
compare.cpp:(.text+0x2d2): undefined reference to `cv::Mat::reshape(int, int) const'
compare.cpp:(.text+0x33d): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
compare.cpp:(.text+0x375): undefined reference to `cv::imwrite(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)'
collect2: ld returned 1 exit status
make: *** [student] Error 1
I don't know why the error is like this. My Makefile is
NVCC= nvcc
###################################
# These are the default install #
# locations on most linux distros #
###################################
OPENCV_LIBPATH=/usr/lib
OPENCV_INCLUDEPATH=/usr/local/include
OPENCV_TROUBLE=
CUDA_INCLUDEPATH=/usr/local/cuda/include
NVCC_OPTS = -arch=sm_20 -Xcompiler -Wall -Xcompiler -Wextra -m64
GCC_OPTS = -Wall -Wextra -m64
student: reference_main.o student_func.o compare.o reference_calc.o Makefile
$(NVCC) -o reference_hw1 reference_main.o student_func.o compare.o reference_calc.o $(NVCC_OPTS) -L $(OPENCV_LIBPATH) $(OPENCV_TROUBLE)
reference_main.o: reference_main.cpp timer.h utils.h reference_calc.cpp compare.cpp reference_hw1.cpp
g++ -c reference_main.cpp $(GCC_OPTS) -I $(OPENCV_INCLUDEPATH) -I $(CUDA_INCLUDEPATH) $(OPENCV_LIBPATH) $(OPENCV_TROUBLE)
student_func.o: student_func.cu utils.h
nvcc -c student_func.cu $(NVCC_OPTS)
compare.o: compare.cpp compare.h
g++ -c compare.cpp -I $(CUDA_INCLUDEPATH) $(GCC_OPTS) -I $(OPENCV_INCLUDEPATH) $(OPENCV_LIBPATH) $(OPENCV_TROUBLE)
reference_calc.o: reference_calc.cpp reference_calc.h
g++ -c reference_calc.cpp -I $(CUDA_INCLUDEPATH) $(GCC_OPTS) -I $(OPENCV_INCLUDEPATH) $(OPENCV_LIBPATH) $(OPENCV_TROUBLE)
clean:
rm -f *.o *.png hw
In the directory of /usr/local/include
there are two folders opencv and opencv2 , so everything is fine according to the arrangements .
Now how to solve the problem ?
yesterday whole day got used in solution for this problem.
Please anybody help me.. Thanks in advance...
I tried all the methods.....