Compilation fails if "--as-needed" linker flag is set / Не компилируется с опцией "--as-needed"

Issue #29 closed
Former user created an issue

Originally reported on Google Code with ID 29

Во многих дистрибутивах опция "--as-needed" используется по умолчанию.
При компиляции получаем ошибку:

ar -cq libfusezip.a libZipWrapper.o fuseZipData.o fileNode.o fuse-zip.o bigBuffer.o
make[1]: Leaving directory `/usr/src/packages/BUILD/fuse-zip-0.2.13/lib'
g++  main.o -pthread -lfuse -lrt -ldl   -lzip -lz   -Llib -lfusezip \
    -o fuse-zip
lib/libfusezip.a(fuseZipData.o): In function `FuseZipData::build_tree()':
/usr/src/packages/BUILD/fuse-zip-0.2.13/lib/fuseZipData.cpp:56: undefined reference
to `zip_get_num_files'
/usr/src/packages/BUILD/fuse-zip-0.2.13/lib/fuseZipData.cpp:58: undefined reference
to `zip_get_name'
lib/libfusezip.a(fuseZipData.o): In function `FuseZipData::removeNode(FileNode*) const':
/usr/src/packages/BUILD/fuse-zip-0.2.13/lib/fuseZipData.cpp:74: undefined reference
to `zip_delete'
lib/libfusezip.a(fuseZipData.o): In function `~FuseZipData':
... (и т. д.)

Помогает исправление Makefile.

fuse-zip-0.2.13-linker.patch:

Index: Makefile
===================================================================
--- Makefile.orig
+++ Makefile
@@ -1,5 +1,5 @@
 DEST=fuse-zip
-LIBS=$(shell pkg-config fuse --libs) $(shell pkg-config libzip --libs) -Llib -lfusezip
+LIBS=-Llib -lfusezip $(shell pkg-config fuse --libs) $(shell pkg-config libzip --libs)
 LIB=lib/libfusezip.a
 CXXFLAGS=-g -O2 -Wall -Wextra
 RELEASE_CXXFLAGS=-O2 -Wall -Wextra

Reported by lazy.kent.suse on 2010-12-27 18:01:39

Comments (8)

  1. Former user Account Deleted

    ``` Already fixed (changeset a9fad2bb6c). To be included in the next release. ```

    Reported by `alexander.galanin` on 2010-12-28 04:55:34 - Status changed: `Accepted`

  2. Former user Account Deleted

    Reported by alexander.galanin on 2013-06-14 08:51:37 - Labels added: Milestone-0.3

  3. Former user Account Deleted
    Fixed in 0.3.0
    

    Reported by alexander.galanin on 2013-06-29 05:31:21 - Status changed: Fixed

  4. Former user Account Deleted
    I'm sorry to say, it doesn't work.
    
     g++ main.o  -lfuse -pthread  -lzip -lz  -Llib -lfusezip \
         -o fuse-zip
     lib/libfusezip.a(fuseZipData.o): In function `FuseZipData::removeNode(FileNode*) const':
     /home/abuild/rpmbuild/BUILD/fuse-zip-0.3.0/lib/fuseZipData.cpp:87: undefined reference
    to `zip_delete'
     lib/libfusezip.a(fuseZipData.o): In function `FuseZipData::build_tree(bool)':
     /home/abuild/rpmbuild/BUILD/fuse-zip-0.3.0/lib/fuseZipData.cpp:56: undefined reference
    to `zip_get_num_entries'
     /home/abuild/rpmbuild/BUILD/fuse-zip-0.3.0/lib/fuseZipData.cpp:61: undefined reference
    to `zip_get_name'
     /home/abuild/rpmbuild/BUILD/fuse-zip-0.3.0/lib/fuseZipData.cpp:69: undefined reference
    to `zip_get_name'
     lib/libfusezip.a(fuseZipData.o): In function `FuseZipData::~FuseZipData()':
     /home/abuild/rpmbuild/BUILD/fuse-zip-0.3.0/lib/fuseZipData.cpp:41: undefined reference
    to `zip_close'
     /home/abuild/rpmbuild/BUILD/fuse-zip-0.3.0/lib/fuseZipData.cpp:43: undefined reference
    to `zip_strerror'
     lib/libfusezip.a(fileNode.o): In function `FileNode::FileNode(FuseZipData*, char const*,
    long)':
     /home/abuild/rpmbuild/BUILD/fuse-zip-0.3.0/lib/fileNode.cpp:54: undefined reference
    to `zip_stat_index'
     /home/abuild/rpmbuild/BUILD/fuse-zip-0.3.0/lib/fileNode.cpp:60: undefined reference
    to `zip_stat_init'
     lib/libfusezip.a(fuse-zip.o): In function `initFuseZip':
     /home/abuild/rpmbuild/BUILD/fuse-zip-0.3.0/lib/fuse-zip.cpp:54: undefined reference
    to `zip_open'
     /home/abuild/rpmbuild/BUILD/fuse-zip-0.3.0/lib/fuse-zip.cpp:56: undefined reference
    to `zip_error_to_str'
     lib/libfusezip.a(fuse-zip.o): In function `fusezip_mkdir':
     /home/abuild/rpmbuild/BUILD/fuse-zip-0.3.0/lib/fuse-zip.cpp:335: undefined reference
    to `zip_dir_add'
     lib/libfusezip.a(fuse-zip.o): In function `fusezip_rename':
     /home/abuild/rpmbuild/BUILD/fuse-zip-0.3.0/lib/fuse-zip.cpp:401: undefined reference
    to `zip_file_rename'
     /home/abuild/rpmbuild/BUILD/fuse-zip-0.3.0/lib/fuse-zip.cpp:407: undefined reference
    to `zip_file_rename'
     lib/libfusezip.a(bigBuffer.o): In function `BigBuffer::zipUserFunctionCallback(void*,
    void*, unsigned long, zip_source_cmd)':
     /home/abuild/rpmbuild/BUILD/fuse-zip-0.3.0/lib/bigBuffer.cpp:274: undefined reference
    to `zip_stat_init'
     lib/libfusezip.a(bigBuffer.o): In function `BigBuffer::saveToZip(long, zip*, char
    const*, bool, long)':
     /home/abuild/rpmbuild/BUILD/fuse-zip-0.3.0/lib/bigBuffer.cpp:295: undefined reference
    to `zip_source_function'
     /home/abuild/rpmbuild/BUILD/fuse-zip-0.3.0/lib/bigBuffer.cpp:300: undefined reference
    to `zip_file_replace'
     /home/abuild/rpmbuild/BUILD/fuse-zip-0.3.0/lib/bigBuffer.cpp:299: undefined reference
    to `zip_file_add'
     /home/abuild/rpmbuild/BUILD/fuse-zip-0.3.0/lib/bigBuffer.cpp:302: undefined reference
    to `zip_source_free'
     lib/libfusezip.a(bigBuffer.o): In function `BigBuffer::BigBuffer(zip*, unsigned long,
    unsigned long)':
     /home/abuild/rpmbuild/BUILD/fuse-zip-0.3.0/lib/bigBuffer.cpp:161: undefined reference
    to `zip_fopen_index'
     /home/abuild/rpmbuild/BUILD/fuse-zip-0.3.0/lib/bigBuffer.cpp:175: undefined reference
    to `zip_fread'
     /home/abuild/rpmbuild/BUILD/fuse-zip-0.3.0/lib/bigBuffer.cpp:193: undefined reference
    to `zip_fclose'
     /home/abuild/rpmbuild/BUILD/fuse-zip-0.3.0/lib/bigBuffer.cpp:177: undefined reference
    to `zip_file_strerror'
     /home/abuild/rpmbuild/BUILD/fuse-zip-0.3.0/lib/bigBuffer.cpp:179: undefined reference
    to `zip_fclose'
     /home/abuild/rpmbuild/BUILD/fuse-zip-0.3.0/lib/bigBuffer.cpp:187: undefined reference
    to `zip_fclose'
     /home/abuild/rpmbuild/BUILD/fuse-zip-0.3.0/lib/bigBuffer.cpp:189: undefined reference
    to `zip_get_name'
     /home/abuild/rpmbuild/BUILD/fuse-zip-0.3.0/lib/bigBuffer.cpp:194: undefined reference
    to `zip_strerror'
     /home/abuild/rpmbuild/BUILD/fuse-zip-0.3.0/lib/bigBuffer.cpp:195: undefined reference
    to `zip_strerror'
     /home/abuild/rpmbuild/BUILD/fuse-zip-0.3.0/lib/bigBuffer.cpp:163: undefined reference
    to `zip_strerror'
     /home/abuild/rpmbuild/BUILD/fuse-zip-0.3.0/lib/bigBuffer.cpp:164: undefined reference
    to `zip_strerror'
     collect2: error: ld returned 1 exit status
     make: *** [fuse-zip] Error 1
    
    Works with the patch.
    fuse-zip-0.3.0-linker.patch:
    
    Index: fuse-zip-0.3.0/Makefile
    ===================================================================
    --- fuse-zip-0.3.0.orig/Makefile
    +++ fuse-zip-0.3.0/Makefile
    @@ -1,5 +1,5 @@
     DEST=fuse-zip
    -LIBS=$(shell pkg-config fuse --libs) $(shell pkg-config libzip --libs) -Llib -lfusezip
    +LIBS=-Llib -lfusezip $(shell pkg-config fuse --libs) $(shell pkg-config libzip --libs)
     LIB=lib/libfusezip.a
     CXXFLAGS=-g -O0 -Wall -Wextra
     RELEASE_CXXFLAGS=-O2 -Wall -Wextra
    

    Reported by lazy.kent.suse on 2013-06-29 06:15:45

  5. Former user Account Deleted
    OK, I will include fix into thew next release.
    

    Reported by alexander.galanin on 2013-06-30 16:16:32 - Status changed: Started - Labels added: Milestone-0.4 - Labels removed: Milestone-0.3

  6. Former user Account Deleted
    Issue 39 has been merged into this issue.
    

    Reported by alexander.galanin on 2013-10-09 17:38:54

  7. Former user Account Deleted
    Fixed again (version 0.3.1) :)
    

    Reported by alexander.galanin on 2013-12-07 15:22:12 - Status changed: Fixed - Labels added: Type-Defect - Labels removed: Milestone-0.4

  8. Log in to comment