mysql connector "Undefined reference to 'get_driver_instance'

Apr 27, 2012 at 3:36am
I am running ubuntu 11.10 (in a virtual machine) using CodeBlocks IDE. I have added the mysql libraries however sql::get_driver_instance() is returning an error "Undefined reference to 'get_driver_instance'". None of the posts or articles I have found on google have given a clear solution to this problem.
Apr 27, 2012 at 8:22am
This means you didn't link correctly to the library. Find the corresponding cpp file and add it to your project, or find the compiled library and add it to your project.
Apr 27, 2012 at 1:13pm
I understand that it is due to improperly adding the mysql c++/connector library. However I do not know how to adjust my settings to fix this. My question is how is this done in CodeBlocks?
Last edited on Apr 27, 2012 at 1:14pm
Apr 27, 2012 at 2:23pm
First, you have to learn what "linking to a library" means. Check out some examples and understand properly what linking libraries is. Then, the task will become easier in Code::Blocks.

Code::Blocks basically is an interface to make life easier for you; it generates the makefile automatically. After you learn what linking is and how it's done, you can modify the libraries and add the required libraries to your program.

After you learn/get the idea of linking, try to apply it in Code::Blocks, and then if you fail we can help you :). We really don't have enough information right now; and I, personally, haven't worked with SQL before. But keep in mind, that undefined reference always means either that cc/cpp file missing, or unlinked library.

Good luck!
Apr 30, 2012 at 10:56pm
I've been reading up on libraries and I am kind of understand but I'm still having trouble. Here is what I have done and what I am unsure of:

in 'project->build options->search directories' I added "/usr/include/cppconn"

in 'project->build options->linker settings->Link libraries' I added "/usr/lib/libmysqlcppconn-static.a" but I'm not sure libmysqlcppconn.so or libmysqlcppconn.a

I am confused on adding flag options and if those are in fact the right things added in the right places. Your help is greatly appreciated.
May 1, 2012 at 8:48am
Well, adding libraries is the right move. Using the tutorial of the program, find the required libraries. You could, however, add all the libraries you can, and see whether the program compiles, and when it does, remove libraries 1 by 1 and see when the program compiles again.
Jun 6, 2012 at 8:36am
I have [url=http://www.electricslipring.com/]slipring[/url]
a LIRC driver somewhere in my development tree. It created a kernel module that allowed the IR sensor to be used with LIRC. Unfortunately, while I could record data using "mode2", I wasn't ever able to "train" the remote to ever work. The LIRC documentation isn't very good at all for developers who want to add drivers.
A corresponding "transmit" driver should be equally easy (or hard) to write, especially since all the GPIOs are hooked up to the Linux kernel GPIO system.
Last edited on Jun 6, 2012 at 8:37am
Jun 6, 2012 at 12:24pm
closed account (3hM2Nwbp)
If you're linking statically, you'll need to feed the preprocessor the following token:

CPPCONN_PUBLIC_FUNC
Topic archived. No new replies allowed.