c++ - 代码块的 FLTK 错误
问题描述
我想用 FLTK 做一个 GUI。所以我通过酿造将它安装在我的Mac上。到目前为止效果很好。
然而,当我尝试编译一个小程序时,我收到以下错误消息:
-------------- Build: Debug in fltk_test (compiler: GNU GCC Compiler)---------------
g++ -o bin/Debug/fltk_test obj/Debug/main.o
Undefined symbols for architecture x86_64:
"fl_define_FL_SHADOW_LABEL()", referenced from:
_main in main.o
"Fl::run()", referenced from:
_main in main.o
"Fl_Box::Fl_Box(int, int, int, int, char const*)", referenced from:
_main in main.o
"Fl_Group::end()", referenced from:
_main in main.o
"Fl_Window::show(int, char**)", referenced from:
_main in main.o
"Fl_Window::Fl_Window(int, int, char const*)", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Process terminated with status 1 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
这是我的代码:
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>
int main (int argc, char ** argv)
{
Fl_Window *window;
Fl_Box *box;
window = new Fl_Window (300, 180);
box = new Fl_Box (20, 40, 260, 100, "Hello World!");
box->box (FL_UP_BOX);
box->labelsize (36);
box->labelfont (FL_BOLD+FL_ITALIC);
box->labeltype (FL_SHADOW_LABEL);
window->end ();
window->show (argc, argv);
return(Fl::run());
}
相信我,我搜索了四个多小时,尝试了不同的 IDE(Atom)等等。“正常” C++ 工作正常...
提前致谢。我感谢我能得到的每一个提示或帮助:)
解决方案
您应该将编译器链接到 fltk。去project->build options->linker options->add
写fltk
然后保存并重建项目并运行它。
在某些用法中,您也需要将 , 链接fltk_forms
到fltk_gl
fltk_images
编译器。
推荐阅读
- javascript - 500 内部服务器错误 Asp.net C# 数据表
- php - 使用 PHP 清理 GET 查询 url
- python - numpy中的多个插入,其中配对元素没有潜台词
- visual-studio-2015 - 与 VS 2015 的角度集成
- angular - 在日历的对象数组上使用 ngFor
- java - 在 Groovy 中返回多个参数
- python - 如何将格式为列表的文件中的字符串读入 Python 中的列表?
- powershell - 如何在powershell中将csv行添加到数组中
- sql - 具有来自另一列的 MAX 值的分组依据
- r - 更改输入数据集后的R匹配错误