I am learning CUDD package for research purposes. I have got one sample code from which I have tried to learn the basic functionalities. But I am getting error during compilation.
I have already set the paths for the header.
#include <sys/types.h>
#include <sys/time.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <stdlib.h>
#include "cudd.h"
#include "util.h"
void print_dd(DdManager *gbm, DdNode *dd, int n, int pr)
{
printf("Ddmanager nodes : %ld \n",Cudd_ReadNodeCount(gbm));
printf("Ddmanager vars : %d \n",Cudd_ReadSize(gbm));
printf("Ddmanager reorderings :%d\n",Cudd_ReadReorderings(gbm));
printf("DdManager memory % ld",Cudd_ReadMemoryInUse(gbm));
Cudd_PrintDebug(gbm,dd,n,pr);
}
void write_dd(DdManager *gbm, DdNode *dd, char * filename)
{
FILE *outfile;
outfile=fopen(filename,"w");
DdNode **ddnodearray=(DdNode **)malloc(sizeof(DdNode*));
ddnodearray[0]=dd;
Cudd_DumpDot(gbm,1,ddnodearray,NULL,NULL,outfile);
free(ddnodearray);
fclose(outfile);
}
int main(int argc, char *argv[])
{
DdManager *gbm;
char filename[30];
gbm=Cudd_Init(0,0,CUDD_UNIQUE_SLOTS,CUDD_CACHE_SLOTS,0);
DdNode *bdd=Cudd_bddNewVar(gbm);
Cudd_Ref(bdd);
bdd=Cudd_BddToAdd(gbm,bdd);
print_dd(gbm,bdd,2,4);
sprintf(filename,"./bdd/graph.dot");
write_dd(gbm,bdd,filename);
Cudd_Quit(gbm);
return 0;
}
I am getting some error during compilation.
gcc -I /home/subhadip/cudd-3.0.0 -I /home/subhadip/cudd-3.0.0/util -I /home/subhadip/cudd-3.0.0/cudd transfer1.c /home/subhadip/cudd-3.0.0/cudd/.libs/libcudd.a -o transfer1
/home/subhadip/cudd-3.0.0/cudd/.libs/libcudd.a(cudd_libcudd_la-cuddAPI.o): In function `Cudd_ExpectedUsedSlots':
/home/subhadip/cudd-3.0.0/cudd/cuddAPI.c:1835: undefined reference to `exp'
/home/subhadip/cudd-3.0.0/cudd/cuddAPI.c:1844: undefined reference to `exp'
/home/subhadip/cudd-3.0.0/cudd/cuddAPI.c:1850: undefined reference to `exp'
/home/subhadip/cudd-3.0.0/cudd/.libs/libcudd.a(cudd_libcudd_la-cuddCache.o): In function `cuddCacheProfile':
/home/subhadip/cudd-3.0.0/cudd/cuddCache.c:816: undefined reference to `exp'
/home/subhadip/cudd-3.0.0/cudd/.libs/libcudd.a(cudd_libcudd_la-cuddUtil.o): In function `Cudd_CountMinterm':
/home/subhadip/cudd-3.0.0/cudd/cuddUtil.c:595: undefined reference to `pow'
/home/subhadip/cudd-3.0.0/cudd/cuddUtil.c:595: undefined reference to `pow'
/home/subhadip/cudd-3.0.0/cudd/cuddUtil.c:595: undefined reference to `pow'
/home/subhadip/cudd-3.0.0/cudd/.libs/libcudd.a(cudd_libcudd_la-cuddUtil.o): In function `Cudd_LdblCountMinterm':
/home/subhadip/cudd-3.0.0/cudd/cuddUtil.c:729: undefined reference to `powl'
/home/subhadip/cudd-3.0.0/cudd/.libs/libcudd.a(cudd_libcudd_la-cuddUtil.o): In function `Cudd_CountMinterm':
/home/subhadip/cudd-3.0.0/cudd/cuddUtil.c:595: undefined reference to `pow'
/home/subhadip/cudd-3.0.0/cudd/cuddUtil.c:595: undefined reference to `pow'
/home/subhadip/cudd-3.0.0/cudd/cuddUtil.c:595: undefined reference to `pow'
/home/subhadip/cudd-3.0.0/cudd/.libs/libcudd.a(cudd_libcudd_la-epd.o): In function `EpdNormalizeDecimal':
/home/subhadip/cudd-3.0.0/epd/epd.c:834: undefined reference to `pow'
/home/subhadip/cudd-3.0.0/epd/epd.c:834: undefined reference to `pow'
/home/subhadip/cudd-3.0.0/cudd/.libs/libcudd.a(cudd_libcudd_la-epd.o):/home/subhadip/cudd-3.0.0/epd/epd.c:452: more undefined references to `pow' follow
/home/subhadip/cudd-3.0.0/cudd/.libs/libcudd.a(cudd_libcudd_la-cuddAnneal.o): In function `siftBackwardProb':
/home/subhadip/cudd-3.0.0/cudd/cuddAnneal.c:671: undefined reference to `exp'
/home/subhadip/cudd-3.0.0/cudd/cuddAnneal.c:671: undefined reference to `exp'
/home/subhadip/cudd-3.0.0/cudd/.libs/libcudd.a(cudd_libcudd_la-cuddAnneal.o): In function `cuddAnnealing':
/home/subhadip/cudd-3.0.0/cudd/cuddAnneal.c:229: undefined reference to `log'
/home/subhadip/cudd-3.0.0/cudd/cuddAnneal.c:229: undefined reference to `log'
/home/subhadip/cudd-3.0.0/cudd/.libs/libcudd.a(cudd_libcudd_la-cuddAnneal.o): In function `siftBackwardProb':
/home/subhadip/cudd-3.0.0/cudd/cuddAnneal.c:671: undefined reference to `exp'
collect2: error: ld returned 1 exit status
I have tried to statically link the libraries but the there is a problem. How can I fix it?
You compiled cudd and generated a static library. Now you need to link with it:
gcc .. <other options> ... transfer1.c /home/subhadip/cudd-3.0.0/cudd/.libs/libcudd.a -o transfer1
Note that the order of files matter.
I can guess that for C++ support you have to link with cplusplus/.libs/libobj.a
and for dddmp support you need symbols exported in dddmp/.libs/libdddmp.a
.