undefined reference to `get_driver_instance - c++ mysql connector - c++

Questions asked on stackoverflow about this question,have not been able to help me, this is complete error:
/usr/bin/ld: /tmp/ccgpX9K3.o: in function `connectDB(sql::Connection*)':
/home/erasmoh/sockets_c++/src/server.cpp:128: undefined reference to `get_driver_instance'
collect2: error: ld returned 1 exit status
i have tried this commands:
sudo g++ -Wall -I/usr/include/cppconn -o server server.cpp -L/usr/lib -lmysqlcppconn
g++ -g -o0 -I/usr/local/include -I/usr/local/boost/include -c server.cpp -o server.o
g++ -g -o0 -L/usr/local/lib -L/usr/local/mysql/lib server.o -o server -lmysqlcppconn
i have tried other ways to do it, creating a shared library as well, but, i getting the same error.

Related

Specifying Google perftools to g++ for using C++ in R

I installed Google perftools (google-perftools 1.7-1ubuntu1), and add -lprofiler to PKG_LIBS in R, when compiling the C++ code.
library(RcppArmadillo)
library(Rcpp)
Sys.setenv("PKG_CXXFLAGS"="-fopenmp")
Sys.setenv("PKG_LIBS"="-fopenmp -lprofiler")
sourceCpp('my.cpp')
The output is:
/usr/bin/ld: cannot find -lprofiler
collect2: ld returned 1 exit status
make: *** [sourceCpp_17496.so] Error 1
g++ -I/usr/share/R/include -DNDEBUG -I"/usr/local/lib/R/site-library/Rcpp/include" -I"/usr/local/lib/R/site-library/RcppArmadillo/include" -fopenmp -fpic -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g -c my.cpp -o my.o g++ -shared -Wl,-Bsymbolic-functions -Wl,-z,relro -o sourceCpp_17496.so my.o -llapack -lblas -lgfortran -lm -lquadmath -fopenmp -fopenmp -lprofiler -L/usr/lib/R/lib -lR
Error in sourceCpp("my.cpp") :
Error 1 occurred building shared library.
WARNING: The tools required to build C++ code for R were not found.
Please install GNU development tools including a C++ compiler.
Even if I run g++ in bash, I get the same error
$ g++ -shared -Wl,-Bsymbolic-functions -Wl,-z,relro -o sourceCpp_17496.so my.o -llapack -lblas -lgfortran -lm -lquadmath -fopenmp -fopenmp -lprofiler -L/usr/lib/R/lib -lR
/usr/bin/ld: cannot find -lprofiler
collect2: ld returned 1 exit status
I wonder why -lprofiler doesn't specify google perfotools? How can I solve the problem? Thanks!
My g++ is g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3.
Quick ones:
Do you actually have the package libgoogle-perftools-dev installed? Ie do you have shared and static libraries /usr/lib/libprofiler.* ? This is the mother of all development FAQs: you need package libfoo to run code against foo, and package libfoo-dev to compile against foo.
I have old working examples in the slides from my 'HPC with R' talks from a few years ago; those should all work as is.

how to compile project include libcurl "undefined reference"

I'm using compile downloaded source code and try to make my c++ project but these error appear.
user1#ubuntu:~$ make
g++ -std=c++0x -g -Wall -Werror -L/home/user1/project0/libcurl/lib/libcurl.a -I/home/user1/proj/libcurl/include -c my-curl.cpp -o curl.o
g++ -std=c++0x -g -Wall -Werror -L/home/user1/project0/libcurl/lib/libcurl.a -I/home/user1/proj/libcurl/include -c main.cpp -o main.o
g++ -std=c++0x -g -Wall -Werror -L/home/user1/project0/libcurl/lib/libcurl.a -I/home/user1/proj/libcurl/include -o my-curl-app my-curl.o main.o
my-curl.o: In function `CCurlDownloader::start_download()':
~/my-curl.cpp:22: undefined reference to `curl_easy_init'
~/my-curl.cpp:27: undefined reference to `curl_easy_setopt'
~/my-curl.cpp:28: undefined reference to `curl_easy_setopt'
~/my-curl.cpp:29: undefined reference to `curl_easy_setopt'
~/my-curl.cpp:30: undefined reference to `curl_easy_perform'
~/my-curl.cpp:53: undefined reference to `curl_easy_cleanup'
collect2: ld returned 1 exit status
make: *** [my-curl-app] Error 1
and i'm changed -L option to specified directory and add -lcurl for specified lib and result is.
user1#ubuntu:~/project0/my-curl$ make
g++ -std=c++0x -g -Wall -Werror -L/home/user1/practics/libcurl/lib -lcurl -I/home/user1/practics/libcurl/include -c my-curl.cpp -o my-curl.o
g++ -std=c++0x -g -Wall -Werror -L/home/user1/practics/libcurl/lib -lcurl -I/home/user1/practics/libcurl/include -c main.cpp -o main.o
g++ -std=c++0x -g -Wall -Werror -L/home/user1/practics/libcurl/lib -lcurl -I/home/user1/practics/libcurl/include -o my-curl-cpp my-curl.o main.o
my-curl.o: In function `CCurlDownloader::start_download()':
~/my-curl.cpp:22: undefined reference to `curl_easy_init'
~/my-curl.cpp:27: undefined reference to `curl_easy_setopt'
~/my-curl.cpp:28: undefined reference to `curl_easy_setopt'
~/my-curl.cpp:29: undefined reference to `curl_easy_setopt'
~/my-curl.cpp:30: undefined reference to `curl_easy_perform'
~/my-curl.cpp:53: undefined reference to `curl_easy_cleanup'
collect2: ld returned 1 exit status
make: *** [bb-cppurl] Error 1
I and try curl-config to link libs but result still be the same.
user1#atom-linux-server:~/my-curl$ make
g++ -std=c++0x -g -Wall -Werror `/home/user1/project0/libcurl/bin/curl-config --libs` `/home/user1/project0/libcurl/bin/curl-config --cflags` -c my-curl.cpp -o my-curl.o
g++ -std=c++0x -g -Wall -Werror `/home/user1/project0/libcurl/bin/curl-config --libs` `/home/user1/project0/libcurl/bin/curl-config --cflags` -c main.cpp -o main.o
g++ -std=c++0x -g -Wall -Werror `/home/user1/project0/libcurl/bin/curl-config --libs` `/home/user1/project0/libcurl/bin/curl-config --cflags` -o my-curl-app my-curl.o main.o
my-curl.o: In function `CCurlDownloader::start_download()':
~/my-curl.cpp:22: undefined reference to `curl_easy_init'
~/my-curl.cpp:27: undefined reference to `curl_easy_setopt'
~/my-curl.cpp:28: undefined reference to `curl_easy_setopt'
~/my-curl.cpp:29: undefined reference to `curl_easy_setopt'
~/my-curl.cpp:30: undefined reference to `curl_easy_perform'
~/my-curl.cpp:53: undefined reference to `curl_easy_cleanup'
collect2: ld returned 1 exit status
make: *** [bb-cppurl] Error 1
You're using the build tools wrong.
1 - the -L option should specify a directory
2 - there's no -l (lowercase L) option to specify which lib to link with (perhaps from the directory -L identifies)
I move
-L/home/user1/practics/libcurl/lib -lcurl
to the tail of command
g++ -std=c++0x -g -Wall -Werror -I/home/user1/practics/libcurl/include -o my-curl-cpp my-curl.o main.o -L/home/user1/practics/libcurl/lib -lcurl
and it works.

