1

The actual error is a linker error. Undefined reference to get_driver_instance.

Any ideas what the problem is?

This is what I did to install.

6
  • possible duplicate of MySQL C++ Connector: undefined reference to `get_driver_instance' Commented Jul 31, 2013 at 2:27
  • Why did you tag this with c? Commented Jul 31, 2013 at 2:27
  • It is c because c++ is built on c and could potentially be a c directive I am missing. This is not a duplicate because that post (already viewed) did not solve my problem. Nor did many different Google searches. Thank you though. Commented Jul 31, 2013 at 3:09
  • why don't you post a runnable sample that demonstrates the problem Commented Jul 31, 2013 at 4:04
  • I posted my exact process in the original post...maybe you can tell me what I missed or did wrong based on that. Commented Jul 31, 2013 at 4:23

1 Answer 1

3

It's likely in a namespace.

throw in this and see what happens:

using namespace sql::mysql; 

edit: Also, did you look through the approximately 869 other times people have asked this same question on stack overflow before posting?

https://www.google.com/search?q=mysql+get_driver_instance+site:stackoverflow.com

If that isn't it, it can be a problem with c++ name mangling.

https://en.wikipedia.org/wiki/Name_mangling#Name_mangling_in_C.2B.2B

Because the name-mangling systems for such features are not standardized across compilers, few linkers can link object code that was produced by different compilers.

and I think the final answer is here:

http://www.mingw.org/wiki/MixingCompilers

another stack overflow answer saying this:

What problems can appear when using G++ compiled DLL (plugin) in VC++ compiled application?

You'll need to build the connector from source using your g++ compiler:

http://dev.mysql.com/doc/refman/5.1/en/connector-cpp-installation-source.html

Sign up to request clarification or add additional context in comments.

4 Comments

I have tried this already and the first 2 results in the provided Google search I have already looked at.
So, at this point, I'm thinking it's a c++ compilation issue. If you look in mysql_driver.cpp, it's not in an extern C section, so my understanding is if you're not using the same C++ compiler as they do, it's not going to find the same library because of how it mangles the names.
Well this I beleive. I looked around a little bit but I cannot find *.cpp files to compile. All I can find is *.h. Any idea where I can find the *.cpp files (I prefer not to use CMAKE since I have been using MinGW / G++ so far).
@LoganMurphy in the mysql connector download page drop down, select the one called "source" or something. I grabbed it and I have a bunch of cpp files. The file you're looking for is: mysql-connector-c++-1.1.3.tar.gz and there are 110 .cpp files in it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.