N
N
nick88hello2014-05-21 15:01:48
C++ / C#
nick88hello, 2014-05-21 15:01:48

How to convert a static library ( fileName.a ) to a shared one ( fileName.so ) using gcc ?

I'm trying to build a zip extension for php :

phpize

     ./configure 
              --disable-static
             --enable-shared
             --enable-zip
             --with-php-config=/usr/local/bin/php-config

      make

     make install

But after compilation, files are created: zip.a and zip.la , but zip.so is needed.
Tried to do the following:
// stackoverflow.com/questions/6263780/how-to-create-a-shared-object-file-from-static-library
       
gcc -shared -o zip.so -Wl,--whole-archive zip.a

 ошибка: выполнение ld завершилось с кодом возврата 1

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
jcmvbkbc, 2014-05-21
@jcmvbkbc

Might just be
ld -shared -o zip.so --whole-archive zip.a

N
nick88hello, 2014-05-21
@nick88hello

Unfortunately it didn't help. Everywhere the same error : ... undefined reference to ...
Here is a snippet :

ld -shared -o zip.so --whole-archive zip.a

/usr/src/zip/php_zip.c:3155: undefined reference to `php_info_print_table_start'
/usr/src/zip/php_zip.c:3157: undefined reference to `php_info_print_table_row'
/usr/src/zip/php_zip.c:3158: undefined reference to `php_info_print_table_row'
/usr/src/zip/php_zip.c:3159: undefined reference to `php_info_print_table_row'
/usr/src/zip/php_zip.c:3160: undefined reference to `php_info_print_table_row'
zip.a(php_zip.o): In function `zm_shutdown_zip':
/usr/src/zip/php_zip.c:3144: undefined reference to `zend_hash_destroy'
/usr/src/zip/php_zip.c:3145: undefined reference to `php_unregister_url_stream_wrapper'
zip.a(php_zip.o): In function `php_zip_free_entry':
/usr/src/zip/php_zip.c:1202: undefined reference to `_efree'
zip.a(php_zip.o): In function `php_zip_free_dir':
/usr/src/zip/php_zip.c:1185: undefined reference to `_efree'
/usr/src/zip/php_zip.c:1180: undefined reference to `php_error_docref0'
zip.a(php_zip.o): In function `php_zip_object_new':
/usr/src/zip/php_zip.c:1134: undefined reference to `_emalloc'
/usr/src/zip/php_zip.c:1144: undefined reference to `zend_object_std_init'
/usr/src/zip/php_zip.c:1156: undefined reference to `object_properties_init'
/usr/src/zip/php_zip.c:1158: undefined reference to `zend_objects_store_put'
zip.a(php_zip.o): In function `php_zip_object_free_storage':
/usr/src/zip/php_zip.c:1098: undefined reference to `_efree'
/usr/src/zip/php_zip.c:1100: undefined reference to `_efree'
/usr/src/zip/php_zip.c:1106: undefined reference to `zend_object_std_dtor'
/usr/src/zip/php_zip.c:1120: undefined reference to `_efree'
/usr/src/zip/php_zip.c:1090: undefined reference to `php_error_docref0'
zip.a(php_zip.o): In function `c_ziparchive_getExternalAttributesIndex':
/usr/src/zip/php_zip.c:2304: undefined reference to `zend_object_store_get_object'

Please help me, how to correctly link everything you need, what parameters still need to be specified? Compiling sources for *.nix systems is not my province. So I'm asking the experts for advice...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question