I having trouble integrating vcpkg package manager with CMake project on Linux. I want to use the doctest library in my project but the same problem exists with other packages too. I performed the following steps.
$ vcpkg install doctest
Computing installation plan...
The following packages will be built and installed:
doctest[core]:x64-linux -> 2.4.9
Detecting compiler hash for triplet "x64-linux"...
Restored 1 packages from /home/bobeff/.cache/vcpkg/archives in 7.67 ms. Use --debug to see more details.
Installing 1/1 doctest:x64-linux...
Elapsed time to handle doctest:x64-linux: 2.183 ms
Total elapsed time: 390 ms
doctest provides CMake targets:
# this is heuristically generated, and may not be correct
find_package(doctest CONFIG REQUIRED)
target_link_libraries(main PRIVATE doctest::doctest)
$ vcpkg integrate install
Applied user-wide integration for this vcpkg root.
CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=/home/bobeff/projects/cpp/vcpkg/scripts/buildsystems/vcpkg.cmake"
I have a vcpkg.json file in the root directory of my project with the following content:
{
"name": "cpp-programming-language",
"version-string": "0.1.0",
"dependencies": [
"doctest"
]
}
$ cmake ../cpp_programming_language/ -DCMAKE_TOOLCHAIN_FILE=/home/bobeff/projects/cpp/vcpkg/scripts/buildsystems/vcpkg.cmake
The last command is giving me the following output:
CMake Error at CMakeLists.txt:7 (find_package):
Could not find a package configuration file provided by "doctest" with any
of the following names:
doctestConfig.cmake
doctest-config.cmake
Add the installation prefix of "doctest" to CMAKE_PREFIX_PATH or set
"doctest_DIR" to a directory containing one of the above files. If
"doctest" provides a separate development package or SDK, be sure it has
been installed.
-- Configuring incomplete, errors occurred!
See also "/home/bobeff/projects/cpp/temp/CMakeFiles/CMakeOutput.log".
When I perform the search for the not found files from the configure error message I have the following output:
$ locate doctestConfig.cmake
/home/bobeff/projects/cpp/vcpkg/buildtrees/doctest/x64-linux-dbg/generated/doctestConfig.cmake
/home/bobeff/projects/cpp/vcpkg/buildtrees/doctest/x64-linux-rel/generated/doctestConfig.cmake
/home/bobeff/projects/cpp/vcpkg/installed/x64-linux/share/doctest/doctestConfig.cmake
/home/bobeff/projects/cpp/vcpkg/packages/doctest_x64-linux/share/doctest/doctestConfig.cmake
Used versions of the programs are as follows:
CMake
$ cmake --version
cmake version 3.16.3
vcpkg
$ vcpkg --version
vcpkg package management program version 2022-06-17-9268e366206712e38102b28dbd1617697a99ff2e
Linux
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.4 LTS
Release: 20.04
Codename: focal
I'm trying to build a C++ "Plug-in" that is part of "Orthanc" (Open Source Project). I've been doing that on both UBUNTU and OS X, but I'm having trouble using a version of Python other than the system installed version (High Sierra, Python 2.7) on OS X. I've tried installing Python 3.8 using the OS X package from the Python website and also using HomeBrew. I'm not real familiar with compiling stuff of OS X, but a little better on UNIX.
The CMakeLists.txt file is fairly long, but the relevant parts are probably:
if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
# The Python version cannot be controlled on OS X (yet)
set(PYTHON_VERSION "3.6" CACHE STRING "Version of Python to be used")
endif()
if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
find_package(PythonLibs)
if (NOT PYTHONLIBS_FOUND)
message(FATAL_ERROR "Cannot find the Python libraries")
endif()
message("Python library - Found version: ${PYTHONLIBS_VERSION_STRING}")
message("Python library - Path to include directory: ${PYTHON_INCLUDE_DIRS}")
message("Python library - Shared library: ${PYTHON_LIBRARIES}")
In the actual build there are a few lines of output about Python. The CLI for the build is:
cmake -DPYTHON_VERSION=3.8 -DSTATIC_BUILD=ON -DCMAKE_BUILD_TYPE=Release ../
although I've tried various things for the 3.8, but it always defaults back to 2.7.
-- Found PythonInterp: /usr/bin/python (found version "2.7.16")
-- Found PythonLibs: /usr/lib/libpython2.7.dylib (found version "2.7.16")
Python library - Found version: 2.7.16
Python library - Path to include directory: /usr/include/python2.7
Python library - Shared library: /usr/lib/libpython2.7.dylib
-- Configuring done
CMake Warning (dev):
Policy CMP0042 is not set: MACOSX_RPATH is enabled by default. Run "cmake
--help-policy CMP0042" for policy details. Use the cmake_policy command to
set the policy and suppress this warning.
MACOSX_RPATH is not specified for the following targets:
My .bash_profile is probably messed up, but this is the most recent version. I have installed both the 3.8 version using brew and the version from the .pkg on the Python website.
source ~/.profile
export NVM_DIR="/Users/sscotti/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
export PATH="/usr/local/bin:$PATH"
export PATH="/usr/local/sbin:$PATH"
# The version installed with HomeBrew
# export PATH="/usr/local/Cellar/python#3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/Cellar/python#3.8/3.8.5/bin:$PATH"
# The version installed with OS X installer
# Setting PATH for Python 3.8
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.8/bin:${PATH}"
##
# Homebrew bash completion
##
if [ -f $(brew --prefix)/etc/bash_completion ]; then
source $(brew --prefix)/etc/bash_completion
fi
Seems that maybe:
find_package(PythonLibs)
is not finding my other version of Python ?
Any suggestions appreciated.
Just getting started with Python, and it is a little confusing about how to set up a couple of different version of Python for development purposes. I don't know if the brew or .pkg version of Python have the "dev packages" included.
Just a follow up to my question. I found that if I explicitly defined that paths for -DPYTHON_LIBRARY= and -DPYTHON_INCLUDE_DIR in the cmake, then it compiles fine and I can use various versions of Python on OS X if I want. I would imagine there is another more elegant way, but this works pretty well.
cmake -DPYTHON_LIBRARY=/usr/local/Cellar/python#3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/libpython3.8.dylib -DPYTHON_INCLUDE_DIR=/usr/local/Cellar/python#3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/include/python3.8/ -DPYTHON_VERSION=3.8 -DSTATIC_BUILD=ON -DCMAKE_BUILD_TYPE=Release ../
Hi I'm trying to use opencv in my Node.js project so I decided to use opencv4nodejs. I tried to install this module by npm and i discovered some errors related to absence of cmake on my computer. So I decided to install cmake by brew. But after this process when I'm trying to install this module the following errors occurs:
MacBook-Air-Micha:webcam-myidea michalkukielka$ npm install opencv4nodejs
> opencv-build#0.1.8 install /Users/michalkukielka/Documents/webcam-myidea/node_modules/opencv-build
> node ./install.js
info No package.json in folder.
info install if you want to use an own OpenCV installation set OPENCV4NODEJS_DISABLE_AUTOBUILD
info readAutoBuildFile file does not exists: /Users/michalkukielka/Documents/webcam-myidea/node_modules/opencv-build/opencv/auto-build.json /Users/michalkukielka/Documents/webcam-myidea/node_modules/opencv-build/opencv/auto-build.json
info install failed to find auto-build.json: /Users/michalkukielka/Documents/webcam-myidea/node_modules/opencv-build/opencv/auto-build.json
info install
info install running install script...
info install
info install opencv version: 3.4.6
info install with opencv contrib: yes
info install custom build flags:
info install
info install executing: git --version
info install git --version: git version 2.20.1
info install
info install executing: cmake --version
info install cmake --version: cmake version 3.15.3
info install
info install CMake suite maintained and supported by Kitware (kitware.com/cmake).
info install
info install installing opencv version 3.4.6 into directory: /Users/michalkukielka/Documents/webcam-myidea/node_modules/opencv-build/opencv
Cloning into 'opencv_contrib'...
remote: Enumerating objects: 2160, done.
remote: Counting objects: 100% (2160/2160), done.
remote: Compressing objects: 100% (1916/1916), done.
remote: Total 2160 (delta 365), reused 1101 (delta 134), pack-reused 0
Receiving objects: 100% (2160/2160), 50.82 MiB | 1.57 MiB/s, done.
Resolving deltas: 100% (365/365), done.
Note: checking out 'f26c98365da6af93cb5e49397b571190fca7bb55'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch-name>
Checking out files: 100% (1780/1780), done.
Cloning into 'opencv'...
remote: Enumerating objects: 7328, done.
remote: Counting objects: 100% (7328/7328), done.
remote: Compressing objects: 100% (6260/6260), done.
remote: Total 7328 (delta 1166), reused 3907 (delta 692), pack-reused 0
Receiving objects: 100% (7328/7328), 81.33 MiB | 1.62 MiB/s, done.
Resolving deltas: 100% (1166/1166), done.
Note: checking out '33b765d7979fd8a6038026aa44f6ff1a9c082b7b'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch-name>
Checking out files: 100% (6080/6080), done.
info install running cmake /Users/michalkukielka/Documents/webcam-myidea/node_modules/opencv-build/opencv/opencv,-DCMAKE_INSTALL_PREFIX=/Users/michalkukielka/Documents/webcam-myidea/node_modules/opencv-build/opencv/build,-DCMAKE_BUILD_TYPE=Release,-DBUILD_EXAMPLES=OFF,-DBUILD_DOCS=OFF,-DBUILD_TESTS=OFF,-DBUILD_PERF_TESTS=OFF,-DBUILD_JAVA=OFF,-DCUDA_NVCC_FLAGS=--expt-relaxed-constexpr,-DBUILD_opencv_apps=OFF,-DBUILD_opencv_aruco=OFF,-DBUILD_opencv_bgsegm=OFF,-DBUILD_opencv_bioinspired=OFF,-DBUILD_opencv_ccalib=OFF,-DBUILD_opencv_datasets=OFF,-DBUILD_opencv_dnn_objdetect=OFF,-DBUILD_opencv_dpm=OFF,-DBUILD_opencv_fuzzy=OFF,-DBUILD_opencv_hfs=OFF,-DBUILD_opencv_java_bindings_generator=OFF,-DBUILD_opencv_js=OFF,-DBUILD_opencv_img_hash=OFF,-DBUILD_opencv_line_descriptor=OFF,-DBUILD_opencv_optflow=OFF,-DBUILD_opencv_phase_unwrapping=OFF,-DBUILD_opencv_python3=OFF,-DBUILD_opencv_python_bindings_generator=OFF,-DBUILD_opencv_reg=OFF,-DBUILD_opencv_rgbd=OFF,-DBUILD_opencv_saliency=OFF,-DBUILD_opencv_shape=OFF,-DBUILD_opencv_stereo=OFF,-DBUILD_opencv_stitching=OFF,-DBUILD_opencv_structured_light=OFF,-DBUILD_opencv_superres=OFF,-DBUILD_opencv_surface_matching=OFF,-DBUILD_opencv_ts=OFF,-DBUILD_opencv_xobjdetect=OFF,-DBUILD_opencv_xphoto=OFF,-DWITH_VTK=OFF,-DOPENCV_ENABLE_NONFREE=ON,-DOPENCV_EXTRA_MODULES_PATH=/Users/michalkukielka/Documents/webcam-myidea/node_modules/opencv-build/opencv/opencv_contrib/modules
-- The CXX compiler identification is unknown
-- The C compiler identification is unknown
-- 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 - failed
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
CMake Error at CMakeLists.txt:153 (message):
CMake fails to determine the bitness of the target platform.
Please check your CMake and compiler installation. If you are cross-compiling then ensure that your CMake toolchain file correctly sets the compiler details.
-- Configuring incomplete, errors occurred!
See also "/Users/michalkukielka/Documents/webcam-myidea/node_modules/opencv-build/opencv/build/CMakeFiles/CMakeOutput.log".
See also "/Users/michalkukielka/Documents/webcam-myidea/node_modules/opencv-build/opencv/build/CMakeFiles/CMakeError.log".
ERR! child process exited with code 1 (for more info, set '--loglevel silly')
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! opencv-build#0.1.8 install: `node ./install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the opencv-build#0.1.8 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/michalkukielka/.npm/_logs/2019-09-07T05_38_02_479Z-debug.log
As I understand there are some new problems with cmake but I cant find solutions for.
Could you help me finish the proces of installation opencv4nodejs?
At the first: Native node modules are built via node-gyp, which already comes with npm by default. However, node-gyp requires you to have python installed. If you are running into node-gyp specific issues have a look at known issues with node-gyp first.
Important note: node-gyp won't handle whitespaces properly, thus make sure, that the path to your project directory does not contain any whitespaces. Installing opencv4nodejs under "C:\Program Files\some_dir" or similar will not work and will fail with: "fatal error C1083: Cannot open include file: 'opencv2/core.hpp'"!**
On Windows you will furthermore need Windows Build Tools to compile OpenCV and opencv4nodejs. If you don't have Visual Studio or Windows Build Tools installed, you can easily install the VS2015 build tools:
npm install --global windows-build-tools
At the second: You should check CMake and compiler installation. If you are cross-compiling then ensure that your CMake toolchain file correctly sets the compiler details.
CMake doesn't (always) listen to CC and CXX. Instead use CMAKE_C_COMPILER and CMAKE_CXX_COMPILER:
cmake -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ ...
See also the documentation.
Alternatively, you can provide a toolchain file, but that might be overkill in this case.
finally: Under OSX we can simply install OpenCV via brew:
brew update
brew install opencv#4
brew link --force opencv#4
I was trying to build flann from source in Windows-10 using cmake. During the installation process it says it cannot find liblz4.
I tried two method :
1) So I downloaded the prebuild lz4 from here (https://github.com/lz4/lz4/releases) and placed the C:\XXXX\Downloads\lz4_v1_9_1_win64\dll to my env path.
2) I used vcpkg to install lz4 first. Then did
C:\source\flann\build> cmake .. -DCMAKE_TOOLCHAIN_FILE=C:\XXXXXX\source\vcpkg\scripts\buildsystems\vcpkg.cmake -G "Visual Studio 15 2017 Win64".
None of the above two method worked. I still get cannot find liblz4 error.
-- Found PkgConfig: C:/XXXXXX/Downloads/cmake-3.13.3-win64-x64/bin/pkg-config.exe (found version "0.26") -- Checking for module 'liblz4' -- No package 'liblz4' found CMake Error at C:/Program Files/CMake/share/cmake-3.13/Modules/FindPkgConfig.cmake:452 (message): A required package was not found Call Stack (most recent call first): C:/Program Files/CMake/share/cmake-3.13/Modules/FindPkgConfig.cmake:622 (_pkg_check_modules_internal) CMakeLists.txt:150 (pkg_check_modules) -- Configuring incomplete, errors occurred! See also "C:/XXXXXXX/source/flann/build/CMakeFiles/CMakeOutput.log".
Did you try to do as follows?(https://github.com/lz4/lz4)
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
vcpkg install lz4
I want to setup connector/c++ on my raspberry Pi to access a mysql db. At first I tried:
sudo apt-get install libmysqlcppconn-dev
which installed successfully, but the I got the error:
ERR: MySQL_Connection::setReadOnly() (MySQL error code: 0, SQLState: )
which comes with the version of cppconn I'm using, as its said here: MySQL Connector for C++ | MySQL_Connection::setReadOnly() exception on setSchema
And when I checked:
sudo apt-cache show libmysqlcppconn-dev
it said "version: 1.1.0-4"
So then I tried to install the latest package from source:
https://dev.mysql.com/downloads/connector/cpp/ which was under ->Source Code -> Generic Linux (Architecture Independent), Compressed TAR Archive
I downloaded it and did "tar xvzf mysql-...." and everything worked. But when I tried to build it with
cmake .
I got the error:
CMake Warning (dev) in CMakeLists.txt:
Syntax Warning in cmake code at
/home/pi/quadro/mysql-connector/CMakeLists.txt:114:24
Argument not separated from preceding token by whitespace.
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Warning (dev) in CMakeLists.txt:
Syntax Warning in cmake code at
/home/pi/quadro/mysql-connector/CMakeLists.txt:114:54
Argument not separated from preceding token by whitespace.
This warning is for project developers. Use -Wno-dev to suppress it.
-- mysql_config was found /etc/mysql
CMake Error at FindMySQL.cm:165 (MESSAGE):
mysql_config wasn't found, -DMYSQL_CONFIG_EXECUTABLE=...
Call Stack (most recent call first):
CMakeLists.txt:55 (INCLUDE)
CMake Error at FindMySQL.cm:167 (MESSAGE):
Cannot find MySQL. Include dir: MYSQL_INCLUDE_DIR-NOTFOUND library dir:
cxxflags:
Call Stack (most recent call first):
CMakeLists.txt:55 (INCLUDE)
-- Configuring incomplete, errors occurred!
See also "/home/pi/quadro/mysql-connector/CMakeFiles/CMakeOutput.log".
I know it means, it cant find the mysql_config, but neither do I know how to tell it where the file is, nor where the file actually is.
So please help me. I'm so sick of this.
Thanks alot.
EDIT:
I tried to install the latest packages manually, which I downloaded from:
https://packages.debian.org/jessie/armhf/libmysqlcppconn-dev/download
sudo dpkg -i libmysqlcppconn7_1.1.3-6_armhf.deb
sudo dpkg -i libmysqlcppconn-dev_1.1.3-6_armhf.deb
And now I get:
$ sudo apt-cache show libmysqlcppconn-dev
Package: libmysqlcppconn-dev
Status: install ok installed
Priority: optional
Section: libdevel
Installed-Size: 3213
Maintainer: Debian MySQL Maintainers <pkg-mysql- maint#lists.alioth.debian.org>
Architecture: armhf
Source: mysql-connector-c++
Version: 1.1.3-6
Depends: libboost-dev, libmysqlcppconn7 (= 1.1.3-6)
Description: MySQL Connector for C++ (development files)
MySQL Connector/C++ is a MySQL database connector for C++.
.
It mimics the JDBC 4.0 API.
.
This package contains the development files (headers, static library).
Package: libmysqlcppconn-dev
Source: mysql-connector-c++
Version: 1.1.0-4
Architecture: armhf
Maintainer: Debian MySQL Maintainers <pkg-mysql- maint#lists.alioth.debian.org>
Installed-Size: 3382
Depends: libboost-dev, libmysqlcppconn5 (= 1.1.0-4)
Homepage: http://forge.mysql.com/wiki/Connector_C++
Priority: optional
Section: libdevel
Filename: pool/main/m/mysql-connector-c++/libmysqlcppconn-dev_1.1.0- 4_armhf.deb
Size: 602550
SHA256: 286b6bf2ef3eb05dc8660a31780dd9af65c06f7d0d675257636281b2de056e15
SHA1: e53eeb1cf70c7522f557bbb6cbf0a753c6788fbb
MD5sum: 8770d029c21d086a48279c1f6e92f4a6
Description: MySQL Connector for C++ (development files)
MySQL Connector/C++ is a MySQL database connector for C++.
.
It mimics the JDBC 4.0 API.
.
This package contains the development files (headers, static library).
Is this good or bad?
You need to install the MySQL client library development files:
apt-get install libmysqlclient-dev
An easier way to try and ensure you have all dependencies installed, is to ask apt to install all build dependencies for it's packaged version:
apt-get build-dep libmysqlcppconn-dev
The libmysqlclient-dev package doesn't exist anymore. I guess it was renamed. So to install the c++ connector there is this new package:
sudo apt install libmysql++-dev