C++ / mysql Connector - undefined reference to get_driver_instance - already tried the easy stuff

后端 未结 4 904
后悔当初
后悔当初 2020-12-08 10:37

Yes this question has been asked before ... I\'ve tried everything mentioned in the previous answers. My setup is really straightforward so this shouldn\'t be so hard.

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-08 11:42

    For me simply swapping the order of the last two arguments fixed this problem. I don't know why but the linker is able to find the function get_driver_instance if I specify the -lmysqlcppconn option at the end after the source file.

    g++ -Wall -o firsttry_prog -I/usr/include/mysqlcppconn -L/usr/lib/mysqlcppconn firsttry.cpp -lmysqlcppconn
    

    Also note that I took out the following options as I think they are redundant

    -I/usr/local/boost_1_53_0  -L/usr/lib/x86_64-linux-gnu -l:libmysqlclient_r.so.18
    

提交回复
热议问题