Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building go-sqlite on system with other installed sqlite3 version #321

Closed
darinkes opened this issue Aug 10, 2016 · 12 comments
Closed

Building go-sqlite on system with other installed sqlite3 version #321

darinkes opened this issue Aug 10, 2016 · 12 comments
Assignees
Milestone

Comments

@darinkes
Copy link

If you import this Package on an OpenBSD 5.9 system your compiled tool will always print a warning:

./tool:/usr/lib/libsqlite3.so.32.0: ./tool: WARNING: symbol(sqlite3_version) size mismatch, relink your program

Problem is the installed version of sqlite3 differs from the one sqlite3-binding.c is copied from.

$ sqlite3 --version
3.9.2 OpenBSD
#define SQLITE_VERSION        "3.12.2"

Enabling the Build Tags "--tags 'libsqlite3 openbsd'" should fix this, but still this Warning occurs, because sqlite3-binding.c is compiled, nevertheless you want to use the system library.

This Diff fixes the Issue for me.

diff --git a/vendor/github.com/mattn/go-sqlite3/callback.go b/vendor/github.com/mattn/go-sqlite3/callback.go
index e2bf3c6..190b695 100644
--- a/vendor/github.com/mattn/go-sqlite3/callback.go
+++ b/vendor/github.com/mattn/go-sqlite3/callback.go
@@ -11,7 +11,11 @@ package sqlite3
 // code for SQLite custom functions is in here.

 /*
+#ifndef USE_LIBSQLITE3
 #include <sqlite3-binding.h>
+#else
+#include <sqlite3.h>
+#endif
 #include <stdlib.h>

 void _sqlite3_result_text(sqlite3_context* ctx, const char* s);
diff --git a/vendor/github.com/mattn/go-sqlite3/sqlite3-binding.c b/vendor/github.com/mattn/go-sqlite3/sqlite3-binding.c
index 7b82c55..caeabba 100644
--- a/vendor/github.com/mattn/go-sqlite3/sqlite3-binding.c
+++ b/vendor/github.com/mattn/go-sqlite3/sqlite3-binding.c
@@ -17,6 +17,7 @@
 ** language. The code for the "sqlite3" command-line shell is also in a
 ** separate file. This file contains only code for the core SQLite library.
 */
+#ifndef USE_LIBSQLITE3
 #define SQLITE_CORE 1
 #define SQLITE_AMALGAMATION 1
 #ifndef SQLITE_PRIVATE
@@ -189317,3 +189318,5 @@ static int sqlite3Fts5VocabInit(Fts5Global *pGlobal, sqlite3 *db){
 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS5) */

 /************** End of fts5.c ************************************************/
+
+#endif // !USE_LIBSQLITE3
diff --git a/vendor/github.com/mattn/go-sqlite3/sqlite3_libsqlite3.go b/vendor/github.com/mattn/go-sqlite3/sqlite3_libsqlite3.go
index 135863e..9550d2f 100644
--- a/vendor/github.com/mattn/go-sqlite3/sqlite3_libsqlite3.go
+++ b/vendor/github.com/mattn/go-sqlite3/sqlite3_libsqlite3.go
@@ -9,6 +9,7 @@ package sqlite3
 /*
 #cgo CFLAGS: -DUSE_LIBSQLITE3
 #cgo linux LDFLAGS: -lsqlite3
+#cgo openbsd LDFLAGS: -lsqlite3
 #cgo darwin LDFLAGS: -L/usr/local/opt/sqlite/lib -lsqlite3
 */
 import "C"
diff --git a/vendor/github.com/mattn/go-sqlite3/sqlite3_load_extension.go b/vendor/github.com/mattn/go-sqlite3/sqlite3_load_extension.go
index 55c8ad7..e6e0801 100644
--- a/vendor/github.com/mattn/go-sqlite3/sqlite3_load_extension.go
+++ b/vendor/github.com/mattn/go-sqlite3/sqlite3_load_extension.go
@@ -7,7 +7,11 @@
 package sqlite3

 /*
+#ifndef USE_LIBSQLITE3
 #include <sqlite3-binding.h>
+#else
+#include <sqlite3.h>
+#endif
 #include <stdlib.h>
 */
 import "C"
diff --git a/vendor/github.com/mattn/go-sqlite3/sqlite3ext.h b/vendor/github.com/mattn/go-sqlite3/sqlite3ext.h
index f02f2c2..d89509f 100644
--- a/vendor/github.com/mattn/go-sqlite3/sqlite3ext.h
+++ b/vendor/github.com/mattn/go-sqlite3/sqlite3ext.h
@@ -17,7 +17,11 @@
 */
 #ifndef _SQLITE3EXT_H_
 #define _SQLITE3EXT_H_
-#include "sqlite3-binding.h"
+#ifndef USE_LIBSQLITE3
+#include <sqlite3-binding.h>
+#else
+#include <sqlite3.h>
+#endif

 typedef struct sqlite3_api_routines sqlite3_api_routines;

Whats your opinion on this topic?
I think warnings should be avoided, since they might confuse the user.