compiler error when running "wmake" in project folder

when I open a terminal, switch to my project directory (which is in my home folder) and run the command "wmake" I get the error:
g++ -m32 -Dlinux -DWM_DP -Wall -Wextra -Wno-unused-parameter
-Wold-style-cast -O3 -DNoRepository -ftemplate-depth-100 -IphaseModel/lnInclude -ImultiphaseSystem/lnInclude -ImultiphaseFixedFluxPressure -IinterfacialModels/lnInclude -I/opt/openfoam221/src/transportModels -I/opt/openfoam221/src/transportModels/incompressible/lnInclude -I/opt/openfoam221/src/transportModels/interfaceProperties/lnInclude -I/opt/openfoam221/src/transportModels/incompressible/lnInclude -I/opt/openfoam221/src/transportModels/incompressible/singlePhaseTransportModel
-I/opt/openfoam221/src/turbulenceModels -I/opt/openfoam221/src/turbulenceModels/incompressible/LES/LESModel -I/opt/openfoam221/src/turbulenceModels/LES/LESdeltas/lnInclude -I/opt/openfoam221/src/finiteVolume/lnInclude -IlnInclude -I. -I/opt/openfoam221/src/OpenFOAM/lnInclude -I/opt/openfoam221/src/OSspecific/POSIX/lnInclude -fPIC -Xlinker --add-needed -Xlinker --no-as-needed Make/linuxGccDPOpt/multiphaseEulerFoam.o
-L/opt/openfoam221/platforms/linuxGccDPOpt/lib \
-lmultiphaseSystem -lcompressibleMultiPhaseModel -linterfaceProperties -lincompressibleTransportModels -lcompressibleMultiphaseEulerianInterfacialModels -lincompressibleLESModels -lincompressibleRASModels -lfiniteVolume -lOpenFOAM -ldl -lm -o /opt/openfoam221/platforms/linuxGccDPOpt/bin/multiphaseEulerFoam /usr/bin/ld: cannot open output file /opt/openfoam221/platforms/linuxGccDPOpt/bin/multiphaseEulerFoam: Permission denied collect2: ld returned 1 exit status make: * [/opt/openfoam221/platforms/linuxGccDPOpt/bin/multiphaseEulerFoam] Error 1
This error occured the first time today, yesterday everything compiled fine for me.
How can I fix this?

