【问题标题】:Run first program with Gecode使用 Gecode 运行第一个程序
【发布时间】:2016-02-04 02:43:12
【问题描述】:

我需要你的帮助。

我已经在 Windows 8 上安装了用于开发基于约束的系统和应用程序的工具包Gecode 4.4.0,还有编译器 C++ Dev C++ 5.9.2,但我仍然不知道如何运行我的第一个程序或安装提供的示例。

我听说我需要一个 make 文件,但实际上我还没有成功编译或执行。

编译命令:

g++.exe -D__DEBUG__ main.o sat.o -o TestGecode.exe -L"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib32"-L"C:/程序文件 (x86)/Dev-Cpp/MinGW64/x86_64-w64-mingw32/lib32"-static-libgcc -L"C:/Program Files (x86)/Gecode/include" -m32 -g3

输出错误:

sat.o:在函数 ZN6Gecode9ExceptionD2Ev': c:/program files (x86)/dev-cpp/mingw64/x86_64-w64-mingw32/include/gecode/support/exception.hpp:46: undefined reference to_imp___ZTVN6Gecode9ExceptionE' sat.o:在 函数ZN6Gecode15MemoryExhaustedC1Ev': c:/program files (x86)/dev-cpp/mingw64/x86_64-w64-mingw32/include/gecode/support/exception.hpp:90: undefined reference to_imp___ZN6Gecode9ExceptionC2EPKcS2_' sat.o:在 函数`ZNK6Gecode9PosChoice7archiveERNS_7ArchiveE': ...

【问题讨论】:

  • 看起来很像您没有将开发工具指向 Gecode 库。不确定如何使用 DevC++ 执行此操作,但它应该有很好的文档记录。尝试将“dev c++ add library to project”添加到您的网络搜索选项中,看看会出现什么结果。
  • 它已经指向 Gecode 库。

标签: c++ constraints windows-8.1 gecode


【解决方案1】:

-L"C:/Program Files (x86)/Gecode/include"

提供 Gecode 标头的路径,而不是库的路径,以将 g++ 作为库路径。考虑使用

-L"C:/Program Files (x86)/Gecode/lib"

改为。

-L 仅将链接器指向查找库的位置。它不会告诉链接器要使用哪些库。 -l <name of library> 在命令行中也是必需的。 Gecode 文档应该告诉您要链接哪些库才能获得所需的功能。快速阅读表明 GecodeSupport 包含Gecode::Exception。不幸的是,它并没有直接出现在Gecode::Exception doc 页面上。您应该需要在命令行中添加-lGecodeSupport<version number>。

警告:如果您安装了 Gecode 网站上提供的任何 Windows 预打包版本,它们看起来都适用于 Visual Studio,GCC 无法识别它们。如果您从源代码下载并构建了 Gecode,那么您应该一切顺利。

【讨论】:

  • 实际上,我正在使用:CodeBlock 和 Dev C++。
  • DevC++ 是一个封装了 mingw 的 GCC 端口的 IDE。请注意以 g++(GCC 的 C++ 编译器)开头的编译命令。 GCC 的链接器将无法理解 Visual Studio 库使用的文件格式。
  • 我安装了Visual Studio 2012,并且已经编译好了。但是现在我又出现了一个错误,我无法运行程序,因为执行过程中发生了错误,程序没有结束!! 1 - cl /DNDEBUG /EHsc /MD /Ox /wd4355 -I"E:/prg files/gecode/x86/include" -c -Fo"C:/Users/sb/Desktop/money.obj" -Tp"C:/Users/sb/Desktop/money.cpp" 2 - cl /DNDEBUG /EHsc /MD /Ox /wd4355 -I"E:/prg files/gecode/x86/include" -Fe"C:/Users/sb/Desktop/money.exe" "C:/Users/sb/Desktop/money.obj" /link /LIBPATH:" E:/prg files/gecode/x86/lib" 3 - C:/Users/sb/Desktop/money.exe
  • Visual Studio 拥有一流的调试器。在调试器中运行程序一两分钟,然后暂停程序,看看卡在哪里。
猜你喜欢
  • 1970-01-01
  • 2017-09-27
  • 2023-04-04
  • 2016-08-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-06-13
相关资源
最近更新 更多