mysql connection error with c. Unknown type name 'SOCKET'

Asked

Viewed 215 times

0

I have this code and is generating error.

#include <stdio.h>
#include <mysql.h>
#include <windows.h>
#include <sys\socket.h>

void main(void)
{

    //parâmetros para Conexão
    char host[100];
    char user[100];
    char pass[100];
    char db[100];
    char script[500];

    //variáveis para conexão e manipulação dos objetos do banco
    MYSQL *socket;
    MYSQL_RES *resp;
    MYSQL_FIELD *campos;
    MYSQL_ROW linhas;   
}

Erro Gerado

More information:

Compiler: Orwell Dev-C++

Operating System: Windows 8 x64

Mysql x32

  • 1

    You have to add pre-compiled lib

  • @Tony I did it and it didn’t work. Just to check, it’s there in the project parameters, in the field Linker?

1 answer

1


I managed to find the error, it is necessary to give the Socks include before mysql. In my case it’s like this:

#include <stdio.h>
#include <winsock2.h>
#include <windows.h>
#include <mysql.h>
//#include <sys\socket.h>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.