undefined reference to `boost::system::generic_category()' [duplicate]

This question already has an answer here:
g++ undefined reference to `boost::system::system_category()'
(1 answer)
Closed 9 years ago.
I have a problem with my code.
I have such an info trying to build:
g++ -L /usr/local/boost_1_55_0 -Wall -pedantic -Iinc -c -lboost_system -pthread -lboost_thread -o obj/glo.o src/glo.cpp
g++ -L /usr/local/boost_1_55_0 -Wall -pedantic -Iinc -c -lboost_system -pthread -lboost_thread -o obj/serial.o src/serial.cpp
g++ -I /usr/local/boost_1_55_0 -Wall -lboost_system -pthread -o dwa obj/glo.o obj/serial.o
obj/glo.o: In function `__static_initialization_and_destruction_0(int, int)':
glo.cpp:(.text+0x15a): undefined reference to `boost::system::generic_category()'
glo.cpp:(.text+0x166): undefined reference to `boost::system::generic_category()'
glo.cpp:(.text+0x172): undefined reference to `boost::system::system_category()'
obj/glo.o: In function `boost::system::error_code::error_code()':
glo.cpp:(.text._ZN5boost6system10error_codeC2Ev[_ZN5boost6system10error_codeC5Ev]+0x17): undefined reference to `boost::system::system_category()'
and similar.
As You can see I have given
-lboost_system -pthread -lboost_thread and compiled system boost in /usr/local/boost_1_55_0
I have no idea whats happening.
Absolutely, g++ cannot find library boost_system. It should locate in /usr/local/boost_1_55_0/lib. You can add option "-v" to check the detailed error messages.
g++ -v -L/usr/local/boost_1_55_0/lib -Wall -lboost_system -pthread -o dwa obj/glo.o obj/serial.o
The commands should be as following:
g++ -I/usr/local/boost_1_55_0/include -Wall -pedantic -Iinc -c -o obj/glo.o src/glo.cpp
g++ -I/usr/local/boost_1_55_0/include -Wall -pedantic -Iinc -c -o obj/serial.o src/serial.cpp
g++ -L/usr/local/boost_1_55_0/lib -Wall -lboost_system -pthread -o dwa obj/glo.o obj/serial.o

