mysql - connect remote sql (c languange) -
i cant connect remote mysql server. after running code use gcc, there undefined reference mysql
administrator@el6116-1:~$ gcc pilihan.c -o pilihan /tmp/cc4uqv0f.o: in function `main': pilihan.c:(.text+0x67): undefined reference mysql_init' pilihan.c:(.text+0xe1): undefined reference mysql_real_connect' pilihan.c:(.text+0xf6): undefined reference mysql_error' pilihan.c:(.text+0x135): undefined reference mysql_query' pilihan.c:(.text+0x145): undefined reference mysql_error' pilihan.c:(.text+0x177): undefined reference mysql_use_result' pilihan.c:(.text+0x1c2): undefined reference mysql_fetch_row' pilihan.c:(.text+0x1d9): undefined reference mysql_free_result' pilihan.c:(.text+0x1e5): undefined reference mysql_close' collect2: error: ld returned 1 exit status
and here code in c:
#include <stdio.h> #include <mysql/mysql.h> #include <stdlib.h> void dataa() { printf( "datanasabah dipilih..." ); } void datab() { printf( "adminnasabah dipilih..." ); } main() { mysql *conn; mysql_res *res; mysql_row row; char *server = "167.205.65.251"; char *user = "nasabah"; char *password = "123"; char *database = "wordpress"; conn = mysql_init(null); int input; printf("mysql client alfred saut sibarani 23214038\n"); printf( "1. data a\n" ); printf( "2. data b\n" ); printf( "3. keluar\n" ); printf( "pilih database: " ); scanf( "%d", &input ); /* connection database */ if (!mysql_real_connect(conn, server, user, password, database, 0, null, 0)) { fprintf(stderr, "%s\n", mysql_error(conn)); exit(1); } /*if input =2 send mysql query*/ if (input == 2 && mysql_query(conn, "select * datanasabah")) { fprintf(stderr, "%s\n", mysql_error(conn)); exit(1); } res = mysql_use_result(conn); /* show table output*/ printf("data nasabah:\n"); while ((row = mysql_fetch_row(res)) != null) printf("%s %s %s\n", row[0],row[1],row[2]); /* close connection */ mysql_free_result(res); mysql_close(conn); }
#include <mysql/mysql.h>
did not succeed. have make sure library in place , beeing linked.
undefined reference mysql_init' pilihan.c:(.text+0xe1)
is clear indicator linking of library mysql.h failed.
Comments
Post a Comment