prasannap5 / snappy

Automatically exported from code.google.com/p/snappy
Other
0 stars 0 forks source link

Unable to build snappy as shared library on mingw-w64 #69

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello,

I'm trying to build snappy as a shared library for Windows 64 bits, via msys + 
mingw-w64.

I run configure with --enable-shared and --disable-static, which runs 
successfully. And then run make and make install, which also run successfully 
(and so does make check).

However, only libsnappy.a and libsnappy.la files are built and installed in 
/usr/local/lib/. No shared library version was built, confirmed by listing the 
contents of .libs/ in the source directory:

fdmanana@fdmanana-win ~/snappy-1.1.0$ ls -lha .libs/
total 1.1M
drwxr-xr-x 2 fdmanana Administrators 4.0K Feb 17 16:56 .
drwxr-xr-x 6 fdmanana Administrators  16K Feb 17 16:56 ..
-rw-r--r-- 1 fdmanana Administrators  84K Feb 17 16:56 libsnappy.a
-rw-r--r-- 1 fdmanana Administrators  917 Feb 17 16:56 libsnappy.la
-rw-r--r-- 1 fdmanana Administrators  918 Feb 17 16:56 libsnappy.lai
-rw-r--r-- 1 fdmanana Administrators  32K Feb 17 16:56 lt-snappy_unittest.c
-rw-r--r-- 1 fdmanana Administrators 6.6K Feb 17 16:56 snappy-c.o
-rw-r--r-- 1 fdmanana Administrators 6.1K Feb 17 16:56 snappy-sinksource.o
-rw-r--r-- 1 fdmanana Administrators 6.4K Feb 17 16:56 snappy-stubs-internal.o
-rw-r--r-- 1 fdmanana Administrators  61K Feb 17 16:56 snappy.o
-rwxr-xr-x 1 fdmanana Administrators 803K Feb 17 16:56 snappy_unittest.exe
-rwxr-xr-x 1 fdmanana Administrators 6.0K Feb 17 16:56 
snappy_unittest_ltshwrapper
fdmanana@fdmanana-win ~/snappy-1.1.0$ 

While make check succeeds, the problem is that when I try to build a C 
application that links to snappy (via -lsnappy) to make use of snappy-c, the 
later produces the following warning and linking error:

libtool: link: ( cd ".libs" && rm -f "libbyteswap.la" && cp -p 
"../libbyteswap.la" "libbyteswap.la" )
/bin/sh ./libtool --tag=CC   --mode=link gcc -std=c99  -I/usr/local/include  
-DLIBCOUCHSTORE_INTERNAL=1 -Wstrict-aliasing=2 -pedantic -I/local64/include 
-mms-bitfields -mthreads -DHAVE_VISIBILITY=1 -fvisibility=hidden 
-L/usr/local/lib  -version-info 1:0:0 -no-undefined -lsnappy -lpthread -lws2_32 
-L/local64/lib -L/usr/local/lib -o libcouchstore.la -rpath /usr/local/lib 
src/libcouchstore_la-arena.lo src/libcouchstore_la-btree_modify.lo 
src/libcouchstore_la-btree_read.lo src/libcouchstore_la-collate_json.lo 
src/libcouchstore_la-couch_db.lo src/libcouchstore_la-couch_save.lo 
src/libcouchstore_la-crc32.lo src/libcouchstore_la-couch_file_read.lo 
src/libcouchstore_la-couch_file_write.lo src/libcouchstore_la-db_compact.lo 
src/libcouchstore_la-iobuffer.lo src/libcouchstore_la-json_reduce.lo 
src/libcouchstore_la-llmsort.lo src/libcouchstore_la-tree_writer.lo 
src/libcouchstore_la-mergesort.lo src/libcouchstore_la-node_types.lo 
src/libcouchstore_la-reduces.lo src/libcouchstore_la-strerror.lo 
src/libcouchstore_la-util.lo src/libcouchstore_la-couch_index.lo 
src/libcouchstore_la-os_win.lo  librfc1321.la libbyteswap.la -licuuc -licuin 

