我正在尝试使用CMake编译zzogl并且我一直在遇到问题。我的第一个问题是我需要pkgconfig,所以我安装了它,为此我还必须安装MacPorts。然后它说我需要gtk + -2.0模块,所以我也得到了。在花了很长时间安装之后,我仍然会收到此错误:
checking for module 'gtk+-2.0'
package 'gtk+-2.0' not found
CMake Error at /Applications/CMake 2.8-2.app/Contents/share/cmake-2.8/Modules/FindPkgConfig.cmake:266 (message):
A required package was not found
Call Stack (most recent call first):
/Applications/CMake 2.8-2.app/Contents/share/cmake-2.8/Modules/FindPkgConfig.cmake:320 (_pkg_check_modules_internal)
CMakeLists.txt:106 (pkg_check_modules)
CMake Error at cmake/funcs.cmake:32 (message):
gtk not found, aborting...
Call Stack (most recent call first):
cmake/funcs.cmake:23 (reportFound)
CMakeLists.txt:107 (checkFor)
Configuring incomplete, errors occurred!
我对自己所做的事情并不熟悉,完全有可能我做错了。任何人都有任何煽动我的问题?我正在使用带有雪豹的mac。
答案 0 :(得分:3)
您是否使用类似于sudo port install gtk2
的命令安装了gtk?如果是,那么通常应该通过cmake找到gtk。你可以测试pkg-config是否正确找到了gtk,如下所示:
pkg-config --cflags gtk+-2.0
应打印类似
的内容-pthread -D_REENTRANT -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/directfb -I/usr/include/libpng12
但是使用不同的路径,以上是在Linux系统上。
如果pkg-config调用确实成功,那么你的CMake配置有问题。然后,您可以尝试安装MacPorts版本的cmake,如下所示:sudo port install cmake
并使用此版本。
答案 1 :(得分:3)
好的,我查看了FindGTK2.cmake
模块,我认为我发现了问题:它没有使用pkg-config
,而是以自己的方式查找标头和库。 _GTK2_FIND_INCLUDE_DIR
函数在其目录列表中没有/opt/local/include/
,这是MacPorts可能要安装标头的位置。同样,_GTK2_FIND_LIBRARY
未列出/opt/local/lib
。
这是一个known bug,显然已在CMake 2.8.3-rc1中修复。不过,我有疑虑,因为他们没有更新库路径。我们会看到。
我查看了find_path
和find_library
的文档。用户可以通过为-D
指定cmake
选项来提供有关搜索路径的提示。尝试类似:
cmake ../zzogl -DCMAKE_INCLUDE_PATH=/opt/local/include -DCMAKE_LIBRARY_PATH=/opt/local/lib