CUDD 包:编译期间未定义的引用
CUDD package : Undefined reference during compilation
我正在学习 CUDD 包用于研究目的。我有一个示例代码,我试图从中学习基本功能。但是我在编译过程中遇到错误。
我已经为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;
}
我在编译过程中遇到一些错误。
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
我已尝试静态 link 库,但出现问题。我该如何解决?
您编译了cudd并生成了一个静态库。现在你需要link:
gcc .. <other options> ... transfer1.c /home/subhadip/cudd-3.0.0/cudd/.libs/libcudd.a -o transfer1
请注意文件的顺序很重要。
我可以猜测,对于 C++ 支持,您必须 link 和 cplusplus/.libs/libobj.a
,对于 dddmp 支持,您需要在 dddmp/.libs/libdddmp.a
.
中导出符号
使用上述解决方法后,如果仍然报错,
对我来说,我没有在代码行的正确位置创建名为 'bdd' 的文件夹:
sprintf(filename, "./bdd/graph.dot");
现在,它正在为我执行。
我正在学习 CUDD 包用于研究目的。我有一个示例代码,我试图从中学习基本功能。但是我在编译过程中遇到错误。
我已经为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;
}
我在编译过程中遇到一些错误。
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
我已尝试静态 link 库,但出现问题。我该如何解决?
您编译了cudd并生成了一个静态库。现在你需要link:
gcc .. <other options> ... transfer1.c /home/subhadip/cudd-3.0.0/cudd/.libs/libcudd.a -o transfer1
请注意文件的顺序很重要。
我可以猜测,对于 C++ 支持,您必须 link 和 cplusplus/.libs/libobj.a
,对于 dddmp 支持,您需要在 dddmp/.libs/libdddmp.a
.
使用上述解决方法后,如果仍然报错, 对我来说,我没有在代码行的正确位置创建名为 'bdd' 的文件夹:
sprintf(filename, "./bdd/graph.dot");
现在,它正在为我执行。