Hello,
first off.. i used the search function and found problems that are about the same.. only no solution is working for me..
i`m new to programming c++ and i mainly want to learn it to connect to a mysql database and show infor from the database.. so it`s just normal to start with a simple mysql.cpp script that just makes a connection to mysql and shows if it`s connected or not.. but the compiling itself is going wrong..
This is the script:
so the script seems to be fine.. no errors there.. than i try to compile it.. this is the error that i get (i`m compiling on Windows XP SP2 in the commant prompt.)Code:#include <windows.h> #include <iostream> #include "mysql.h" using namespace std; int main() { MYSQL mysql; mysql_init(&mysql); mysql_options(&mysql,MYSQL_READ_DEFAULT_GROUP,"your_prog_name"); if (!mysql_real_connect(&mysql,"host","user","passwd","database",0,NULL,0)) { fprintf(stderr, "Failed to connect to database: Error: %s\n", mysql_error(&mysql)); } else { cout << "FINALLY CONNECTED" << endl; } return 0; }
i tried to get it working with about all they say here: http://dev.mysql.com/doc/refman/5.0/...compiling.html but no luck.. and -lmysql is also one of the options i tried..Code:C:\Programming\mysql_connection>g++ mysql.cpp -o mysql.exe C:\DOCUME~1\Mark\LOCALS~1\Temp/ccW8caaa.o(.text+0x13d):mysql.cpp: undefined refe rence to `mysql_init@4' C:\DOCUME~1\Mark\LOCALS~1\Temp/ccW8caaa.o(.text+0x15e):mysql.cpp: undefined refe rence to `mysql_options@12' C:\DOCUME~1\Mark\LOCALS~1\Temp/ccW8caaa.o(.text+0x1a7):mysql.cpp: undefined refe rence to `mysql_real_connect@32' C:\DOCUME~1\Mark\LOCALS~1\Temp/ccW8caaa.o(.text+0x1bc):mysql.cpp: undefined refe rence to `mysql_error@4' collect2: ld returned 1 exit status C:\Programming\mysql_connection>
so do any of you guys know what i might do wrong?
Thanx alot.



LinkBack URL
About LinkBacks




I used to be an adventurer like you... then I took an arrow to the knee.