Hello, good afternoon, I'm making a C++ program with CodeBlocks (20.03 - MinGW - Windows 10 x64) that connects to a MySQL database but the linker is failing me and I don't understand it...
I use libmysql.a and:
- I have it referenced in Project build options > Linker settings ("C:\Users\Pablo\Documents\C++\OrganizadorProductosPAP\libmysql.a").
- Then in Project build options > Search directories > Compiler I have the include folder of the project ("C:\Users\Pablo\Documents\C++\ OrganizerProductsPAP\include").
When building I get the following errors:
C:\Users\Pablo\Documents\C++\OrganizadorProductosPAP\main.cpp|28|undefined reference to `mysql_init'|
C:\Users\Pablo\Documents\C++\OrganizadorProductosPAP\main.cpp|29|undefined reference to `mysql_real_connect'|
@keskiverto I linked in these directory with libmysql.a, If I'm not mistaken, I had been recommended to link it with libmysqlclient.a but I didn't find that file anywhere and I think it's for Unix systems
@kigar64551 I understand what you mean but in my case I am a beginner with it and I use XAMPP instead of MySQL Server itself. Could you help me in what I tell you please? :/
Once you have installed MySQL server, the required libraries/header files for the C API will be available at:
1 2
C:\Program Files\MySQL\MySQL Server 8.0\lib
C:\Program Files\MySQL\MySQL Server 8.0\include
I already gave you a full example how to use those, if you call the compiler from the command-line. It should be straight-forward to reproduce those commands in an IDE, e.g. Code::Blocks, but I haven't tried that...
Sorry I'm busy these days, I finally installed the entire MySQL and put the MySQL Server directories in Search Directories together with the program folder and the Connector directory, it still doesn't go...
@kigar64551 I was able to link to the official MySQL libmysql.lib that I found in the MySQL directories but when starting the application I get: The application was unable to start correctly (0xc000007b) :/
Thank you very much everyone, I saw that libmysql.dll was missing in the folder and I copied it from MySQL and it just connected the database, I'm very happy, greetings!