Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"make libraries" not working on Mac OS #77

Closed
AlejandroCamba opened this issue Jul 18, 2020 · 1 comment
Closed

"make libraries" not working on Mac OS #77

AlejandroCamba opened this issue Jul 18, 2020 · 1 comment

Comments

@AlejandroCamba
Copy link

AlejandroCamba commented Jul 18, 2020

I'm working on a C++ project that will later be a Web Assembly module to use with JavaScript, not relevant but useful to know where i intend to go with this.

Click here to go to my GitHub project

When i clone/run the project I'm getting the error:

[ 87%] Building C object lib/CMakeFiles/zip.dir/zip_mkstempm.c.o
make[3]: *** No rule to make target `/Users/alejandrocamba/Documents/libzippp/lib/zlib-1.2.11/libz.so', needed by `lib/libzip.5.3.dylib'.  Stop.
make[3]: *** Waiting for unfinished jobs....
[ 87%] Building C object lib/CMakeFiles/zip.dir/zip_source_file_stdio_named.c.o
[ 87%] Building C object lib/CMakeFiles/zip.dir/zip_random_unix.c.o
make[2]: *** [lib/CMakeFiles/zip.dir/all] Error 2
make[1]: *** [all] Error 2
make: *** [libzip-build-shared] Error 2

I'm using Visual Studio Code and the editor config for c++ files is:

            "includePath": [
                "${workspaceFolder}/**",
                "/usr/local/Cellar/opencv/4.3.0_5/include/opencv4",
                "/Users/alejandrocamba/Documents/leptonica/build/",
                "/Users/alejandrocamba/Documents/tesseract/build/",
                "/usr/local/Cellar/libzip/1.7.3/",
                "/usr/local/Cellar/zlib/1.2.11/",
                "/usr/local/include/libzippp"
            ]

I tried the following workaround based on some online solutions i found:

mkdir build && cd build
cmake ..

-- The C compiler identification is AppleClang 11.0.0.11000033
-- The CXX compiler identification is AppleClang 11.0.0.11000033
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/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/libz.dylib (found version "1.2.11")
-- Found LIBZIP: /usr/local/lib/libzip.dylib
-- Found BZip2: /usr/lib/libbz2.dylib (found version "1.0.6")
-- Looking for BZ2_bzCompressInit
-- Looking for BZ2_bzCompressInit - found
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/alejandrocamba/Documents/libzippp/build

make

Scanning dependencies of target libzippp
[ 25%] Building CXX object CMakeFiles/libzippp.dir/src/libzippp.cpp.o
[ 50%] Linking CXX static library libzippp_static.a
[ 50%] Built target libzippp
Scanning dependencies of target libzippp_test
[ 75%] Building CXX object CMakeFiles/libzippp_test.dir/tests/tests.cpp.o
[100%] Linking CXX executable libzippp_static_test
[100%] Built target libzippp_test

make install

[ 50%] Built target libzippp
[100%] Built target libzippp_test
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/lib/libzippp_static.a
-- Up-to-date: /usr/local/include/libzippp/libzippp.h
-- Installing: /usr/local/share/libzippp/libzipppConfig.cmake
-- Installing: /usr/local/share/libzippp/libzipppConfigVersion.cmake
-- Up-to-date: /usr/local/share/libzippp/FindLIBZIP.cmake
-- Installing: /usr/local/share/libzippp/libzipppTargets.cmake
-- Installing: /usr/local/share/libzippp/libzipppTargets-noconfig.cmake

My CMakeLists.txt looks like this:

cmake_minimum_required(VERSION 2.8)
project(startProject)
set(Leptonica_DIR /Users/alejandrocamba/Documents/leptonica/build)

list(APPEND CMAKE_PREFIX_PATH "/Users/alejandrocamba/Documents/libzippp/lib/libzip-1.7.1/")
list(APPEND CMAKE_PREFIX_PATH "/Users/alejandrocamba/Documents/libzippp/lib/zlib-1.2.11/")

find_package(OpenCV REQUIRED)
find_package(Leptonica REQUIRED)
find_package(Tesseract REQUIRED)
find_package(libzippp 3.0 REQUIRED)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)

include_directories(${OpenCV_INCLUDE_DIRS})
include_directories(${Leptonica_INCLUDE_DIRS})
include_directories(${Tesseract_INCLUDE_DIRS})

add_executable(startProject main.cpp)
target_link_libraries(startProject PRIVATE libzippp::libzippp)
target_link_libraries(startProject ${OpenCV_LIBS})
target_link_libraries(startProject ${Tesseract_LIBRARIES})

I'm able to import the library but when i try tu run the project i finally get the error:

(/project) make

[ 50%] Building CXX object CMakeFiles/startProject.dir/main.cpp.o
[100%] Linking CXX executable startProject
ld: library not found for -llibzip::libzip
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [startProject] Error 1
make[1]: *** [CMakeFiles/startProject.dir/all] Error 2
make: *** [all] Error 2

I've tried other other solutions i've found on the internet but i can't find a way to install libzip from the repo either, when i go to libzippp/lib/libzip-1.7.1/build and run make install i get

make[2]: *** No rule to make target `/Users/alejandrocamba/Documents/libzippp/lib/zlib-1.2.11/libz.so', needed by `lib/libzip.5.3.dylib'.  Stop.
make[1]: *** [lib/CMakeFiles/zip.dir/all] Error 2
make: *** [all] Error 2
@ctabin
Copy link
Owner

ctabin commented Jul 18, 2020

Hi @AlejandroCamba,

Thanks for the report. Since I don't have any Mac, I'm unable to test it, but since all is pretty standard, it should work fine.
As the messages are pointed out, it seems to be a link problem between libzip and zlib, not sure how libzippp is related to that.
I suggest you try vcpkg to work with CMake. Also, another idea would be to try the compilation of libzip (not libzippp) to see if that works.

At this point, I'm unable to provide any more useful help, so I'm close this issue. If you find some problem in the libzippp configuration, please feel free to submit a PR.

@ctabin ctabin closed this as completed Jul 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants