Open ClayZhang0403 opened 5 years ago
Try use the cmake toolchain
Try use the cmake toolchain
Hi. Can you told me how to use the cmake toolchain ? I tried cmake ~/darknet/ -DCMAKE_TOOLCHAIN_FILE=~/darknet/DarknetConfig.cmake.in
but it's not working ;(
no it's not the right command.
Just go inside the darknet folder and then launch ./build.sh
If you have installed already all the dependencies you should be ready to go. Otherwise just let me know errors and I will tell you more
Thanks, @cenit. This is what I get when running ./build.sh
CMake Warning at /usr/local/Cellar/cmake/3.13.1/share/cmake/Modules/CMakeFindDependencyMacro.cmake:48 (find_package):
By not providing "FindStb.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Stb", but
CMake did not find one.
Could not find a package configuration file provided by "Stb" with any of
the following names:
StbConfig.cmake
stb-config.cmake
Add the installation prefix of "Stb" to CMAKE_PREFIX_PATH or set "Stb_DIR"
to a directory containing one of the above files. If "Stb" provides a
separate development package or SDK, be sure it has been installed.
Call Stack (most recent call first):
DarknetConfig.cmake.in:12 (find_dependency)
CMakeFiles/3.13.1/CMakeSystem.cmake:6 (include)
CMakeLists.txt:17 (project)
CMake Warning at CMakeLists.txt:77 (find_package):
By not providing "FindOpenCV.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "OpenCV", but
CMake did not find one.
Could not find a package configuration file provided by "OpenCV" with any
of the following names:
OpenCVConfig.cmake
opencv-config.cmake
Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set
"OpenCV_DIR" to a directory containing one of the above files. If "OpenCV"
provides a separate development package or SDK, be sure it has been
installed.
CMake Error at /usr/local/Cellar/cmake/3.13.1/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find Stb (missing: Stb_INCLUDE_DIR)
Call Stack (most recent call first):
/usr/local/Cellar/cmake/3.13.1/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
cmake/Modules/FindStb.cmake:29 (find_package_handle_standard_args)
CMakeLists.txt:78 (find_package)
-- Configuring incomplete, errors occurred!
See also "/Users/lamhoangtung/darknet/CMakeFiles/CMakeOutput.log".
See also "/Users/lamhoangtung/darknet/CMakeFiles/CMakeError.log".
Error: could not load cache
usage: cp [-R [-H | -L | -P]] [-fi | -n] [-apvXc] source_file target_file
cp [-R [-H | -L | -P]] [-fi | -n] [-apvXc] source_file ... target_directory
You are missing dependencies, which are easily satisfied with vcpkg
cd /Users/lamhoangtung/
git clone https://github.com/Microsoft/vcpkg.git
echo -e "\n export VCPKG_ROOT=/Users/lamhoangtung/vcpkg/\n" >> ~/.bashrc
source /Users/lamhoangtung/.bashrc
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg install stb opencv
cd ../darknet
./build.sh
otherwise, if you have brew installed, you can use it to install opencv (much quicker because it downloads prebuilt libraries)
brew install opencv
(stb must still come from vcpkg)
@cenit ./build.sh
doesn't use integrated stb
by default?
it doesn't depend on the shell script but to the cmakelists, so yes, you're right, it should pick up integrated stb if it is not already found in the system... 🤔
So this is strange that it can't find Stb.
CMake Error at /usr/local/Cellar/cmake/3.13.1/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:137 (message): Could NOT find Stb (missing: Stb_INCLUDE_DIR)
yes it's strange. In fact I just tried and I can't reproduce it. By default, on a fresh mac laptop, it finds the stb that we include in this repo... If the errors persist, I need more logs from his machine
yes it's strange. In fact I just tried and I can't reproduce it. By default, on a fresh mac laptop, it finds the stb that we include in this repo... If the errors persist, I need more logs from his machine
Willing to help ;)
Here is the log when I use your script @cenit
Cloning into 'vcpkg'...
remote: Enumerating objects: 87, done.
remote: Counting objects: 100% (87/87), done.
remote: Compressing objects: 100% (57/57), done.
remote: Total 56813 (delta 39), reused 55 (delta 30), pack-reused 56726
Receiving objects: 100% (56813/56813), 13.88 MiB | 573.00 KiB/s, done.
Resolving deltas: 100% (36080/36080), done.
/Users/lamhoangtung/.bashrc: line 1: -e: command not found
Downloading cmake...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 621 0 621 0 0 428 0 --:--:-- 0:00:01 --:--:-- 427
100 31.9M 100 31.9M 0 0 458k 0 0:01:11 0:01:11 --:--:-- 362k
Downloading cmake... done.
Extracting cmake...
Extracting cmake... done.
Downloading ninja...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 602 0 602 0 0 414 0 --:--:-- 0:00:01 --:--:-- 414
100 77284 100 77284 0 0 22694 0 0:00:03 0:00:03 --:--:-- 47913
Downloading ninja... done.
Extracting ninja...
Extracting ninja... done.
-- The C compiler identification is AppleClang 10.0.0.10001044
-- The CXX compiler identification is GNU 9.1.0
-- 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
-- Checking whether CXX compiler has -isysroot
-- Checking whether CXX compiler has -isysroot - yes
-- Checking whether CXX compiler supports OSX deployment target flag
-- Checking whether CXX compiler supports OSX deployment target flag - yes
-- Check for working CXX compiler: /usr/local/bin/g++-9
-- Check for working CXX compiler: /usr/local/bin/g++-9 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/lamhoangtung/vcpkg/toolsrc/build.rel
[43/64] Building CXX object CMakeFiles/vcpkg.dir/src/vcpkg/export.cpp.o
In file included from ../include/vcpkg/base/view.h:3,
from ../include/vcpkg/base/strings.h:7,
from ../include/vcpkg/base/checks.h:5,
from ../include/vcpkg/base/expected.h:3,
from ../include/vcpkg/packagespec.h:3,
from ../include/vcpkg/build.h:3,
from ../include/vcpkg/commands.h:3,
from ../src/vcpkg/export.cpp:3:
../include/vcpkg/base/span.h: In instantiation of 'constexpr vcpkg::Span<T>::Span(std::initializer_list<_Tp>) [with T = const vcpkg::Export::handle_export_command_arguments(const vcpkg::VcpkgCmdArguments&, const vcpkg::Triplet&)::OptionPair]':
../src/vcpkg/export.cpp:368:26: required from here
../include/vcpkg/base/span.h:26:97: warning: initializing 'vcpkg::Span<const vcpkg::Export::handle_export_command_arguments(const vcpkg::VcpkgCmdArguments&, const vcpkg::Triplet&)::OptionPair>::m_ptr' from 'std::initializer_list<const vcpkg::Export::handle_export_command_arguments(const vcpkg::VcpkgCmdArguments&, const vcpkg::Triplet&)::OptionPair>::begin' does not extend the lifetime of the underlying array [-Winit-list-lifetime]
26 | constexpr Span(std::initializer_list<T> l) noexcept : m_ptr(l.begin()), m_count(l.size()) {}
| ^
[64/64] Linking CXX executable vcpkg
The following packages will be built and installed:
* eigen3[core]:x64-osx
* libjpeg-turbo[core]:x64-osx
* liblzma[core]:x64-osx
* libpng[core]:x64-osx
opencv[core,eigen,flann,jpeg,opengl,png,tiff]:x64-osx
* opengl[core]:x64-osx
stb[core]:x64-osx
* tiff[core]:x64-osx
* zlib[core]:x64-osx
Additional packages (*) will be modified to complete this operation.
Starting package 1/9: liblzma:x64-osx
Building package liblzma[core]:x64-osx...
-- Downloading https://github.com/xz-mirror/xz/archive/v5.2.4.tar.gz...
-- Extracting source /Users/lamhoangtung/vcpkg/downloads/xz-mirror-xz-v5.2.4.tar.gz
-- Applying patch enable-uwp-builds.patch
-- Using source at /Users/lamhoangtung/vcpkg/buildtrees/liblzma/src/v5.2.4-66bfe33102
-- Configuring x64-osx-dbg
-- Configuring x64-osx-rel
-- Building x64-osx-dbg
-- Building x64-osx-rel
-- Installing: /Users/lamhoangtung/vcpkg/packages/liblzma_x64-osx/share/liblzma/copyright
-- Performing post-build validation
-- Performing post-build validation done
Building package liblzma[core]:x64-osx... done
Installing package liblzma[core]:x64-osx...
Installing package liblzma[core]:x64-osx... done
Elapsed time for package liblzma:x64-osx: 14.45 s
Starting package 2/9: zlib:x64-osx
Building package zlib[core]:x64-osx...
-- Downloading http://www.zlib.net/zlib-1.2.11.tar.gz...
-- Extracting source /Users/lamhoangtung/vcpkg/downloads/zlib1211.tar.gz
-- Applying patch cmake_dont_build_more_than_needed.patch
-- Using source at /Users/lamhoangtung/vcpkg/buildtrees/zlib/src/1.2.11-f690224aeb
-- Configuring x64-osx-dbg
-- Configuring x64-osx-rel
-- Building x64-osx-dbg
-- Building x64-osx-rel
-- Installing: /Users/lamhoangtung/vcpkg/packages/zlib_x64-osx/share/zlib/copyright
-- Performing post-build validation
-- Performing post-build validation done
Building package zlib[core]:x64-osx... done
Installing package zlib[core]:x64-osx...
Installing package zlib[core]:x64-osx... done
Elapsed time for package zlib:x64-osx: 7.96 s
Starting package 3/9: libjpeg-turbo:x64-osx
Building package libjpeg-turbo[core]:x64-osx...
-- Downloading https://github.com/libjpeg-turbo/libjpeg-turbo/archive/2.0.2.tar.gz...
-- Extracting source /Users/lamhoangtung/vcpkg/downloads/libjpeg-turbo-libjpeg-turbo-2.0.2.tar.gz
-- Applying patch add-options-for-exes-docs-headers.patch
-- Applying patch workaround_cmake_system_processor.patch
-- Using source at /Users/lamhoangtung/vcpkg/buildtrees/libjpeg-turbo/src/2.0.2-3c759cce19
-- Configuring x64-osx-dbg
-- Configuring x64-osx-rel
-- Building x64-osx-dbg
-- Building x64-osx-rel
-- Performing post-build validation
-- Performing post-build validation done
Building package libjpeg-turbo[core]:x64-osx... done
Installing package libjpeg-turbo[core]:x64-osx...
Installing package libjpeg-turbo[core]:x64-osx... done
Elapsed time for package libjpeg-turbo:x64-osx: 23.64 s
Starting package 4/9: tiff:x64-osx
Building package tiff[core]:x64-osx...
-- Downloading http://download.osgeo.org/libtiff/tiff-4.0.10.tar.gz...
-- Extracting source /Users/lamhoangtung/vcpkg/downloads/tiff-4.0.10.tar.gz
-- Applying patch fix-stddef.patch
-- Applying patch cmakelists.patch
-- Using source at /Users/lamhoangtung/vcpkg/buildtrees/tiff/src/4.0.10-229dd2f530
-- Configuring x64-osx-dbg
-- Configuring x64-osx-rel
-- Building x64-osx-dbg
-- Building x64-osx-rel
-- Installing: /Users/lamhoangtung/vcpkg/packages/tiff_x64-osx/share/tiff/copyright
-- Performing post-build validation
-- Performing post-build validation done
Building package tiff[core]:x64-osx... done
Installing package tiff[core]:x64-osx...
Installing package tiff[core]:x64-osx... done
Elapsed time for package tiff:x64-osx: 25.76 s
Starting package 5/9: libpng:x64-osx
Building package libpng[core]:x64-osx...
-- Downloading https://github.com/glennrp/libpng/archive/v1.6.37.tar.gz...
-- Extracting source /Users/lamhoangtung/vcpkg/downloads/glennrp-libpng-v1.6.37.tar.gz
-- Applying patch use-abort-on-all-platforms.patch
-- Using source at /Users/lamhoangtung/vcpkg/buildtrees/libpng/src/v1.6.37-802966ac31
-- Configuring x64-osx-dbg
-- Configuring x64-osx-rel
-- Building x64-osx-dbg
-- Building x64-osx-rel
-- Performing post-build validation
-- Performing post-build validation done
Building package libpng[core]:x64-osx... done
Installing package libpng[core]:x64-osx...
Installing package libpng[core]:x64-osx... done
Elapsed time for package libpng:x64-osx: 14.81 s
Starting package 6/9: eigen3:x64-osx
Building package eigen3[core]:x64-osx...
-- Downloading https://github.com/eigenteam/eigen-git-mirror/archive/3.3.7.tar.gz...
-- Extracting source /Users/lamhoangtung/vcpkg/downloads/eigenteam-eigen-git-mirror-3.3.7.tar.gz
-- Using source at /Users/lamhoangtung/vcpkg/buildtrees/eigen3/src/3.3.7-c0bebf7460
-- Configuring x64-osx-dbg
-- Configuring x64-osx-rel
-- Building x64-osx-dbg
-- Building x64-osx-rel
-- Performing post-build validation
-- Performing post-build validation done
Building package eigen3[core]:x64-osx... done
Installing package eigen3[core]:x64-osx...
Installing package eigen3[core]:x64-osx... done
Elapsed time for package eigen3:x64-osx: 28.08 s
Starting package 7/9: stb:x64-osx
Building package stb[core]:x64-osx...
-- Downloading https://github.com/nothings/stb/archive/1034f5e5c4809ea0a7f4387e0cd37c5184de3cdd.tar.gz...
-- Extracting source /Users/lamhoangtung/vcpkg/downloads/nothings-stb-1034f5e5c4809ea0a7f4387e0cd37c5184de3cdd.tar.gz
-- Using source at /Users/lamhoangtung/vcpkg/buildtrees/stb/src/5184de3cdd-ab05218886
-- Performing post-build validation
-- Performing post-build validation done
Building package stb[core]:x64-osx... done
Installing package stb[core]:x64-osx...
Installing package stb[core]:x64-osx... done
Elapsed time for package stb:x64-osx: 9.058 s
Starting package 8/9: opengl:x64-osx
Building package opengl[core]:x64-osx...
-- Performing post-build validation
-- Performing post-build validation done
Building package opengl[core]:x64-osx... done
Installing package opengl[core]:x64-osx...
Installing package opengl[core]:x64-osx... done
Elapsed time for package opengl:x64-osx: 49.77 ms
Starting package 9/9: opencv:x64-osx
Building package opencv[core,eigen,flann,jpeg,opengl,png,tiff]:x64-osx...
-- Downloading https://github.com/opencv/opencv/archive/3.4.3.tar.gz...
-- Extracting source /Users/lamhoangtung/vcpkg/downloads/opencv-opencv-3.4.3.tar.gz
-- Applying patch /Users/lamhoangtung/vcpkg/ports/opencv/0001-winrt-fixes.patch
-- Applying patch /Users/lamhoangtung/vcpkg/ports/opencv/0002-install-options.patch
-- Applying patch /Users/lamhoangtung/vcpkg/ports/opencv/0003-disable-downloading.patch
-- Applying patch /Users/lamhoangtung/vcpkg/ports/opencv/0004-use-find-package-required.patch
-- Applying patch /Users/lamhoangtung/vcpkg/ports/opencv/0005-remove-custom-protobuf-find-package.patch
-- Using source at /Users/lamhoangtung/vcpkg/buildtrees/opencv/src/3.4.3-701a6234df
-- Configuring x64-osx-dbg
-- Configuring x64-osx-rel
-- Building x64-osx-dbg
-- Building x64-osx-rel
-- Performing post-build validation
-- Performing post-build validation done
Building package opencv[core,eigen,flann,jpeg,opengl,png,tiff]:x64-osx... done
Installing package opencv[core,eigen,flann,jpeg,opengl,png,tiff]:x64-osx...
Installing package opencv[core,eigen,flann,jpeg,opengl,png,tiff]:x64-osx... done
Elapsed time for package opencv:x64-osx: 34.76 min
Total elapsed time: 36.82 min
The package opencv provides CMake integration:
find_package(OpenCV REQUIRED)
target_include_directories(main PRIVATE ${OpenCV_INCLUDE_DIRS})
target_link_libraries(main PRIVATE ${OpenCV_LIBS})
CMake Warning at /usr/local/Cellar/cmake/3.13.1/share/cmake/Modules/CMakeFindDependencyMacro.cmake:48 (find_package):
By not providing "FindStb.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Stb", but
CMake did not find one.
Could not find a package configuration file provided by "Stb" with any of
the following names:
StbConfig.cmake
stb-config.cmake
Add the installation prefix of "Stb" to CMAKE_PREFIX_PATH or set "Stb_DIR"
to a directory containing one of the above files. If "Stb" provides a
separate development package or SDK, be sure it has been installed.
Call Stack (most recent call first):
DarknetConfig.cmake.in:12 (find_dependency)
CMakeFiles/3.13.1/CMakeSystem.cmake:6 (include)
CMakeLists.txt:17 (project)
CMake Warning at CMakeLists.txt:77 (find_package):
By not providing "FindOpenCV.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "OpenCV", but
CMake did not find one.
Could not find a package configuration file provided by "OpenCV" with any
of the following names:
OpenCVConfig.cmake
opencv-config.cmake
Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set
"OpenCV_DIR" to a directory containing one of the above files. If "OpenCV"
provides a separate development package or SDK, be sure it has been
installed.
CMake Error at /usr/local/Cellar/cmake/3.13.1/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find Stb (missing: Stb_INCLUDE_DIR)
Call Stack (most recent call first):
/usr/local/Cellar/cmake/3.13.1/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
cmake/Modules/FindStb.cmake:29 (find_package_handle_standard_args)
CMakeLists.txt:78 (find_package)
-- Configuring incomplete, errors occurred!
See also "/Users/lamhoangtung/darknet/CMakeFiles/CMakeOutput.log".
See also "/Users/lamhoangtung/darknet/CMakeFiles/CMakeError.log".
Error: could not load cache
usage: cp [-R [-H | -L | -P]] [-fi | -n] [-apvXc] source_file target_file
After reinstall opencv with brew, I ran ./build.sh
and face this issue:
CMake Warning at /usr/local/Cellar/cmake/3.13.1/share/cmake/Modules/CMakeFindDependencyMacro.cmake:48 (find_package):
By not providing "FindStb.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Stb", but
CMake did not find one.
Could not find a package configuration file provided by "Stb" with any of
the following names:
StbConfig.cmake
stb-config.cmake
Add the installation prefix of "Stb" to CMAKE_PREFIX_PATH or set "Stb_DIR"
to a directory containing one of the above files. If "Stb" provides a
separate development package or SDK, be sure it has been installed.
Call Stack (most recent call first):
DarknetConfig.cmake.in:12 (find_dependency)
CMakeFiles/3.13.1/CMakeSystem.cmake:6 (include)
CMakeLists.txt:17 (project)
CMake Error at /usr/local/Cellar/cmake/3.13.1/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find Stb (missing: Stb_INCLUDE_DIR)
Call Stack (most recent call first):
/usr/local/Cellar/cmake/3.13.1/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
cmake/Modules/FindStb.cmake:29 (find_package_handle_standard_args)
CMakeLists.txt:78 (find_package)
-- Configuring incomplete, errors occurred!
See also "/Users/lamhoangtung/darknet/CMakeFiles/CMakeOutput.log".
See also "/Users/lamhoangtung/darknet/CMakeFiles/CMakeError.log".
Error: could not load cache
usage: cp [-R [-H | -L | -P]] [-fi | -n] [-apvXc] source_file target_file
cp [-R [-H | -L | -P]] [-fi | -n] [-apvXc] source_file ... target_directory
I believe the simplest way to compile on MacOS is to modify Makefile
:
https://github.com/AlexeyAB/darknet/blob/3ff27b1cdd4580e6e9346bd7a2c63bde3498a2e3/Makefile#L139
just modify -l:$(LIBNAMESO)
to -l$(EXEC)
can solve this problem.
-l$(EXEC)
Seem likes it's working, thanks a lot
-l$(EXEC)
Thanks a lot! It works for me
Hi, AlexyAB, This error occurred when I ran make on MAC for compilation. I wonder if this is a system or something? I changed the LIBSO to LIBSO = 1 in Makefile
ld: library not found for -l:libdarknet.so clang: fatal error: linker command failed with exit code 1 (use -v to see invocation) make: *** [uselib] Error 1