How To Compile D2SQLite3 on OSX?

Mike McKee via Digitalmars-d digitalmars-d at puremagic.com
Mon Sep 7 22:50:14 PDT 2015


LOL, I feel like I need to do one of these "Explain like I'm 5" 
kind of posts you see on Reddit. I'm stuck. I'm on OSX 
(Yosemite). I seem to have properly installed homebrew, and then 
dub, and then sqlite3, and I have the dmd D compiler installed 
and working. Now I'm trying to get D2SQLite3 installed on OSX so 
that I can interact with a SQLite database. I downloaded and 
expanded the zip from Github:

https://github.com/biozic/d2sqlite3

...and then cd'd to this directory. I then edited the dub.json 
file like so:

{
     "name": "d2sqlite3",
     "description": "A thin wrapper around SQLite3",
     "homepage": "https://github.com/biozic/d2sqlite3",
     "authors": ["Nicolas Sicard", "Other contributors: see Github 
repo"],
     "copyright": "Copyright 2011-15 Nicolas Sicard",
     "license": "BSL-1.0",
     "targetType": "library",
     "libs": ["sqlite3"],
     "systemDependencies": "SQLite version >= 3.8.7",
     "lflags": 
["-L/usr/local/Cellar/sqlite/3.8.11.1/lib/libsqlite3.dylib"]
}


...although I'm not quite clear if I did the lflags line 
properly. I then ran "dub build" and it seems to have created the 
file: libd2sqlite3.a

Now I don't know what to do with that file. I also created a 
test.d script to test the SQLite out, but it's complaining of 
missing symbols, even though I'm importing the right .d files:

import d2sqlite3;
import std.array;
import std.conv;
import std.exception;
import std.file;
import std.path;
import std.stdio;
import std.string;
import std.c.stdlib : exit;
import core.stdc.time : time_t;
import etc.c.zlib;

void main(){

	auto db = Database("test.sqlite");
	auto results = db.execute("SELECT * FROM test");
	while (!results.empty) {
		auto row = results.front;
		writeln(row.peek!string(0));
		results.popFront();
	}

}

When I compile this, it complains of missing the d2SQLite symbols:

$ dmd test.d
Undefined symbols for architecture x86_64:
   "_D9d2sqlite311ResultRange11__fieldDtorMFZv", referenced from:
       __Dmain in test.o
   "_D9d2sqlite311ResultRange5emptyMFNdZb", referenced from:
       __Dmain in test.o
   "_D9d2sqlite311ResultRange5frontMFNdZS9d2sqlite33Row", 
referenced from:
       __Dmain in test.o
   "_D9d2sqlite311ResultRange8_Payload11__fieldDtorMFZv", 
referenced from:
       _D42TypeInfo_S9d2sqlite311ResultRange8_Payload6__initZ in 
test.o
   
"_D9d2sqlite311ResultRange8_Payload11__xopEqualsFKxS9d2sqlite311ResultRange8_PayloadKxS9d2sqlite311ResultRange8_PayloadZb", referenced from:
       _D42TypeInfo_S9d2sqlite311ResultRange8_Payload6__initZ in 
test.o
   "_D9d2sqlite311ResultRange8popFrontMFZv", referenced from:
       __Dmain in test.o
   "_D9d2sqlite312__ModuleInfoZ", referenced from:
       _D4test12__ModuleInfoZ in test.o
   "_D9d2sqlite33Row13internalIndexMFiZi", referenced from:
       _D9d2sqlite33Row13__T4peekTAyaZ4peekMFiZAya in test.o
   "_D9d2sqlite38Database11__fieldDtorMFZv", referenced from:
       __Dmain in test.o
   "_D9d2sqlite38Database6__ctorMFNcAyaiZS9d2sqlite38Database", 
referenced from:
       __Dmain in test.o
   "_D9d2sqlite38Database7executeMFAyaZS9d2sqlite311ResultRange", 
referenced from:
       __Dmain in test.o
   "_D9d2sqlite38Database8_Payload6__dtorMFZv", referenced from:
       _D38TypeInfo_S9d2sqlite38Database8_Payload6__initZ in test.o
   "_D9d2sqlite39Statement8_Payload10__aggrDtorMFZv", referenced 
from:
       _D39TypeInfo_S9d2sqlite39Statement8_Payload6__initZ in 
test.o
   
"_D9d2sqlite39Statement8_Payload11__xopEqualsFKxS9d2sqlite39Statement8_PayloadKxS9d2sqlite39Statement8_PayloadZb", referenced from:
       _D39TypeInfo_S9d2sqlite39Statement8_Payload6__initZ in 
test.o
   "_sqlite3_column_text", referenced from:
       _D9d2sqlite33Row13__T4peekTAyaZ4peekMFiZAya in test.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to 
see invocation)
--- errorlevel 1

How do I get this going?



More information about the Digitalmars-d mailing list