i have a project in Netbeans to connect to Mysql which is in my Raspberry pi card. so the example code i found is:
#include<iostream>
#include<mysql/mysql.h>
// <editor-fold defaultstate="collapsed" desc="comment">
using namespace std; // </editor-fold>
MYSQL *connection, mysql;
MYSQL_RES *result;
MYSQL_ROW row;
int query_state;
#define HOST "myhost" //
#define USER "mysuer" //
#define PASSWD "mypwd" //
#define DB "mydb"
int main()
{
//initialize database connection
mysql_init(&mysql);
// the three zeros are: Which port to connect to, which socket to connect to
// and what client flags to use. unless you're changing the defaults you only need to put 0 here
connection = mysql_real_connect(&mysql,HOST,USER,PASSWD,DB,0,0,0);
// Report error if failed to connect to database
if (connection == NULL) {
cout << mysql_error(&mysql) << endl;
return 1;
}
//Send query to database
query_state = mysql_query(connection, "select * from settings");
// store result
result = mysql_store_result(connection);
while ( ( row = mysql_fetch_row(result)) != NULL ) {
// Print result, it prints row[column_number])
cout << row[0] << "\t" << row[1] << endl;
}
return 0;
}
when i run this code i have this error:
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory '/home/pi/NetBeansProjects/Test1'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/test1
make[2]: Entering directory '/home/pi/NetBeansProjects/Test1'
mkdir -p dist/Debug/GNU-Linux-x86
g++ -o dist/Debug/GNU-Linux-x86/test1 build/Debug/GNU-Linux-x86/Test1.o -lbcm2835 `mysql_config --cflags` `mysql_config --libs`
/usr/bin/ld: cannot find -lbcm2835
collect2: ld returned 1 exit status
nbproject/Makefile-Debug.mk:62: recipe for target 'dist/Debug/GNU-Linux-x86/test1' failed
make[2]: *** [dist/Debug/GNU-Linux-x86/test1] Error 1
make[2]: Leaving directory '/home/pi/NetBeansProjects/Test1'
nbproject/Makefile-Debug.mk:59: recipe for target '.build-conf' failed
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory '/home/pi/NetBeansProjects/Test1'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 3s)
Can you help me, thank you
GNU-Linux-x86), although if it's being built on the pi it's being built with an ARM compiler, and unless there's asm in there somewhere it will be fine.libbcm2835is actually a pi-specific library (see my answer). – goldilocks Sep 30 '15 at 18:15