I want to start a little c++ projekt that uses the library cddlib (http://www.inf.ethz.ch/personal/fukudak/cdd_home/cdd.html) which I installed (plus GMP) in a directory, say
/some/path/to/libcdd/
In a different directory, I have a file main.cpp with the contents
#include "setoper.h"
#include "cdd.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <string.h>
int main()
{
fprintf(stdout, "start\n");
dd_set_global_constants();
dd_free_global_constants();
fprintf(stdout, "done\n");
return 0;
}
Here, the two functions dd_... are functions from the library cddlib. I tried to compile this using the (naive?) command
g++ -o out main.cpp
However, this yields
/tmp/ccF7dx0W.o: In function `main':
main.cpp:(.text+0x28): undefined reference to `dd_set_global_constants'
main.cpp:(.text+0x2d): undefined reference to `dd_free_global_constants'
collect2: error: ld returned 1 exit status
The same happens for the call
g++ -L/some/path/to/libcdd/lib -I/some/path/to/libcdd/include -lcdd main.cpp
Is this just a stupid mistake? I am using Ubuntu 14.04 with g++ 4.8.2.
First, add cdd-path to your includes:
#include <cdd/setoper.h>
#include <cdd/cdd.h>
Next use following to compile:
g++ -o exe main.cpp -lcdd
Nothing else needed, if library is in system library dirs.
Note:-lcdd
must be the last argument of the compiler command line to work correctly.
Hope this works for you.