@dgsb
Copy link
Contributor

dgsb commented Sep 15, 2016

Hello @darinkes this is related with #318 and #293. We should definitely not mix the vendored files or the system library.

@leehambley
Copy link

Also related to #330 where it seems to be reported that the -tag libsqlite3 has no effect because the files are compiled anyway and happen to be opportunistically used by the linker.

gjrtimmer added a commit to gjrtimmer/go-sqlite3 that referenced this issue May 26, 2018
Compile Section Closes mattn#175
Compile Section Closes mattn#201
Compile Section Closes mattn#206
Compile Section Closes mattn#404
Compile Section Closes mattn#217
Compile Section Closes mattn#224
Compile Section Closes mattn#234
Compile Section Closes mattn#242
Feature table Closes mattn#255
Description Section Closes mattn#232
Golang:1.6 not supported Closes mattn#272
Golang:1.5 not supported + compilation section Closes mattn#283
usleep Implemented Closes mattn#285
FAQ Section Closes mattn#289
Compile Section closes mattn#295
FAQ Section Closes mattn#305
PR339 Closes mattn#318 mattn#321
Compilation Section Closes mattn#341
PR407 Closes mattn#364
Feature `sqlite_vtable` Closes mattn#393
Compile Section Closes mattn#416
sqlite_trace feature Closes mattn#433
Compilation Section Closes mattn#435
Compilation Section Closes mattn#443
Golang:1.6 Not Supported Closes mattn#445
Compilation Section Closes mattn#451
Compilation Section Closes mattn#467
Compilation Section Closes mattn#491
Compilation Section Closes mattn#495
Compilation Section Closes mattn#505
Compilation Section Closes mattn#557
Compilation Section Closes mattn#560
gjrtimmer added a commit to gjrtimmer/go-sqlite3 that referenced this issue May 26, 2018
Compile Section Closes mattn#175
Compile Section Closes mattn#201
Compile Section Closes mattn#206
Compile Section Closes mattn#404
Compile Section Closes mattn#217
Compile Section Closes mattn#224
Compile Section Closes mattn#234
Compile Section Closes mattn#242
Feature table Closes mattn#255
Description Section Closes mattn#232
Golang:1.6 not supported Closes mattn#272
Golang:1.5 not supported + compilation section Closes mattn#283
usleep Implemented Closes mattn#285
FAQ Section Closes mattn#289
Compile Section closes mattn#295
FAQ Section Closes mattn#305
PR339 Closes mattn#318 mattn#321
Compilation Section Closes mattn#341
PR407 Closes mattn#364
Feature `sqlite_vtable` Closes mattn#393
Compile Section Closes mattn#416
sqlite_trace feature Closes mattn#433
Compilation Section Closes mattn#435
Compilation Section Closes mattn#443
Golang:1.6 Not Supported Closes mattn#445
Compilation Section Closes mattn#451
Compilation Section Closes mattn#467
Compilation Section Closes mattn#491
Compilation Section Closes mattn#495
Compilation Section Closes mattn#505
Compilation Section Closes mattn#557
Compilation Section Closes mattn#560
[ci skip]
@gjrtimmer
Copy link
Collaborator

gjrtimmer commented May 30, 2018

Already implemented:

#ifndef USE_LIBSQLITE3
#include <sqlite3-binding.h>
#else
#include <sqlite3.h>
#endif

To be added:

#cgo openbsd LDFLAGS: -lsqlite3

gjrtimmer added a commit to gjrtimmer/go-sqlite3 that referenced this issue May 30, 2018
gjrtimmer added a commit that referenced this issue May 30, 2018
@gjrtimmer
Copy link
Collaborator

@darinkes Could you please checkout branch fix/platform and test again please. Thanks.

@gjrtimmer
Copy link
Collaborator

@darinkes any update ?

@darinkes
Copy link
Author

@gjrtimmer Ah, sorry. Thougth the thumbs-up is enough :)
Works for me 👍

@gjrtimmer
Copy link
Collaborator

@darinkes do I need to merge this into the master ?

@darinkes
Copy link
Author

I'm fine with my vendor checkout and update/merge manually.

gjrtimmer added a commit to gjrtimmer/go-sqlite3 that referenced this issue Jun 12, 2018
@gjrtimmer gjrtimmer mentioned this issue Jun 12, 2018
@gjrtimmer
Copy link
Collaborator

When Travis-CI is completed, I will merge, this way you can use the master branch and all the new cool features we are including and all the fixes 👍

@gjrtimmer gjrtimmer self-assigned this Jun 12, 2018
@gjrtimmer gjrtimmer added this to the 1.9.0 milestone Jun 12, 2018
@darinkes
Copy link
Author

Cool! Thanks a lot! 👍

@mattn
Copy link
Owner

mattn commented Jun 13, 2018

closable?

gjrtimmer added a commit that referenced this issue Jun 13, 2018
@gjrtimmer
Copy link
Collaborator

@darinkes You can now use the master, Issue Closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants