Codeblocks的FLTK错误

时间:2018-05-31 13:00:21

标签: c++ macos 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 ++正常运行......

提前致谢。我感谢每一个提示或帮助我得到:)

2 个答案:

答案 0 :(得分:0)

编译器告诉您它无法找到您正在调用的FLTK函数的函数定义。这意味着您没有正确链接FLTK库。请参阅标题为“编译您的程序”

标题下如何链接库here的说明

答案 1 :(得分:0)

您应该将编译器链接到fltk。转到fltk并编写fltk_forms,然后保存并重建项目并运行它。

在某些用法中,您还需要将fltk_glfltk_images data: have grp1 grp2 col1 col2 a b 20 . a b 30 10 a b 20 10 a b . 10 链接到编译器。