使用 Gecode 运行第一个程序

Run first program with Gecode

本文关键字:程序 第一个 运行 Gecode 使用      更新时间:2023-10-16

拜托,我需要你的帮助。

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

我已经读到我需要一个制作文件,但实际上我还没有成功编译或执行。

编译命令:

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: in 函数"ZNK6Gecode9PosChoice7archiveERNS_7ArchiveE":...

-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文档页面上说出来。您应该需要将-lGecodeSupport<version number>添加到命令行。

警告:如果您安装了Gecode网站上提供的任何Windows预打包版本,它们看起来都是Visual Studio的,并且GCC无法识别。如果您从源代码下载并构建了 Gecode,您应该很高兴。