0

So, after whole day of trial and effort, I still couldn't figure answer to this question. I'm perfectly aware of this thread and this one but they don't quite give answer to the question.

So, the problem is when compiling program, let's say, like this one:

#include <iostream>
#include <windows.h>
#include <mysql.h>
using namespace std;
int main()
{
    MYSQL *connection, mysql;
    MYSQL_RES *result;
    MYSQL_ROW row;
    mysql_init(&mysql);
}

and I get linker error

undefined reference to `mysql_init@4'

I tried adding to input section libmesql.lib and mysqclient.lib, both simultaneously and separately. Tried copying .lib files to Visual Studio default folder, than attempted compiling it by setting path in Linker->General->Additional Library Directories. Tried #pragma comment as well - still to no avail.

So if anyone out there could explain what am I doing wrong (and possibly a way to solve this problem) it would be much appreciated.

p.s. And please, don't answer with links to MySQL documentation - I got them here.

Community
  • 1
  • 1
Monceber
  • 151
  • 2
  • 9

1 Answers1

0

Link your code with mysqlclient.lib.

Properties->Linker->General->Additional Libraries

Add the path to your library here.

TimH - Codidact
  • 1,439
  • 1
  • 12
  • 13
  • Please, read more attentively. As I stated in my question, I've tried this already, but this didn't help. – Monceber Sep 13 '12 at 07:10