LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   gcc compilation error (https://www.linuxquestions.org/questions/programming-9/gcc-compilation-error-51055/)

Proger 03-21-2003 02:57 PM

gcc compilation error
 
gcc -I/usr/include/mysql -L/usr/lib/mysql myapp.cpp -o myapp -lm -lmysqlclient

Error:
-----------------------------------------------------------------------------------
/tmp/ccwSHrG5.o (.eh_frame +0x11) : undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
-----------------------------------------------------------------------------------

My C code:
-----------------------------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <mysql/mysql.h>

MYSQL mysql;
MYSQL_RES *res;
MYSQL_ROW row;

void exiterr(int exitcode)
{
fprintf(stderr, "%s\n", mysql_error(&mysql));
exit(exitcode);
}

int main()
{
uint i = 0;

if (!(mysql_connect(&mysql,"host","username","password")))
exiterr(1);
if (mysql_select_db(&mysql,"payroll")) exiterr(2);
if (mysql_query(&mysql,"SELECT name,rate FROM emp_master"))
exiterr(3);
if (!(res = mysql_store_result(&mysql))) exiterr(4);
while((row = mysql_fetch_row(res))) {
for (i=0 ; i < mysql_num_fields(res); i++)
printf("%s\n",row[i]);
}
if (!mysql_eof(res)) exiterr(5);
mysql_free_result(res);
mysql_close(&mysql);
}
-----------------------------------------------------------------------------------

What's wrong? Please help me... :confused:

Proger 03-22-2003 12:32 PM

problem is solved....
source file extention *.c needed (not *.cpp)


All times are GMT -5. The time now is 09:19 AM.