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 install fails for static library build #215

Open
msakai opened this issue Feb 7, 2019 · 1 comment
Open

make install fails for static library build #215

msakai opened this issue Feb 7, 2019 · 1 comment

Comments

@msakai
Copy link
Member

msakai commented Feb 7, 2019

If -DBUILD_SHARED_LIBS=OFF is specified, make install fails with following error:

$ cmake .. -DBUILD_SHARED_LIBS=OFF -DENABLE_TEST=OFF -DENABLE_EXAMPLE=ON && make
-- The C compiler identification is AppleClang 10.0.0.10001044
-- The CXX compiler identification is AppleClang 10.0.0.10001044
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc
-- Check for working C compiler: /Library/Developer/CommandLineTools/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: /Library/Developer/CommandLineTools/usr/bin/c++
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- CMAKE_BUILD_TYPE is unset, defaulting to Release
-- Build type: Release
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE  
-- Found Protobuf: /usr/local/lib/libprotobuf.dylib (found version "3.6.1") 
-- Found Git: /usr/bin/git (found version "2.17.2 (Apple Git-113)") 
-- Adding external/onnx
fatal: /Users/sakai/menoh/external/onnx: '/Users/sakai/menoh/external/onnx' is outside repository
-- 
-- ******** Summary ********
--   CMake version         : 3.12.4
--   CMake command         : /usr/local/Cellar/cmake/3.12.4/bin/cmake
--   System                : Darwin
--   C++ compiler          : /Library/Developer/CommandLineTools/usr/bin/c++
--   C++ compiler version  : 10.0.0.10001044
--   CXX flags             :  -Wnon-virtual-dtor
--   Build type            : Release
--   Compile definitions   : 
--   CMAKE_PREFIX_PATH     : 
--   CMAKE_INSTALL_PREFIX  : /usr/local
--   CMAKE_MODULE_PATH     : /Users/sakai/menoh/cmake
-- 
--   ONNX version          : 1.4.1
--   ONNX NAMESPACE        : menoh_onnx
--   ONNX_BUILD_TESTS      : OFF
--   ONNX_BUILD_BENCHMARKS : OFF
--   ONNX_USE_LITE_PROTO   : OFF
--   ONNXIFI_DUMMY_BACKEND : OFF
-- 
--   Protobuf compiler     : /usr/local/bin/protoc
--   Protobuf includes     : /usr/local/include
--   Protobuf libraries    : /usr/local/lib/libprotobuf.dylib
--   BUILD_ONNX_PYTHON     : OFF
-- Adding benchmark
-- Adding example
-- Found OpenCV: /usr/local (found version "3.4.3") 
-- Adding menoh
-- Found MKLDNN: /usr/local/lib/libmkldnn.dylib (Required is at least version "0.14") 
-- Adding include
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/sakai/menoh/build
Scanning dependencies of target gen_onnx_proto
[  1%] Running gen_proto.py on onnx/onnx.in.proto
Processing /Users/sakai/menoh/external/onnx/onnx/onnx.in.proto
Writing /Users/sakai/menoh/build/external/onnx/onnx/onnx_menoh_onnx.proto
Writing /Users/sakai/menoh/build/external/onnx/onnx/onnx_menoh_onnx.proto3
Writing /Users/sakai/menoh/build/external/onnx/onnx/onnx.pb.h
generating /Users/sakai/menoh/build/external/onnx/onnx/onnx_pb.py
..(snip)..
bash-3.2$ make install
[  2%] Built target gen_onnx_proto
[ 35%] Built target menoh_objlib
[ 44%] Built target onnx_proto
[ 88%] Built target onnx
[ 89%] Built target menoh
[ 91%] Built target vgg16_benchmark
[ 94%] Built target general_cnn_example_in_cpp
[ 96%] Built target mkldnn_vgg16_example_in_cpp
[ 98%] Built target mkldnn_vgg16_example_in_c
[100%] Built target menoh_test_target
Install the project...
-- Install configuration: "Release"
CMake Error at cmake_install.cmake:36 (file):
  file INSTALL cannot find "/Users/sakai/menoh/MENOH_ONNX_LIB-NOTFOUND".


make: *** [install] Error 1

I think this is because libmenoh_onnx.a and libmenoh_onnx_proto.a are not built yet when find_library is executed.

menoh/CMakeLists.txt

Lines 104 to 115 in d07eebb

set(BUILD_SHARED_LIBS_SAVED "${BUILD_SHARED_LIBS}")
set(BUILD_SHARED_LIBS OFF)
set(ONNX_NAMESPACE "menoh_onnx" CACHE INTERNAL "onnx namespace")
add_subdirectory(${EXTERNAL_DIR}/onnx EXCLUDE_FROM_ALL) # Note: BUILD_SHARED_LIBS must be OFF in this place
if(NOT ${BUILD_SHARED_LIBS_SAVED}) # install libmenoh_onnx and lib_menoh_onnx_proto
set_target_properties(onnx_proto PROPERTIES OUTPUT_NAME "menoh_onnx_proto")
set_target_properties(onnx PROPERTIES OUTPUT_NAME "menoh_onnx")
find_library(MENOH_ONNX_PROTO_LIB "menoh_onnx_proto" "${CMAKE_CURRENT_BINARY_DIR}/external/onnx")
find_library(MENOH_ONNX_LIB "menoh_onnx" "${CMAKE_CURRENT_BINARY_DIR}/external/onnx")
install(FILES "${MENOH_ONNX_LIB}" "${MENOH_ONNX_PROTO_LIB}" DESTINATION "lib")
endif()
set(BUILD_SHARED_LIBS "${BUILD_SHARED_LIBS_SAVED}")

@okdshin
Copy link
Contributor

okdshin commented Feb 7, 2019

I see. I'll try to modify.

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