ºìÁªLinuxÃÅ»§
Linux°ïÖú

ubuntuϵÄc++Á¬½ÓÊý¾Ý¿â

·¢²¼Ê±¼ä:2008-10-10 00:51:00À´Ô´:ºìÁª×÷Õß:SDjeBa
µÚÒ»²½£º×¼±¸¹¤×÷
gcc,×°ÍêÖ®ºó£¬»¹Òª×°Ò»Ð©Àà¿â£¬Òª²»»á³öºÜ¶à´íÎó

sudo apt-get install g++,glibc,glibc-source,build-essential,libmysql++dev,libmysqlclient15off,libmysqlclient15-dev

ÉÏÃæÕâЩ¶«Î÷£¬ÎÒÒ²²»ÖªµÀÄÄЩÕæÕýÓÐÓ㬷´ÕýÕâЩÎÒ¶¼¸ø×°ÉÏÁË

µÚ¶þ²½£º
ʾÀý³ÌÐò£¨±ðÈ˵ģ©[code]#include
#include
#include
#include

int main(){
MYSQL *mysql;
MYSQL_RES *res;
MYSQL_ROW row;
char query[1024];
int t,r;

mysql=mysql_init(NULL);
if (!mysql_real_connect(mysql,"test","root",
"123","test",0,NULL,0))
{
printf( "Error connecting to database: %s\n",mysql_error(mysql));
}
else printf("Connected...\n");

sprintf(query,"select * from first");

t=mysql_query(mysql,query);

if (t)
{
printf("Error making query: %s\n",
mysql_error(mysql));
}
else printf("Query made...\n");
res=mysql_use_result(mysql);
for(r=0;rrow=mysql_fetch_row(res);
if(row<0) break;
for(t=0;tprintf("%s",row[t]);
printf("\n");
}
mysql_close(mysql);
return 0;
}[/code]È»ºógcc test.c -lmysqlclient

ÁíÍâ#include ÕâÀïÒ²¿ÉÄÜ»á³öÏÖÎÊÌ⣬Èç¹ûÐèÒª¿ÉÒÔ×Ô¼ºÐ޸ijɾø¶Ô·¾¶£¬ÔÙÊÔÒ»ÏÂ×Ó¡£
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 0 ÌõÆÀÂÛ