Hi,I want to use SQLite with my Golang Application on Linux and I wanted that the sqlite library be present in my own Application folder.So firstly created a library file in a subfolder mydb :gcc $(go env GOGCCFLAGS) -shared -o libmydb.so sqlite3.c -ldlI am using the SQlite Binding from here :I modified the CGO Line in sqlite3.go from :--#cgo pkg-config: sqlite3To :#cgo LDFLAGS: -L/my/src/mydb -lmydb
When I build my golang application and do a LDD :linux-gate.so.1 => (0x001ad000) libnudb.so => /usr/lib/libmydb.so (0x00786000) libpthread.so.0 => /lib/libpthread.so.0 (0x00d69000) libc.so.6 => /lib/libc.so.6 (0x00b7d000) libdl.so.2 => /lib/libdl.so.2 (0x00983000) /lib/ld-linux.so.2 (0x0099c000)As you can see its trying to find the Library file in :/usr/lib/libmydb.so
Instead of looking for it in the current folder.How can I change this so that it looks in the current folder ?On Windows you just need to add the sqlite.dll in the same folder and it works.Looking forward to any input.Regards,R
Hi,I tried that and its still searching in the /usr/lib/ folder.What is the -x param ?The LD_LIBRARY_PATH solution works as intended but it will require a SHELL SCRIPT to start the application instead of it actually starting on its own.Regards,R
Hi,I though Static linking is not at all possible at the moment.Did you try it on Linux as well ?Regards,R
// #cgo LDFLAGS: -r PATH
import "C"
Hi,I got it working now.Thanks. The -ldflags="-r PATH" works great.Regards,R
On Monday, September 17, 2012 11:36:28 AM UTC+5:30, Dave Cheney wrote:
On Sep 17, 2012 9:07 PM, "Raph" <gala...@gmx.de> wrote:
>
> Shouldn't it be possible to use this in the #cgo part of a .go file, too?
>
> Along the lines of:
>
>> // #cgo LDFLAGS: -r PATH
>> import "C"
>
> Is this supported?
no. cgo ldflags is for gcc, -ldflags is for go's linker, they are not the same thing.
I advocate static linking.
For me at least, this would be the ideal solution, but the problem is some of the libraries I need are C++ with C headers, and not C, so they can't be compiled by CGO.