How to build Shallot on Ubuntu? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I tried to compile Shallot on Ubuntu linux (gcc ./src/shallot.c), but I've got this error:
/tmp/ccwsRxaV.o: In function `main':
shallot.c:(.text+0x3d): undefined reference to `usage'
shallot.c:(.text+0x1ea): undefined reference to `parse_cpuinfo'
shallot.c:(.text+0x2a3): undefined reference to `pattern'
shallot.c:(.text+0x2eb): undefined reference to `usage'
shallot.c:(.text+0x3ba): undefined reference to `usage'
shallot.c:(.text+0x440): undefined reference to `usage'
shallot.c:(.text+0x4de): undefined reference to `usage'
shallot.c:(.text+0x57a): undefined reference to `usage'
/tmp/ccwsRxaV.o:shallot.c:(.text+0x5f4): more undefined references to `usage' follow
/tmp/ccwsRxaV.o: In function `main':
shallot.c:(.text+0x92d): undefined reference to `worker'
shallot.c:(.text+0x941): undefined reference to `pthread_create'
shallot.c:(.text+0x984): undefined reference to `monitor_proc'
shallot.c:(.text+0x998): undefined reference to `pthread_create'
shallot.c:(.text+0x9b7): undefined reference to `worker'
shallot.c:(.text+0x9db): undefined reference to `pthread_join'
Sorry, but I'm not a programmer. I don't really know how this should work.
Well I went to the site, took down the instructions and gave it a try. Seems pretty straight forward:
First clone the source into a "shallot" directory:
git clone https://github.com/katmagic/Shallot.git Shallot
Then we run the configure:
mike#linux-4puc:~/C/Shallot> ./configure Liunx detected. Have you
considered switching to BSD? Configuration successful. This does not
mean it will build. If you are missing gcc, or required
libraries/headers, you will need to install them first.
Finally run the Makefile:
mike#linux-4puc:~/C/Shallot> make
cc -O3 -I/usr/include -I/usr/local/include -L/usr/lib -L/usr/local/lib -Wall -o src/math.o -c src/math.c
cc -O3 -I/usr/include -I/usr/local/include -L/usr/lib -L/usr/local/lib -Wall -o src/error.o -c src/error.c
cc -O3 -I/usr/include -I/usr/local/include -L/usr/lib -L/usr/local/lib -Wall -o src/linux.o -c src/linux.c
cc -O3 -I/usr/include -I/usr/local/include -L/usr/lib -L/usr/local/lib -Wall -o src/print.o -c src/print.c
cc -O3 -I/usr/include -I/usr/local/include -L/usr/lib -L/usr/local/lib -Wall -o src/thread.o -c src/thread.c
cc -O3 -I/usr/include -I/usr/local/include -L/usr/lib -L/usr/local/lib -Wall -o src/shallot.o -c src/shallot.c
cc -O3 -I/usr/include -I/usr/local/include -L/usr/lib -L/usr/local/lib -pthread src/math.o src/error.o src/linux.o src/print.o src/thread.o src/shallot.o -o shallot -lm -lpthread -lssl -lcrypto
And now the executable shallot can be seen in the directory:
mike#linux-4puc:~/C/Shallot> ls
CHANGELOG configure LICENSE Makefile README.asciidoc shallot src
So if you followed all the steps exactly like I did, I suspect the place you're having issues is the block of text I highlighted above. Do you have all the required libraries/headers for building shallot?