On Thu, 21 Jul 2016 05:45:41 -0700 (PDT)
vijaykumar.g...@vistarait.com wrote:

> i am compiling in 32bit ubuntu 12.04LTS 
> GO Vesrion 1.6.2 (32bit)
> 
> openssl version
> OpenSSL 1.0.1 14 Mar 2012
> 
> i have required library also 
> /lib/i386-linux-gnu/libcrypto.so.1.0.0
> /usr/lib/i386-linux-gnu/libcrypto.a
> /usr/lib/i386-linux-gnu/libcrypto.so
> /usr/lib/i386-linux-gnu/pkgconfig/libcrypto.pc
> 
> 
> I am able to create static binary in 64bit ubuntu 10.04,14.04 but i
> don't know why i am not able to create in 32bit ubuntu
> 
> I am getting this error ,i don't any clue please help
> 
> go build --ldflags '-extldflags "-static"' encrypto.go
> # command-line-arguments
> /usr/local/go/pkg/tool/linux_386/link: running gcc failed: exit
> status 1 /tmp/go-link-283149086/000000.o: In function `unixDlOpen':
> /root/gocode/src/github.com/xeodou/go-sqlcipher/sqlite3-binding.c:37085: 
> warning: Using 'dlopen' in statically linked applications requires at 
> runtime the shared libraries from the glibc version used for linking

I'm pretty much sure that's what James Bardin warned you about in the
previous discussion on the same topic [1].

Basically, github.com/xeodou/go-sqlcipher appears to assume it's always
linked dynamically because it uses the dlopen(3) function from libc
(the standard C library) to load the SQLite shared object file (.so)
_at runtime_.  "dlopen" stands for "dynamic loader open" and involves
actually running the dynamic loader which finds the required library
file, loads it and links with your program in memory.

This means your program -- should you succeed -- won't be static anyway,
because -- as gcc told you -- you'll need to have libc on the target
system.  Most of GNU/Linux-based OSes surely have libc installed but
1) Not all (see Alpine Linux for an example which relies on Musl, not
   Glibc);
2) You'll need glibc of the same version the linker saw on your system
   when it was linking your program.

> /usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/libcrypto.a
> (c_zlib.o): In function `bio_zlib_free':
> (.text+0x4f): undefined reference to `inflateEnd'
> /usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/libcrypto.a
> (c_zlib.o): In function `bio_zlib_free':
> (.text+0x6b): undefined reference to `deflateEnd'
> /usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/libcrypto.a
> (c_zlib.o): In function `bio_zlib_ctrl':
> (.text+0x252): undefined reference to `deflate'
> /usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/libcrypto.a
> (c_zlib.o): In function `bio_zlib_ctrl':
> (.text+0x310): undefined reference to `zError'
> /usr/lib/gcc/i686-linux-gnu/4.6/../../../i386-linux-gnu/libcrypto.a
[...]
> collect2: ld returned 1 exit status

These merely look as the linker not seeing proper (static) version of
the libz library in its path: the names "inflate" and "deflate" and the
name of the offending object file (c_zlib.o) should have give you the
necessary clue ;-)

Let me reiterate: even if/when you succeed in bulding, you won't get
properly static program because the SQLite code will not be compiled
statically into it.  It's surely possible to statically link SQLite
(for instance, Fossil [2] does this) but this requires extensive
changes to github.com/xeodou/go-sqlcipher.  So you could start with
contacting its maintainer on these matters or merely forking the
project and trying to implement this yourself FWIW.

1. https://groups.google.com/d/msg/golang-nuts/4vsUITbJpXc/gB5HFuKuCQAJ
2. http://fossil-scm.org

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to