discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Howto write GNUmakefile.preamble with using C API


From: Jaroslav Joska
Subject: Howto write GNUmakefile.preamble with using C API
Date: Mon, 21 Jul 2008 21:10:50 +0200
User-agent: Thunderbird 2.0.0.12 (X11/20080213)

Hi all!

When I waited for reply to my question about installing SQLClient,
I tried C program API to connect with MySQL. Tjis is C file test.c:

*#include* <mysql.h>
*#include* <stdio.h>

*main*() {
  MYSQL *conn;
  MYSQL_RES *res;
  MYSQL_ROW row;

  char *server = "localhost";
  char *user = "root";
  char *password = "PASSWORD"; //* set me first *//
  char *database = "mysql";

  conn = *mysql_init*(NULL);

  //* Connect to database *//
  *if* (!*mysql_real_connect*(conn, server,
        user, password, database, 0, NULL, 0)) {
     *fprintf*(stderr, "%s\n", *mysql_error*(conn));
     *exit*(1);
  }

  //* send SQL query *//
  *if* (*mysql_query*(conn, "show tables")) {
     *fprintf*(stderr, "%s\n", *mysql_error*(conn));
     *exit*(1);
  }

  res = *mysql_use_result*(conn);

  //* output table name *//
  *printf*("MySQL Tables in mysql database:\n");
  *while* ((row = *mysql_fetch_row*(res)) != NULL)
     *printf*("%s \n", row[0]);

  //* close connection *//
  *mysql_free_result*(res);
  *mysql_close*(conn);
}

I successfully complied with this command:
# |*gcc -o test $(mysql_config --cflags) test.c *||*$(mysql_config --libs)*|
#./test
and it's fully working.


And this is my question. Can I compile this file (first rename to test.m) with GNUstep make? I changed GNUstep.preamble many times. I compiled test.m file without error massage, but
for everytime I got "Segmentation fault :11" without core file.

Does anybody knows which variables in my GNUmakefile.preamble have I to change?
ADDITIONAL_CPPFLAGS +=
ADDITIONAL_OBJCFLAGS +=
ADDITIONAL_TOOL_LIBS += -L/usr/local/lib/mysql -lmysqlclient -lz -lcrypt -lm
ADDITIONAL_CFLAGS += -I/usr/local/include/mysql  -fno-strict-aliasing -pipe
ADDITIONAL_INCLUDE_DIRS +=  -I/usr/local/include/mysql
ADDITIONAL_LDFLAGS +=
ADDITIONAL_LIB_DIRS += -L/usr/local/lib/mysql
ADDITIONAL_INSTALL_DIRS +=

This is my MySQL configuration.
# mysql_config
Usage: /usr/local/bin/mysql_config [OPTIONS]
Options:
--cflags [-I/usr/local/include/mysql -fno-strict-aliasing -pipe]
       --include        [-I/usr/local/include/mysql]
--libs [-L/usr/local/lib/mysql -lmysqlclient -lz -lcrypt -lm] --libs_r [-L/usr/local/lib/mysql -lmysqlclient_r -lz -pthread -lcrypt -lm -pthread]
       --socket         [/tmp/mysql.sock]
       --port           [0]
       --version        [5.1.23-rc]
--libmysqld-libs [-L/usr/local/lib/mysql -lmysqld -lz -pthread -lcrypt -lm -pthread -lwrap]





reply via email to

[Prev in Thread] Current Thread [Next in Thread]