Why simple mysql++ code compiles standalone, but not in project?

后端 未结 2 996
不思量自难忘°
不思量自难忘° 2020-12-22 06:01

At first, small program:

#include 
using namespace mysqlpp;

void mainuu ()
{ Connection conn(\"mysql\", \"localhost\", \"root\", \"pwd\");}         


        
相关标签:
2条回答
  • 2020-12-22 06:44

    Those are linker errors.

    When you create your final executable, you still must provide references to all library functions, just as you did when you compiled the single translation unit.

    So, pass -lmysqlclient -lmysqlpp to g++ this time, too.

    If you are using an Integrated Development Environment, configure your project's build settings accordingly. In particular, I see that CodeLite has both "Compiler" and "Linker" build settings. It's "Linker" settings that you're after.

    For more information on the build process (i.e. compiling, linking and the difference), read a good C++ book.

    0 讨论(0)
  • 2020-12-22 06:55

    Looks like you need to edit CodeLite project settings and add these settings -lmysqlclient -lmysqlpp that you pass in command line. Fill Library Path and Libraries fields on Linker tab.

    0 讨论(0)
提交回复
热议问题