MySQL Forums
Forum List  »  Connector/C++

undefined reference to `get_driver_instance'
Posted by: Ryan Hirscher
Date: June 24, 2021 09:46AM

Hi, I have compile failure for c++ embedded mysql. The program is very simple. I have included the direct paths for all of the headerfiles in include and its subdirectory cppconn.
using namespace std;
using namespace sql;
int main(){
Driver *driver;
Connection *con;
driver = get_driver_instance();
con = driver -> connect(host, username, password);
con -> setSchema(db);
con -> close(); }

The error: /tmp/cc1YxUfU.o: In function `main':
sqlTest.cpp:(.text+0xd): undefined reference to `sql::mysql::get_mysql_driver_instance()'
collect2: error: ld returned 1 exit status

I have tested a couple compile methods, but to no avail.
g++ sqlTest.cpp -o test
g++ -Wall -I/home/ryanh/mysql-connector-c++-noinstall-1.0.5-winx64/include/cppconn -o test sqlTest.cpp -L/home/ryanh/mysql-connector-c++-noinstall-1.0.5-winx64/lib

After some research some people suggested using -lmysqlcppconn, but I have no idea what that is or what it does. When I use it in the compile it says it does not exist.

A hello world compiles with the headers and runs without the use of any functions or anything.

I tried creating an object of driver class MySQL_Driver *driver and use its function get_mysql_driver_instance, but it has the same corresponding error saying it is an undefined reference.

Help would be appreciated thanks.

Options: ReplyQuote


Subject
Views
Written By
Posted
undefined reference to `get_driver_instance'
2540
June 24, 2021 09:46AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.