我想用 C++ 编译一个包含 gtkmm 库的测试程序。在编译过程中,找不到该库。
我在macos mojave上。我用 Homebrew 软件安装了 gtkmm。
gtkmm.h 文件在这里:/usr/local/Cellar/gtkmm/2.24.5_2/include/gtkmm-2.4/gtkmm.h
我试图在我的代码中写:#include "/usr/local/Cellar/gtkmm/2.24.5_2/include/gtkmm-2.4/gtkmm.h"
但是编译器没有找到文件 gtkmm.h
中的头文件。 .
brew doctor 告诉一切似乎都很好。
这是代码:
#include <gtkmm.h>
int main(int argc, char* argv[]) {
Gtk::Main app(argc, argv);
Gtk::Window fenetre;
Gtk::Main::run(fenetre);
return 0;
}
在终端上,我写道:
g++ test.cpp -o Fenetre `pkg-config gtkmm-3.0 --cflags --libs`
它回答:
Package gtkmm-3.0 was not found in the pkg-config search path. Perhaps you should add the directory containing `gtkmm-3.0.pc' to the PKG_CONFIG_PATH environment variable No package 'gtkmm-3.0' found test.cpp:1:10: fatal error: 'gtkmm.h' file not found "#include <gtkmm.h> ^~~~~~~~~ 1 error generated.
最佳答案
只是因为 gtkmm 2.4 版与 gtkmm 3 版不一样!您已经安装了 2.4 版,但使用 3 版进行编译,这似乎不存在于您的环境中。
关于compiler-errors - 编译器未找到库 gtkmm,但已安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57636982/