Run first program with Gecode

1k Views Asked by At

Please i need your help.

I have installed the toolkit for developing constraint-based systems and applications Gecode 4.4.0 on Windows 8, also the compilator C++ Dev C++ 5.9.2 but i still don't know how can i run my first program or the example provided by the insallation.

I've read that i need a make file but really i have not yet succeeded compilation or execution.

Compile command :

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

Output error :

sat.o: In function 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: In function 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 function `ZNK6Gecode9PosChoice7archiveERNS_7ArchiveE': ...

1

There are 1 best solutions below

4
On

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

Provides the path to the Gecode headers, not the path to the libraries, to g++ as a library path. Consider using

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

instead.

-L only points the linker at where to find the libraries. It doesn't tell the linker what libraries to use. -l <name of library> is also required on the command line. The Gecode documentation should tell you which libraries to link in order to get the functions you need. A quick read suggests GecodeSupport contains Gecode::Exception. Unfortunately it doesn't come right out and say it on the Gecode::Exception doc page. You should need to add -lGecodeSupport<version number> to the command line.

Caveat: If you installed any of the pre-packaged versions for Windows provided on the Gecode site, they all look to be for Visual Studio and won't be recognizable to GCC. If you downloaded and built Gecode from source, you should be good to go.