-1

拜托我需要你的帮忙。

我已经安装了用于在 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:/Program Files (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': ...

4

1 回答 1

0

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

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

-L"C:/程序文件 (x86)/Gecode/lib"

反而。

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

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

于 2016-02-02T20:55:06.263 回答