*** Warning: This system can not link to static lib archive 
/usr/local/lib/libsnappy.la.
*** I have the capability to make that library automatically link in when
*** you link to this library.  But I can only do this if you have a
*** shared version of the library, which you do not appear to have.

(...)

/bin/sh ./libtool --tag=CC   --mode=link gcc -std=c99  -D__STDC_FORMAT_MACROS 
-I/local64/include -mms-bitfields -mthreads -DHAVE_VISIBILITY=1 
-fvisibility=hidden -L/local64/lib -L/usr/local/lib -o couch_dbdump.exe 
src/couch_dbdump-dbdump.o libcouchstore.la libbyteswap.la -lsnappy -lws2_32 
libtool: link: gcc -std=c99 -D__STDC_FORMAT_MACROS -I/local64/include 
-mms-bitfields -mthreads -DHAVE_VISIBILITY=1 -fvisibility=hidden -o 
.libs/couch_dbdump.exe src/couch_dbdump-dbdump.o  -L/local64/lib 
-L/usr/local/lib ./.libs/libcouchstore.a -lpthread -licuuc -licuin 
./.libs/libbyteswap.a /usr/local/lib/libsnappy.a -lws2_32 -mthreads
C:/MinGW/msys/1.0/local/lib/libsnappy.a(snappy-c.o):snappy-c.cc:(.text+0x76): 
undefined reference to `__gxx_personality_sj0'
C:/MinGW/msys/1.0/local/lib/libsnappy.a(snappy-c.o):snappy-c.cc:(.text+0x1d3): 
undefined reference to `__gxx_personality_sj0'
C:/MinGW/msys/1.0/local/lib/libsnappy.a(snappy-c.o):snappy-c.cc:(.text+0x326): 
undefined reference to `__gxx_personality_sj0'
C:/MinGW/msys/1.0/local/lib/libsnappy.a(snappy-c.o):snappy-c.cc:(.text+0x483): 
undefined reference to `__gxx_personality_sj0'
C:/MinGW/msys/1.0/local/lib/libsnappy.a(snappy-c.o):snappy-c.cc:(.text+0x5e0): 
undefined reference to `__gxx_personality_sj0'
C:/MinGW/msys/1.0/local/lib/libsnappy.a(snappy-c.o):snappy-c.cc:(.text+0x733): 
more undefined references to `__gxx_personality_sj0' follow
c:/mingw/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.7.0/../../../../x86_64-w64-
mingw32/bin/ld.exe: C:/MinGW/msys/1.0/local/lib/libsnappy.a(snappy-c.o): bad 
reloc address 0x0 in section `.pdata'
c:/mingw/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.7.0/../../../../x86_64-w64-
mingw32/bin/ld.exe: final link failed: Invalid operation
collect2.exe: error: ld returned 1 exit status

Attached is my config.log.

Am I missing something here, or a snappy shared library is not supported for 
mingw-w64?

thank you

Original issue reported on code.google.com by fdman...@gmail.com on 17 Feb 2013 at 5:11

Attachments:

GoogleCodeExporter commented 9 years ago
Hi,

We don't really do library building ourselves; all of this is deferred to 
libtool, which we use in a rather straightforward way. So if it doesn't work on 
your platform, please open a bug with libtool.

Original comment by se...@google.com on 17 Feb 2013 at 5:12

GoogleCodeExporter commented 9 years ago
Thanks.
Indeed it seems to be libtool specific.

I manually built the shared library like this:

g++ -shared -o libsnappy.so snappy.cc snappy-sinksource.cc 
snappy-stubs-internal.cc snappy-c.cc

And it works perfectly, tested by writing a small test program that links with 
it and does compression and decompression.
Will report an issue to libtool.

Original comment by fdman...@gmail.com on 17 Feb 2013 at 7:51