I am new to Gyp. Instead of compiling my dependency, I would like to use a shared library, in particular, libsqlite3.so, which is already on my machine. The main binding.gyp currently looks like
{ 'targets': [ { 'target_name': 'node_sqlite3', 'sources': [ 'src/database.cc', 'src/node_sqlite3.cc', 'src/statement.cc' ], 'dependencies': [ 'deps/sqlite3/binding.gyp:sqlite3' ] } ] }
How do I change this to use the sqlite3 shared library? The binding.gyp file in the deps folder has a section that looks below. I don't think I need gyp to compile sqlite3 for me, so the switch type for shared_library is probably not the right answer.
'targets': [ { 'target_name': 'sqlite3', 'type': 'static_library', 'include_dirs': [ '.' ], 'direct_dependent_settings': { 'include_dirs': [ '.' ], 'defines': [ 'SQLITE_THREADSAFE=1', 'SQLITE_ENABLE_FTS3', 'SQLITE_ENABLE_RTREE' ], }, 'defines': [ '_REENTRANT=1', 'SQLITE_THREADSAFE=1', 'SQLITE_ENABLE_FTS3', 'SQLITE_ENABLE_RTREE' ], 'sources': [ './sqlite3.c', ], }, { 'target_name': 'shell', 'type': 'executable', 'dependencies': [ 'sqlite3' ], 'sources': [ './shell.c' ] } ] }
Update. . I managed to get things to compile by changing the binding to this.
{ 'targets': [ { 'target_name': 'node_sqlite3', 'sources': [ 'src/database.cc', 'src/node_sqlite3.cc', 'src/statement.cc' ], 'ldflags': [ '-lsqlite3' ] } ] }
However, when I go to run the program using the module, I get
node: symbol search error: / usr / local / lib / node_modules / sqlite3 / build / Release / node_sqlite3.node: undefined symbol: sqlite3_open_v2
as if the shared library is not loading or unavailable. I think I'm near. libsqlite3 was installed in / usr / local / lib
/usr/local/lib$ ls libsqlite3.a libsqlite3.so libsqlite3.so.0.8.6 node_modules python2.7 libsqlite3.la libsqlite3.so.0 node pkgconfig
Update2. The plot is thickening. I tried ldd in the executable created by node -sqlite3
linux-vdso.so.1 => (0x00007fffd7168000) libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fc9451df000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fc944fc2000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fc944c04000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fc94490a000) /lib64/ld-linux-x86-64.so.2 (0x00007fc945704000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fc9446f4000)
Obviously, libsqlite3 is missing. So maybe my ldflags instruction really didnβt work as planned.