|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
From: Alex Katebi (alex.katebi
gmail.com)
Date: Sat Sep 13 2008 - 12:35:09 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hello,
I am having problems building and running the embedded server examples
from the reference manual. My host OS is "2.6.25-14.fc9.i686" (Fedora Core
9), with mysql-6.0.6-alpha. If I follow the instructions in the manual I get
lots of link errors. Then I add the missing libraries -lstdc++ and -ldl. Now
it builds but when I run, it exits with error "MySQL server has gone away".
Below is the source code, my.cnf and the compilation command used.
Any help is very much appreciated!!!
Thanks,
-Alex
=================================================================
gcc -o test1_libmysqld test1_libmysqld.c -Wall -g -ldl -lstdc++
`mysql_config --cflags --libmysqld-libs`
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include "mysql.h"
int main(void)
{
char *server_options[] = { "test_libmysqld", "--defaults-file=./my.cnf"};
char *server_groups[] = { "server", "embedded", "test1_libmysqld_SERVER",
NULL};
int num_elements = (sizeof(server_options) / sizeof(char *));
int rc;
MYSQL *mysql;
MYSQL_RES *results;
MYSQL_ROW record;
if((rc = mysql_library_init(num_elements, server_options, server_groups)))
{
printf("Error %d: Could not init library\n", rc);
exit(1);
}
if((mysql = mysql_init(NULL)) == 0)
{
printf("init failed\n");
}
if((rc = mysql_options(mysql, MYSQL_READ_DEFAULT_GROUP, "server")))
{
printf("Failed options %d\n", rc);
exit(1);
}
if((rc = mysql_options(mysql, MYSQL_OPT_USE_EMBEDDED_CONNECTION, NULL)))
{
printf("Failed options %d\n", rc);
exit(1);
}
mysql_real_connect(mysql, NULL,NULL,NULL, "database1", 0,NULL,0);
printf("real_connect: mysql %p\n", mysql);
if((rc = mysql_query(mysql, "SELECT column1, column2 FROM table1")))
{
printf("query: rc %d, %s\n", rc, mysql_error(mysql));
}
if((results = mysql_store_result(mysql)) == NULL)
printf("store_result: %s\n", mysql_error(mysql));
while((record = mysql_fetch_row(results))) {
printf("%s - %s \n", record[0], record[1]);
}
mysql_free_result(results);
mysql_close(mysql);
mysql_library_end();
return 0;
}
# my.cnf
[server]
datadir=./data
[embedded]
datadir=./data
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]