繁体   English   中英

编译使用SWI-Prolog接口的C ++程序

[英]Compiling C++ program that uses SWI-Prolog Interface

我正在编译在这里找到的程序,并且在运行时出现错误:

这是我要做的编译:

$ g++ -I/home/jpthomps/Desktop/pl-6.0.2/src main.cpp -L/usr/local/lib/swipl-6.0.2/lib/x86_64-linux -lswipl
main.cpp: In function ‘int main()’:
main.cpp:8:39: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
main.cpp:20:22: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]

然后,当我尝试运行已编译的程序时:

$ ./a.out
./a.out: error while loading shared libraries: libswipl.so.6.0.2: cannot open shared object file: No such file or directory

我是否需要在.cpp文件中添加一些内容以告诉它libswipl.so.6.0.2文件的位置?

您看到的问题与无法运行a.out来查找动态库有关。 有几种与系统有关的方法来处理此问题。 例如,在Linux上,您可以设置LD_LIBRARY_PATH以包括libswipl.so.6.0.2所在的目录。


尽管编译警告与运行时错误无关,但是修复它们仍然是一个好主意:

 static const char * av[] = {"calc.pl", NULL}; .... const char * expression = "pi/2"; 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM