anroy Posted August 9, 2006 Share Posted August 9, 2006 [i]I wanted to take this to MySQL Freaks but they are down I was directed back here. However please be warned that this problem has nothing to do with PHP, only MySQL and C. Moderaters, please shelve it if it is too irrelevant.[/i]I set up MySQL 5.0.24 on an Ubuntu Linux machine, by downloading the source tarball.For some reason I just can't seem to get mysql_init to work, it ALWAYS returns NULL!On the MySQL site it says that this happens if there is insufficient memory. I am sure that is not the case here.Here is my code.[code]#include </usr/local/mysql/include/mysql/mysql.h>#include <stdio.h>#include <string.h>int main(){ MYSQL mysql; rc = mysql_init( &mysql ); if( rc == NULL ) { printf( "mysql_init returns NULL" ); }}[/code]I also tried the following variation, with the same NULL results.[code]#include </usr/local/mysql/include/mysql/mysql.h>#include <stdio.h>#include <string.h>int main(){ MYSQL *mysql; mysql = mysql_init( NULL ); if( mysql == NULL ) { printf( "mysql_init returns NULL" ); }}[/code]Does anybody have even the slightest clue as to why I would get NULL?I compiled and linked using the following:gcc sql_prog.c -o sql_prog -lz -lmysqlclient -L /usr/local/mysql/lib/mysql/The compile and link were successful, as the message "mysql_init returns NULL" is properly output!Also, the database server runs fine, the client programs mysqlshow, mysqladmin, etc. work fine. They were also compiled on the same machine (I installed from source).I am thinking about copying one of the client folders (like mysqlshow) in the MySQL source, modifying the code so it does what I need, and including it in the overall MySQL build as another Client.However it is very time-consuming to configure and make the entire MySQL each time. Maybe I can use this option?shell> ./configure --without-serverDoes this have any effect on the server that I am not aware of, like removing any files or settings? I just want to rebuild the clients but want to leave the server as is.Thanks,Arka N. Roy Quote Link to comment https://forums.phpfreaks.com/topic/17043-mysql-c-api-problem/ Share on other sites More sharing options...
anroy Posted August 11, 2006 Author Share Posted August 11, 2006 Sorry it turns out this was a false alarm. Please forgive me for having wasted your time.The lesson here is to check more carefully before posting to a forum. :-[ Quote Link to comment https://forums.phpfreaks.com/topic/17043-mysql-c-api-problem/#findComment-72873 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.