Hello everyone.
I know this is a C++ forum not MySQL forum but I need help with the C++ library for MySQL I am hoping that there will be people here who are knowledgeable about MySQL++.

My problem is that I can't get the g++ compile to link to the MySQL++ shared libraries.
I installed the latest stable release of MySQL and MySQL++, all as according to the documentation provided. MySQL++ I had to build from the source files to get it to work with my system. I am running a fedora 9 i386 server by the way.

I checked that the installation was good by making sure that the header files and shared object libraries exist and they do. /usr/include and /usr/lib accordingly

Then I wrote a small application in C++

#include <mysql++.h>

int main()
{
    Connection conn(false);
}

It does nothing other than create a Connection object without connecting to the database
This is consistent with the MySQL Api
When I try to compile this I get a linker error:
cmdline.cpp:(.text+0xa2): undefined reference to `mysqlpp::Connection::Connection(bool)'
and no matter what I do, I always get this error
I tried indicating the path to the library files with -L /usr/lib and I tried using -l /usr/lib/libmysqlpp.so.3.0.6
Nothing works. Does anyone understand where the problem is?

Are you able to compile/link the example/test files that come with the MySQL++ distribution? I have the distribution for MS-Windows, using a different compiler, and have no problems with the sample/test programs.

I had the same problem you have with your program too. But by comparing the example program Sample1 I found that you need to include two libraries -- libmysql.lib and mysqlpp_d.lib (they probably have *.so file extensions on your system) After adding that 2nd lib the program linked ok.

I had the same problem you have with your program too. But by comparing the example program Sample1 I found that you need to include two libraries -- libmysql.lib and mysqlpp_d.lib (they probably have *.so file extensions on your system) After adding that 2nd lib the program linked ok.

You're right, I was able to make it work.
I found that on my system there are library files: libmysqlpp.so libmysqlpp.so.3.0 libmysqlpp.so.3.0.6

I got a make file that basically does all the linking which linked one of those libraries and then it worked fine. Although I don't know why I couldn't link the libraries without the make file and I still don't really know how the make file did it.
Hey it works so I'll take that for now, later I might try to figure out what the makefile does

I have the same problem but Im not able to solve it. I use Automake in my project and I dont know how to specify the shared libraries (.so files) needed in the makefile.am file.

Someone can help me?

Normand Bédard (normand.bedardATgmail.com)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.