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

后端 未结 2 999
不思量自难忘°
不思量自难忘° 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.

提交回复
热议问题