I'm trying to connect to mysql with C++ and the MySQLConnector, but I'm getting "undefined reference" errors everytime I make calls to the connector.
example:
/usr/lib/libmysqlcppconn.so: undefined reference to `mysql_stmt_execute#libmysqlclient_18'
My OS is Ubuntu 13.04 VM, I'm using Eclipse CDT and I installed the packages:
sudo apt-get mysql-client
sudo apt-get mysql-server
sudo apt-get mysql-client
sudo apt-get libmysqlclient-dev
I'm wondering that the libs (libmysqlclient,..) are in the folder /usr/lib/x86_64-linux-gnu/
and not in /user/local/mysql/lib like often found on the net. Does this make any difference?
I also downloaded the C++ Connector (binaries) from Oracle and copied the lib directory to /usr/lib and the include directory to /usr/include, but still I'm gettind the undefined reference errors.
I configured Eclipse in a way that I get this compile command:
g++ -L/usr/lib -L/usr/lib/x86_64-linux-gnu -pthread -o "Proj" ./Client.o -lmysqlcppconn -lmysqlclient -lz -lm -ldl
Any ideas?
Related
I am trying to link libgetfiles.so to main.cpp. I ran the following command:
sudo g++ main.cpp -L/ubuntu/test -lgetfiles -L/usr/local/lib/ -lboost_thread
It gives me the following error:
/ubuntu/test/libgetfiles.so: undefined reference to'boost::thread::start_thread_noexcept()'
/ubuntu/test/libgetfiles.so: undefined reference to 'boost::thread::join_noexcept()'
/ubuntu/test/libgetfiles.so: undefined reference to 'boost::system::system_category()'
/ubuntu/test/libgetfiles.so: undefined reference to 'boost::system::generic_category()'
How can I resolve them?
I have tried uninstalling and reinstalling boost libraries as well.
I have also tried the below command:
g++ main.cpp -L/ubuntu/test -lgetfiles -L/usr/local/lib/ -lboost_thread-mt
Both of them did not work for me.
If you manually build and install boost (i.e. specific version), you should check you already not have libboost-all-dev package installed inside /usr/lib. Try to rm /usr/lib/libboost* && rm -r /usr/include/boost and then build again.
I'm trying building Box2d v2.3.1 on my Ubuntu (13.10) machine. This is what I'm doing:
$ premake4 gmake
$ cd Build/gmake/
$ make
But the testbed is not building correctly. I get lots of undefined reference errors for glfw and glew symbols, like this:
obj/Debug/Testbed/Main.o: In function `main':
/home/mostafa/.adobe/box2d-2.3.1/Box2D/Build/gmake/../../Testbed/Framework/Main.cpp:458: undefined reference to `glfwCreateWindow'
I have the development packages for both glfw and glew installed. I also checked the Testbed.make makefile and, since I saw no reference to glfw, added -lglfw to the two places where LIBS variable was defined. But I still get the same error.
I managed to fix this at last, after lots of searching and tweaking. This is what I did:
Make sure you have the very latest version of premake. I had to install premake 4.4 (beta version).
Compile and install the latest version of glfw (3.0.4 at the moment) from source. The version in Ubuntu's repositories does not work.
Make sure you have glew and xorg development packages. I installed these from Ubuntu's repository: sudo apt-get install libglew-dev xorg-dev
After running premake4 gmake in Box2D directory, go to Build/gmake and edit Testbed.make. Change the line LIBS += $(LDDEPS) -lX11 -lGL -lGLU -lglut into this LIBS += $(LDDEPS) -lX11 -lGL -lGLU -lglut -lGLEW -lglfw3 -lX11 -lXxf86vm -lpthread -lXrandr -lXi.
Now run make.
I was trying to compile an application for 32 bit target on x86_64 ubuntu 12.04 machine.
I installed the required packages using
sudo apt-get install gcc-multilib g++-multilib libc6-i386 libc6-dev-i386
The first command works generating the 32 bit version. However, the second command errors out
1. g++ -m32 hello.c
2. gcc -m32 hello.c
skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
Could anyone explain to me why gcc fails to work. Am I missing some libraries?
Thanks!
I upgraded my g++ to 4.8 and g++ -m32 stopped working too. Installing g++-4.8-multilib made -m32 option work with both gcc and g++.
I think you need this package of Ubuntu:
sudo apt-get install ia32-libs
Also confirm that you are using gcc multilib with gcc -v. If not set path accordingly or re-install gcc-multilib.
I've checked similar posts and anyone solve my problem. I's very simple but I'm new with eclipse. I'm trying to make a simple example and I'm having this problem.
the make file is just this
all: hello.exe
clean:
rm Hello.o Hello.exe
hello.exe: hello.o
g++ -g -o hello.exe hello.o
hello.o:
g++ -c -g main.cpp
And I get this error "make: g++: Command not found"
Thanks for helping.
You need to install the development tools from GNU. I assume you're on windows, in which case you have two options: cygwin and mingw. The former includes g++ out of the box. I'm less familiar with mingw, but the C++ Standard library appears to, also, be available.
See these installation instructions, I'd recommend starting from step 1, if at all possible.
"sudo apt install g++" did the trick for on on Ubuntu 20 LTS.
Adding for RHEL users, installing development tools resolved the issue on rhel.
Command:
yum groupinstall 'Development Tools'
This is a very basic question, I only post because I've spent already some time into it. This is what I've done so far:
Downloaded and compiled the boost library:
sudo ./bootstrap.sh and sudo ./bjam install
This way it was installed into /usr/local/lib.
In my source code I've added only:
#include <boost/asio.hpp>
using boost::asio::ip::tcp
I compile it with:
g++ -I/usr/lib/jvm/java-6-openjdk/include -L/usr/local/lib -fPIC -lboost_system -shared -o libagent.so agent.cpp
However, ldd -d ./libagent.so gives me:
libboost_system.so.1.46.1 => not found
But there is no error thrown, when using the -lboost_system and ls /usr/local/lib gets me among other things:
libboost_system.so
libboost_system.a
What am I missing?
Did the ./bjam install tool also run the ldconfig(8) tool? ldconfig(8) needs to be run after new libraries are installed to update the caches used by ld.so(8) at program execution time.
You should compile it with:
g++ -I/usr/lib/jvm/java-6-openjdk/include -L/usr/local/lib -Wl,-rpath,/usr/local/lib -fPIC -lboost_system -shared -o libagent.so agent.cpp
This makes it look for the boost library in /usr/local/lib at runtime, the -L option only makes it look in /usr/local/lib at compile time.