MySQL Lists are EOL. Please join:

List:General Discussion« Previous MessageNext Message »
From:Barry Leslie Date:September 15 2008 7:38pm
Subject:Re: embedded server examples
View as plain text  
Hi Alex,

Make sure it can find the errmsg.sys file. If it cannot it will just die.
The location is determined by the --language option.

Barry


On 9/13/08 10:35 AM, "Alex Katebi" <alex.katebi@stripped> wrote:

> 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

-------------------------------------------------------------------------
Barry Leslie

SNAP Innovation Softwareentwicklung GmbH
Senior Software Engineer

Tel: (001) 250 595 4228
Fax: (001) 250 595 4233
Email: Barry.Leslie@stripped
Web: www.PrimeBase.com

SNAP Innovation Softwareentwicklung GmbH, D-22765 Hamburg,
Max-Brauer-Allee 50, Germany
Amtsgericht Hamburg HRB 61066, Geschäftsführer: Ulrich Zimmer, Paul
McCullagh
-------------------------------------------------------------------------



Thread
embedded server examplesAlex Katebi13 Sep
  • Re: embedded server examplesBarry Leslie15 Sep