【问题标题】:I'm getting a linker error I don't understand with VC++ and FLTK [closed]我收到一个链接器错误,我不理解 VC++ 和 FLTK [关闭]
【发布时间】:2014-05-14 20:13:40
【问题描述】:

我正在尝试使用 FLTK 和 VC++2010 创建一个新项目。我有一段时间没有这样做了。我尽我所能通过记忆设置属性。我收到了一个链接器错误。谁能告诉我如何解决这个问题?

1>------ Build started: Project: BJST chap 14 ex 1a, Configuration: Debug Win32 ------ 
1>  BJST chap 14 ex 1.cpp 
1>c:\users\bryan\documents\visual studio 2010\projects\bjst chap 14 ex 1a\bjst chap 14 ex 1a\bjst chap 14 ex 1.cpp(10): error C2065: 'FL_Window' : undeclared identifier
1>c:\users\bryan\documents\visual studio 2010\projects\bjst chap 14 ex 1a\bjst chap 14 ex 1a\bjst chap 14 ex 1.cpp(10): error C2146: syntax error : missing ';' before identifier 'window'
1>c:\users\bryan\documents\visual studio 2010\projects\bjst chap 14 ex 1a\bjst chap 14 ex 1a\bjst chap 14 ex 1.cpp(10): error C3861: 'window': identifier not found
1>c:\users\bryan\documents\visual studio 2010\projects\bjst chap 14 ex 1a\bjst chap 14 ex 1a\bjst chap 14 ex 1.cpp(12): error C2065: 'FL_Box' : undeclared identifier 
1>c:\users\bryan\documents\visual studio 2010\projects\bjst chap 14 ex 1a\bjst chap 14 ex 1a\bjst chap 14 ex 1.cpp(12): error C2146: syntax error : missing ';' before identifier 'box'
1>c:\users\bryan\documents\visual studio 2010\projects\bjst chap 14 ex 1a\bjst chap 14 ex 1a\bjst chap 14 ex 1.cpp(12): error C3861: 'box': identifier not found 
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== 


#include <FL/Fl.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Window.H>



int main ()
{

    FL_Window window(200, 200, "window title");

    FL_Box box();

return 0;
}

【问题讨论】:

  • '缺少';'在标识符 'box'` 之前不是 linker 错误!
  • 你忘记#include &lt;FLTK_header_name_goes_here.h&gt;了吗?或者,FLTK 类型可能属于某个命名空间,您需要对它们进行限定。无论如何,这些都不是链接器错误。
  • 我使用的是 box 和 window,你可以看到它们都包含在内。
  • 可能错过了namespace?
  • 知道了。 FL_Window 需要为 Fl_Window,以此类推。

标签: c++ visual-studio-2010 fltk


【解决方案1】:

这个错误信息

错误 C2065:“FL_Window”:未声明的标识符

表示编译器没有找到标识符FL_Window的声明。如果您输入正确,则可以在某个命名空间中声明此名称(我认为确实如此)。检查头文件&lt;FL/Fl_Window.H&gt; 是否在某个命名空间中声明了此名称。在这种情况下,你必须至少写成

TheNameSpace::FL_Window window(200, 200, "window title");

在哪里写命名空间而不是 TheNameSpace 声明名称 FL_Window。

看来标识符FL_Box也有同样的问题

【讨论】:

  • 正确。顺便说一句,FLTK1 没有命名空间……FLTK2 有。
猜你喜欢
  • 1970-01-01
  • 2015-01-14
  • 1970-01-01
  • 2021-03-12
  • 1970-01-01
  • 1970-01-01
  • 2012-05-17
  • 2014-07-22
  • 1970-01-01
相关资源
最近更新 更多