Menu

DEV C++ and Mysql api

2005-02-06
2012-09-26
  • Nobody/Anonymous

    hello world !
    i'have always this error when i compile this prog:
    //----------------------------------------------------------------------------------------------------
    In file included from C:/Dev-Cpp/include/MySQL/mysql.h:57,
    from mysqliostream.cpp:3:
    C:/Dev-Cpp/include/MySQL/mysql_com.h:116:
    error: 'SOCKET' is used as a type,
    but is not defined as a type.
    C:/Dev-Cpp/include/MySQL/mysql_com.h:180:
    error: SOCKET' was not declared in this scope C:/Dev-Cpp/include/MySQL/mysql_com.h:180: error: syntax error before,' token make.exe: *** [mysqliostream.o] Error 1
    //----------------------------------------------------------------------------------------------------
    this is my prog:

    include <iostream>

    include <MySQL/mysql.h>

    using namespace std;
    int main()
    {
    MYSQL mysql;
    mysql_init(&mysql);
    char v1;
    int v2;
    char
    v3;
    char v4;
    char
    v5;
    cout << "server"<<endl;
    cin >> v1;
    cout << "port"<<endl;
    cin >> v2;
    cout << "login"<<endl;
    cin >> v3;
    cout << "pass"<<endl;
    cin >> v4;
    cout << "base"<<endl;
    cin >> v5;

        if (!mysql_real_connect(&amp;mysql,v1,v3,v4,v5,v2,NULL,0))
        {
            cout&lt;&lt;&quot;erreur &quot;&lt;&lt; mysql_error(&amp;mysql)&lt;&lt;endl;
    
         }
        else{
            char *sql;
    
            sql= &quot;create table test_cpp(id int);&quot; ;
            if (!mysql_query(&amp;mysql,sql))
            {
                cout &lt;&lt; mysql_error(&amp;mysql)&lt;&lt;endl;
    
            }
        else    
        {
        cout &lt;&lt; &quot;hello Mysql !&quot;&lt;&lt;endl;
    
            }  
        }  
        mysql_close(&amp;mysql);
        system(&quot;pause&quot;);
        return 0;
    

    }
    can any one help me please
    thefaycal@yahoo.fr

     
    • Nobody/Anonymous

      try adding #include <windows.h> before the other includes, I think maybe even in a console app mysql needs some of the things defined by windows.

       
      • Alhassan A. Ahmed

        Thanks for the solution @Nobody/Anonymous.I included <windows.h> and the libraries error cleared, but my program now crashes when I compile and run it.Any idea how I could resolve that?

         

Log in to post a comment.