Simpler Navigation for Servers and Operating Systems
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
Languages and Scripting
cancel
Showing results for 
Search instead for 
Did you mean: 

Connection to Mysql database from C or C++

Vinay_19
Occasional Advisor

Connection to Mysql database from C or C++

Hi,

Has anyone tried connecting to Mysql database from C or C++. I have the code I am not sure how to make it work. Compile and execute.

I am on HP-UX 11.23i ,rx2600, 64 bit machine Itanium processor.


Any help appreciated.

Thank you,
Vinay



2 REPLIES
Werner Ittner
Occasional Advisor

Re: Connection to Mysql database from C or C++

Hi,

for me MySQL would be worthless without C interface.

I didn't test it with HPUX until now, but this works fine with LINUX :


CFG=/usr/bin/mysql_config
sh -c "gcc -o Prog.r '$CFG --cflags' Prog.c '$CFG --libs'"

where Prog.c is your source code.


Unfortunatley there is no precomiler in MySQL, yet (only experimental). So you must use c-libs in your code.
But speed is very nice !!

Highlighted
Vinay_19
Occasional Advisor

Re: Connection to Mysql database from C or C++

Werner,

I get the following error with the command.

$ sh "cc -o testmy `mysql_config --cflags` testmy.c `mysql_config --libs`"

ld: Can't find library or mismatched ABI for -lmysqlclient
Fatal error.


Is there anything wrong with thge library.

Thank You,
Vinay