-1

I am trying to write programs in Visual Studio for MySQL but for some reason I cannot get Visual Studio to use the connector files for MySQL , the code I have is:

    #include <my_global.h>
    #include <mysql.h>
    #include "stdafx.h"

    int main(int argc, char **argv)
    {
         printf("MySQL client version: %s\n", mysql_get_client_info());

         return 0;
    }

The errors I am getting are:

Error   C3861   'mysql_get_client_info': identifier not found   ConsoleApplication6 c:\documents\visual studio 2017\projects\consoleapplication6\consoleapplication6\consoleapplication6.cpp    7   

Error (active)  E0020   identifier "mysql_get_client_info" is undefined ConsoleApplication6 c:\Documents\Visual Studio 2017\Projects\ConsoleApplication6\ConsoleApplication6\ConsoleApplication6.cpp    7   

Error (active)  E1696   cannot open source file "my_global.h"   ConsoleApplication6 c:\Documents\Visual Studio 2017\Projects\ConsoleApplication6\ConsoleApplication6\ConsoleApplication6.cpp    1   

Error (active)  E1696   cannot open source file "mysql.h"   ConsoleApplication6 c:\Documents\Visual Studio 2017\Projects\ConsoleApplication6\ConsoleApplication6\ConsoleApplication6.cpp    2   

I believe that I am linking the proper include and library files which I got from here: https://dev.mysql.com/downloads/connector/c/

I have followed the instructions on how to connect the header and library files correctly but it is still not working, any help would be greatly appreciated.

Toby
  • 9,696
  • 16
  • 68
  • 132
JackFF
  • 31
  • 1
  • 6
  • Where did you place these header files? If you placed them in your project's folder, try `#include "mysql.h"` instead of `#include ` – cbr Jun 12 '17 at 12:31
  • I didn't place them anywhere but I linked the header files by Project -> Project Properties -> C/C++ -> General -> Additional include directories and the lib files Project -> Project Properties -> Linker -> General -> Additional library directories, also using " " instead of < > made no difference – JackFF Jun 12 '17 at 12:40
  • stdafx.h must be the first include in all cpp files. – KonstantinL Jun 12 '17 at 20:38
  • btw, the diagnostics does not look like vs-2017 one. – KonstantinL Jun 12 '17 at 20:42

1 Answers1

0

I think it has to do with the fact that the tutorial has you switch builds to Release but you may have linked directories for the Debug Build. Based on the solution proposed here, I found that simply adding the include and lib directories with the Configuration set to Release in Project Properties should fix your error.

Hope this helped!

YashTD
  • 428
  • 3
  • 10