ctabin / libzippp

C++ wrapper for libzip
Other
376 stars 93 forks source link

Failed to build in Codespace #225

Closed AstroAir closed 6 months ago

AstroAir commented 6 months ago

Sorry to bother you again.Recently, I attempted to build libzippp in Codespace, but encountered the following error:

[build] /workspaces/Lithium/libs/libzippp/libzippp.cpp: In member function ‘int libzippp::ZipArchive::close()’:
[build] /workspaces/Lithium/libs/libzippp/libzippp.cpp:388:13: error: ‘zip_register_cancel_callback_with_state’ was not declared in this scope; did you mean ‘zip_register_progress_callback_with_state’?
[build]   388 |             zip_register_cancel_callback_with_state(zipHandle, progress_cancel_callback, nullptr, this);
[build]       |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build]       |             zip_register_progress_callback_with_state
        if(!listeners.empty()) {
            zip_register_progress_callback_with_state(zipHandle, progressPrecision, progress_callback, nullptr, this);
            zip_register_cancel_callback_with_state(zipHandle, progress_cancel_callback, nullptr, this);
        }

I don't know where the problem is, I hope to get help.

ctabin commented 6 months ago

Hi @AstroAir,

It is odd, since the function zip_register_cancel_callback_with_state exists since long time ago... :thinking: Did you try it to build with CMake or Makefile ?

Sorry, I have no experience in Codespace.

AstroAir commented 6 months ago

@ctabin

@AstroAir ➜ /workspaces/libzippp/build (master) $ cmake ..
-- The CXX compiler identification is GNU 9.4.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11") 
-- Found LIBZIP: /usr/lib/x86_64-linux-gnu/libzip.so  
-- Found BZip2: /usr/lib/x86_64-linux-gnu/libbz2.so (found version "1.0.8") 
-- Looking for BZ2_bzCompressInit
-- Looking for BZ2_bzCompressInit - found
-- Configuring done
-- Generating done
-- Build files have been written to: /workspaces/libzippp/build
@AstroAir ➜ /workspaces/libzippp/build (master) $ make
Scanning dependencies of target libzippp
[ 25%] Building CXX object CMakeFiles/libzippp.dir/src/libzippp.cpp.o
/workspaces/libzippp/src/libzippp.cpp: In member function ‘int libzippp::ZipArchive::close()’:
/workspaces/libzippp/src/libzippp.cpp:388:13: error: ‘zip_register_cancel_callback_with_state’ was not declared in this scope; did you mean ‘zip_register_progress_callback_with_state’?
  388 |             zip_register_cancel_callback_with_state(zipHandle, progress_cancel_callback, nullptr, this);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |             zip_register_progress_callback_with_state
make[2]: *** [CMakeFiles/libzippp.dir/build.make:63: CMakeFiles/libzippp.dir/src/libzippp.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:105: CMakeFiles/libzippp.dir/all] Error 2
make: *** [Makefile:141: all] Error 2
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.4.0-1ubuntu1~20.04.2' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-9QDOt0/gcc-9-9.4.0/debian/tmp-nvptx/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.2)

cmake version 3.16.3

CMake suite maintained and supported by Kitware (kitware.com/cmake).
ctabin commented 6 months ago

Did you build a recent version of libzip ? I cannot se the version in your log. Also you're using an old version of zlib but that doesn't seem related.

AstroAir commented 6 months ago

libzip-dev:amd64 (1.5.1-0ubuntu1)

I used this command to install : sudo apt install zlib1g-dev libzip-dev liblzma-dev libbz2-dev

ctabin commented 6 months ago

@AstroAir Seems to be the version of libzip which is too old... the function has been implemented in 1.6.0 and you're using version 1.5.1.

AstroAir commented 6 months ago

But the version in the official source of Ubuntu is indeed very old, is there any way to be compatible?

ctabin commented 6 months ago

You'll have to compile libzip locally and use this version instead of the one provided by Ubuntu. This is the way it is done in the Github CI either with the Makefile and CMake.

AstroAir commented 6 months ago

Okay, I'll give it a try. Thank you for your help