Visualizzazione dei risultati da 1 a 5 su 5

Discussione: c++ [mysql]

  1. #1

    c++ [mysql]

    Ciao


    è possibile collegarsi al database mysql attraverso un programma c++ programmando in ambiente windows???


    Ho cercato via internet ma trovo solo soluzioni per linux.



    Ciao

  2. #2
    Utente di HTML.it
    Registrato dal
    Mar 2006
    Messaggi
    4
    8.5 MySQL C++ APIs

    Two APIs are available in the MySQL Contrib directory (http://www.mysql.com/Downloads/Contrib/).

    8.5.1 Borland C++

    You can compile the MySQL Windows source with Borland C++ 5.02. (The Windows source includes only projects for Microsoft VC++, for Borland C++ you have to do the project files yourself.)

    One known problem with Borland C++ is that it uses a different structure alignment than VC++. This means that you will run into problems if you try to use the default libmysql.dll libraries (that was compiled with VC++) with Borland C++. You can do one of the following to avoid this problem.

    You can use the static MySQL libraries for Borland C++ that you can find on http://www.mysql.com/downloads/os-win32.html.
    Only call mysql_init() with NULL as an argument, not a pre-allocated MYSQL struct.

  3. #3
    perdonami, sono un po' stordito e mi sono avvicinato a queste api solo da pochi minuti.


    ho almeno un paio di domande:

    io vorrei programmare in visual c++; le librerie per il borland vanno bene lo stesso?


    se ti è abbastanza facile, potresti passarmi il link per per scaricare direttamente le api giuste visto che nn le ho trovate da nessuna parte???? (sì lo so, sono stordito!!)


    Ciao e sopratutto grazie!

  4. #4
    Utente di HTML.it
    Registrato dal
    Mar 2006
    Messaggi
    4
    li ce scritto che vanno bene sia su visualc++ sia su borlandc++

    tieni presente che "visualc++" e "borlandc++" NON SONO 2 LINGUAGGI
    ma 2 NOMI DI COMPILATORI (e ide) differenti!

  5. #5
    ok, credo di essere riuscito a combinare qualcosa.


    Ho scritto questo semplicissimo codice:

    #include <iostream.h>
    #include <mysql.h>


    void main(){

    MYSQL* conn;

    conn=mysql_init(NULL);

    mysql_real_connect(conn, "127.0.0.1", "","", NULL, 3306, NULL, 0);

    mysql_select_db(conn, "liceogiovio");

    mysql_query(conn, "select nick, password from chat");

    MYSQL_RES* res;

    res=mysql_store_result(conn);

    int num=mysql_num_fields(res);

    MYSQL_FIELD* fd;

    fd=mysql_fetch_fields(res);

    cout << "Sono stati selezionati i seguenti campi:" <<endl;

    for(int i=0; i<num; i++)
    cout << fd[i].name <<" "<<endl;


    MYSQL_ROW row;

    while(row=mysql_fetch_row(res))

    cout << row[0] << " | " <<row[1]<<endl;

    mysql_free_result(res);


    }


    ma mi da dei problemi in fase di linking.


    IO ho modificato il progetto attraverso il menù tool-->option

    linguetta directories e aggiungendo C:/mysql/include per gli include files e c:/mysql/lib/opt per le library files.


    Gli errori di link sono i seguenti:
    MYSQL.OBJ : error LNK2001: unresolved external symbol _mysql_free_result@4
    MYSQL.OBJ : error LNK2001: unresolved external symbol _mysql_fetch_row@4
    MYSQL.OBJ : error LNK2001: unresolved external symbol _mysql_fetch_fields@4
    MYSQL.OBJ : error LNK2001: unresolved external symbol _mysql_num_fields@4
    MYSQL.OBJ : error LNK2001: unresolved external symbol _mysql_store_result@4
    MYSQL.OBJ : error LNK2001: unresolved external symbol _mysql_query@8
    MYSQL.OBJ : error LNK2001: unresolved external symbol _mysql_select_db@8
    MYSQL.OBJ : error LNK2001: unresolved external symbol _mysql_real_connect@32
    MYSQL.OBJ : error LNK2001: unresolved external symbol _mysql_init@4
    Debug/MYSQL.exe : fatal error LNK1120: 9 unresolved externals
    Error executing link.exe.



    Dove sbaglio?

    Grazie

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.