This is on a Mac, judging on the hostname and /Users/ being parent of the 
homedir. Therefore I will guess that GNUstep is built as a universal binary and 
the test program is being built as a universal ("fat") binary.

At the very least, force the test program to not be built as a universal binary.

Better is to build sqlite3 as universal.

Best is to use Cocoa if you have it available – in my personal opinion. This is 
best unless you depend on gnustep-make or other GNUstep specific features. And 
use GNUstep on a platform where it won't conflict with Cocoa.

On June 5, 2018 2:48:21 PM GMT+01:00, "Andreas Höschler" <ahoe...@smartsoft.de> 
wrote:
>Hi all,
>
>I would like to access a SQLite database with a minimalistic
>Objective-C (GNUstep) program. I installed SQLite like so
>
>       tar xvf sqlite-autoconf-3230100.tar
>       cd sqlite-autoconf-3230100
>       ./configure
>       make
>       make install
>
>and got
>
>/usr/local/bin/sqlite3
>
>/usr/include/php/ext/sqlite3/libsqlite
>/usr/lib/libsqlite3.0.dylib
>/usr/lib/libsqlite3.dylib
>/usr/local/lib/libsqlite3.0.dylib
>/usr/local/lib/libsqlite3.a
>/usr/local/lib/libsqlite3.dylib
>/usr/local/lib/libsqlite3.la
>
>I have now written the following Objective-C test program but don't get
>it linked! :-(
>
>***************************************************************************************************
>#import <Foundation/Foundation.h>
>#include <sqlite3.h>
>
>static int callback(void *NotUsed, int argc, char **argv, char
>**azColName)
>  {
>   int i;
>   for(i=0; i<argc; i++)
>     {
>      printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
>     }
>   printf("\n");
>   return 0;
>  }
> 
>int main (int argc, const char *argv[])
>  {
>   NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
>   
>   // insert your code here
>     {
>      sqlite3 *db;
>      int rc;
>      
>rc =
>sqlite3_open("/Users/ahoesch/Development/SQLite/sqlite-autoconf-3230100/ex1",
>&db);
>      if (rc) 
>        {
>         NSLog(@"Can't open database: %s\n", sqlite3_errmsg(db));
>         sqlite3_close(db);
>         return(1);
>        }
>      
>      char *zErrMsg = 0;
> rc = sqlite3_exec(db, "select * from PERSON;", callback, 0, &zErrMsg);
>        if (rc != SQLITE_OK)
>          {
>           fprintf(stderr, "SQL error: %s\n", zErrMsg);
>           sqlite3_free(zErrMsg);           
>          }
>        sqlite3_close(db);
>     }
>   
>   [pool release];
>   exit(0);       // insure the process exit status is 0
>   return 0;      // ...and make main fit the ANSI spec.
>}
>***************************************************************************************************
>With the GNumakefile
>
>
>
>I get 
>
>admins-iMac:FirstAccess ahoesch$ make clean
>This is gnustep-make 2.4.0. Type 'make print-gnustep-make-help' for
>help.
>rm -rf /Build/FirstAccess/*~ /Build/FirstAccess/obj
>admins-iMac:FirstAccess ahoesch$ make
>This is gnustep-make 2.4.0. Type 'make print-gnustep-make-help' for
>help.
>Making all for tool FirstAccess...
> Compiling file main.m ...
> Linking tool FirstAccess ...
>Undefined symbols for architecture i386:
>  "_sqlite3_close", referenced from:
>      _main in main.m.o
>  "_sqlite3_errmsg", referenced from:
>      _main in main.m.o
>  "_sqlite3_exec", referenced from:
>      _main in main.m.o
>  "_sqlite3_free", referenced from:
>      _main in main.m.o
>  "_sqlite3_open", referenced from:
>      _main in main.m.o
>ld: symbol(s) not found for architecture i386
>clang: error: linker command failed with exit code 1 (use -v to see
>invocation)
>make[3]: *** [/Build/FirstAccess/obj/FirstAccess] Error 1
>make[2]: *** [internal-tool-all_] Error 2
>make[1]: *** [FirstAccess.all.tool.variables] Error 2
>make: *** [internal-all] Error 2
>
>That's probably because sqlite lib was built for for x86_64 and cannot
>be mixed with 32 bit code!? I extracted the gcc calls with make
>messages=yes and remove all -m32 occurrences. This now gives me
>
>
>admins-iMac:FirstAccess ahoesch$ cd /Build/FirstAccess;
>/Library/GNUstep/Makefiles/mkinstalldirs ./obj
>admins-iMac:FirstAccess ahoesch$ cd /Build/FirstAccess;
>/Library/GNUstep/Makefiles/mkinstalldirs ./obj/FirstAccess.obj/
>admins-iMac:FirstAccess ahoesch$ cd
>/Users/ahoesch/Development/SQLite/FirstAccess
>admins-iMac:FirstAccess ahoesch$ gcc main.m -c -MMD -MP
>-DNeXT_Foundation_LIBRARY=1 -DNeXT_GUI_LIBRARY=1 -DNeXT_RUNTIME=1
>-dynamic -fno-common -Wall -DGSWARN -DGSDIAGNOSE -Wno-import -g -O2
>-fno-strict-aliasing -fnext-runtime -Wno-parentheses -Wno-import -I.
>-I/usr/local/include/ -F/Library/Frameworks/ -o
>/Build/FirstAccess/obj/FirstAccess.obj/main.m.o
>admins-iMac:FirstAccess ahoesch$ gcc -fnext-runtime -o
>/Build/FirstAccess/obj/FirstAccess
>/Build/FirstAccess/obj/FirstAccess.obj/main.m.o -ldl -lpthread -lz -lm 
>-L/usr/local/lib/ -F/Library/Frameworks/    -framework Foundation      
>-lm
>Undefined symbols for architecture x86_64:
>  "_sqlite3_close", referenced from:
>      _main in main.m.o
>  "_sqlite3_errmsg", referenced from:
>      _main in main.m.o
>  "_sqlite3_exec", referenced from:
>      _main in main.m.o
>  "_sqlite3_free", referenced from:
>      _main in main.m.o
>  "_sqlite3_open", referenced from:
>      _main in main.m.o
>ld: symbol(s) not found for architecture x86_64
>clang: error: linker command failed with exit code 1 (use -v to see
>invocation)
>
>I am stuck! Any idea whatI am doing wrong and how to get this working?
>
>Thanks a lot,
>
> Andreas

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.
_______________________________________________
Discuss-gnustep mailing list
Discuss-gnustep@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnustep

Reply via email to