I am trying to use Pybind11 in a Cmake project. I'm using Cmake 3.23.0-rc2.
To include it, I can do the following:
find_package(pybind11 REQUIRED)
However, this does not work on my machine. So, I attempted to give find_package a hint as per the user guide:
SET(pybind11_DIR, "C:/Users/tyler.shellberg/AppData/Local/Programs/Python/Python37/Lib/site-packages/pybind11")
That did not work either. The Cmake error suggested it may need to be the specific location of files like pybind11Config.cmake. So, I tried being more specific:
SET(pybind11_DIR, "C:/Users/tyler.shellberg/AppData/Local/Programs/Python/Python37/Lib/site-packages/pybind11/share/cmake/pybind11")
That doesn't work either. I get the exact same error in Cmake:
CMake Error at lib/(our project name)/CMakeLists.txt:30 (find_package):
By not providing "Findpybind11.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "pybind11",
but CMake did not find one.
Could not find a package configuration file provided by "pybind11" with any
of the following names:
pybind11Config.cmake
pybind11-config.cmake
Add the installation prefix of "pybind11" to CMAKE_PREFIX_PATH or set
"pybind11_DIR" to a directory containing one of the above files. If
"pybind11" provides a separate development package or SDK, be sure it has
been installed.
I double checked, Python itself is being found:
Python_FOUND:TRUE
Python_VERSION:3.7.4
Python_Development_FOUND:TRUE
Python_LIBRARIES:C:/Users/tyler.shellberg/AppData/Local/Programs/Python/Python37/libs/python37.lib
Python_INCLUDE_DIRS:
(Though weirdly, include_dirs is empty)
What am I doing wrong?
One way is to find Python3 first and then use the sitelib as a hint:
find_package(Python3 REQUIRED)
find_package(pybind11 REQUIRED HINTS "${Python3_SITELIB}")
pip install "pybind11[global]" fixed it. It may not be recommended, but it works. Found the recommendation from here: How to make cmake find pybind11
Related
after I successfully set up my gcc/g++ environment under my Linux installation, I decided to do that for my Windows 11 machine as well. For that purpose I decided to use MSYS2. With the help of that handy tool I quickly installed MinGW as well as corresponding libraries.
One library which gives me headache (under Windows) is pkg-config. But before the installation of pkg-config, I installed gtk-3.0 first. I just installed it with the following command:
pacman -S mingw-w64-x86_64-gtk3
After that I installed pkg-config with the following command:
pacman -S mingw-w64-x86_64-pkg-config
After that, I tried to get all include and library flags for gtk3:
pkg-config --cflags gtk+-3.0
However after entering that command, the following error message occurs:
Perhaps you should add the directory containing `gtk+-3.0.pc'
to the PKG_CONFIG_PATH environment variable
Package 'gtk+-3.0', required by 'virtual:world', not found
The thing is that this exact command works like a charm under my Linux installation but somehow pkg-config can't find the package in the pkg-config search path. Why is that the case? Is that a known problem within the MSYS2 environment?
I would appreciate every tip I can get from you.
Thank you in advance!
EDIT: It looks like I just had to start the MinGW64 shell and not the one from MSYS2. Within that environment the files can be found and no error will occur. Thanks #HolyBlackCat!
The following answer is outdated, written in italic style and shouldn't be followed.
I just solved it by myself. I found out that I had to copy all .pc files from msys64\mingw64\lib\pkgconfig to the path I get from echoing PKG_CONFIG_PATH:
echo $PKG_CONFIG_PATH
gives me
/usr/lib/pkgconfig:/usr/share/pkgconfig:/lib/pkgconfig
So I just copied the files to /usr/lib/pkgconfig - problem solved!
Thank you anyway! :)
I have cloned "https://gitlab.gnome.org/GNOME/msitools/-/tree/v0.100" in my Centos7 host and trying to build, but facing following error and even though required package is already installed, it still doesn't work.
Below is the error I am getting when tried to build the code using the "autogen.sh" in the code base.
Error:
Checking for GSF... no configure: error: Package requirements (libgsf-1) were not met: No package 'libgsf-1' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables GSF_CFLAGS
and GSF_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
But the issue is I have the libgsf rpm already installed
[meuser#localhost msitools]$ rpm -qa | grep libgsf
libgsf-1.14.26-7.el7.x86_64
Thanks in advance for the help !
When building software on top of another package, you should install the development package, which will contain the necessary stuff like include headers, pkg-config files (which it's looking for here) and others.
CentOS/Fedora in general denote development packages by adding a "-devel" suffix, which is also the case here. So the package you're looking for is libgsf-devel
If there a relatively simple way to make go + libxml2 + gokogiri work on windows?
I mean that I may be can install it (but at the moment I can not, stuck with Package libxml-2.0 was not found in the pkg-config search path), but then I need to provide my utilite to other people, who will never be able (or would wish ) to install lall libxml2 dependencies, modify PATH etc on windows...
It work flawless on Ubuntu...
I found this https://github.com/moovweb/gokogiri/issues/49 thats funny with installation of Gimp 2 (what?!), but I still cannot make it run with such error, I guess might be issue with PATH, but all PATH are set
$ go get github.com/moovweb/gokogiri
# github.com/moovweb/gokogiri/help
Documents\go\src\github.com\moovweb\gokogiri\help\help.go:6:25: fatal error: lib
xml/tree.h: No such file or directory
#include <libxml/tree.h>
^
compilation terminated.
# github.com/moovweb/gokogiri/xpath
Documents\go\src\github.com\moovweb\gokogiri\xpath\expression.go:4:26: fatal err
or: libxml/xpath.h: No such file or directory
#include <libxml/xpath.h>
^
compilation terminated.
You are struggling because it is hard to combine packages that were built by different people for different purposes and get your environment set up correctly. I think it is best to use MSYS2, an environment for Windows that provides a consistent set of packages for things like gcc, go, libxml2, and iconv. MSYS2 has a package manager (pacman) that helps you easily install them and keep them updated.
I don't do much programming with Go, but I am familiar with MSYS2 and it seems like I was able to get gokogiri installed using MSYS2. You should open MSYS2's "MinGW-w64 Win64 Shell" from the Start menu (mingw64_shell.bat), and try running these commands:
pacman -S mingw-w64-x86_64-{gcc,go,libxml2,iconv}
export GOROOT=/mingw64/
export GOPATH=/c/Users/David/Documents/goproj/
mkdir -p $GOPATH
go get github.com/moovweb/gokogiri
I think GOPATH should be set to the directory of your project. If you run into an error, it might be because some pacman package is required that I didn't list here.
The string mingw-w64-x86_64-{gcc,go,libxml2,iconv} gets expanded by Bash into the following list of packages:
mingw-w64-x86_64-gcc
mingw-w64-x86_64-go
mingw-w64-x86_64-libxml2
mingw-w64-x86_64-iconv
If you are actually using 32-bit Windows, replace x86_64 with i686 in the instructions above.
If you are curious, the scripts for building those packages are here: https://github.com/Alexpux/MINGW-packages
As a disclaimer, I haven't actually compiled any go programs in MSYS2, so there could be big problems I am unaware of.
Also, one of the main developers of MSYS2 (alexpux) said this in the #msys2 IRC chat on 2015-06-21:
We not build go for a long time.
This package in very WIP state
Also see
https://github.com/Alexpux/MINGW-packages/issues/421
So you might need to fix some issues with the MSYS2 Go package and recompile it yourself to really make this work. But you have the PKGBUILD script that was used to build it, so maybe that will be less hard than what you are trying to do right now, which involves compiling/collecting every dependency of gokogiri.
MSYS2 would make your other installation of go, libxml2, and iconv obsolete. You can delete those things once you get your MSYS2 environment working.
If you are using visual studio and want to add dependency to your project then just install it using NuGet Package Manager it's easiest method.
Install command: Install-Package libxml2
I'm building the latest github version of rstudio-server to run on OSX Yosemite, but can't get it to find the macports R libraries when installing.
I run into a "Minimum R version (2.11.1) not found." error when I run
cmake -DRSTUDIO_TARGET=Server -DCMAKE_BUILD_TYPE=Release ..
but when I pass -DRSTUDIOVERIFYR_VERSION=0 as well, I configure successfully and make it to about 44% before the build fails:
Rogers-iMac:build roger$ sudo make install
Password:
Scanning dependencies of target gwt_build
Buildfile: /Users/roger/projects/rstudio/src/gwt/build.xml
[...]
Scanning dependencies of target rstudio-r
[ 44%] Building CXX object src/cpp/r/CMakeFiles/rstudio-r.dir/RErrorCategory.cpp.o
[ 44%] Building CXX object src/cpp/r/CMakeFiles/rstudio-r.dir/RExec.cpp.o
In file included from /Users/roger/projects/rstudio/src/cpp/r/RExec.cpp:17:
In file included from /Users/roger/projects/rstudio/src/cpp/r/include/r/RExec.hpp:30:
In file included from /Users/roger/projects/rstudio/src/cpp/r/include/r/RSexp.hpp:33:
/Users/roger/projects/rstudio/src/cpp/r/include/r/RInternal.hpp:43:10: fatal error: 'Rinternals.h' file not found
#include <Rinternals.h>
^
1 error generated.
I was able to find Rinternals.h in /opt/local/Library/Frameworks/R.framework/Versions/3.1/PrivateHeaders/Rinternals.h (EDIT: also in /opt/local/Library/Frameworks/R.framework/Versions/3.1/Resources/include/Rinternals.h), but how do I point the build configuration to this location?
EDIT: Additionally, I experienced another problem where the build failed at about 70% with the error
/opt/local/lib/libR.dylib/Resources/R: not a directory
make[2]: *** [src/cpp/r/R/packages/library/manipulate/DESCRIPTION] Error 126
Upon further investigation, /opt/local/lib/libR.dylib/Resources/R does not exist, because /opt/local/lib/libR.dylib is actually a file.
Not sure about the specifics of cmake but you can try
$ export CPATH=$CPATH:/opt/local/Library/Frameworks/R.framework/Versions/3.1/PrivateHeaders/
$ sudo make install
to tell the compiler to look for header files in the location where you found them.
This appears to be a problem with the RStudio cmake script not properly detecting a MacPorts R installation. To fix these problems:
Point cmake to the correct location of your R executable using export RSTUDIO_WHICH_R=/opt/local/bin/R (or whatever the location is for you), as described in this RStudio Knowledge Base Article. This solves the problem with cmake failing to generate a configuration.
To solve the problems with Rinternals.h not being found, go into build/CMakeCache.txt and change the path of LIBR_INCLUDE_DIRS to reflect Rinternals.h's actual location, as described in this RStudio Support Forum Question.
Ensure that LIBR_EXECUTABLE, LIBR_HOME, and LIBR_DOC_DIR all point to the correct location. You can get the correct locations by doing R.home(component="home") (or component="doc") in an R interactive prompt, as described on this webpage. This will solve the build error at 44%, and the additional error I had at 70-ish%.
Add -I /opt/local/Library/Frameworks/R.framework/Versions/3.1/PrivateHeaders/ to the compiler's command line.
Alternatively, you can set CPLUS_INCLUDE_PATH in the environment to tell the compiler where to search for additional headers when compiling C++ code. You may also want to set C_INCLUDE_PATH for C if needed.
$ export CPLUS_INCLUDE_PATH=/opt/local/Library/Frameworks/R.framework/Versions/3.1/PrivateHeaders
$ make
Let be a library A that I compile with CMake. I also want to distribute it via a package (e.g. RPM).
Where should my package install the files AConfig.cmake and AConfigVersion.cmake ?
In /usr/share/cmake/Modules on Linux ?
You should find what you need here:
http://www.cmake.org/Wiki/CMake/Tutorials/Packaging
With the relevant portion of the text:
Consider a project "Foo" that installs the following files:
<prefix>/include/foo-1.2/foo.h
<prefix>/lib/foo-1.2/libfoo.a
It may also provide a CMake package configuration file
<prefix>/lib/foo-1.2/foo-config.cmake
The config files need the be in your install tree. Only the FindXXX.cmake file should go in the modules directory.