C++ 编译C++;使用SWI Prolog接口的程序
我正在编译找到的程序,在运行时出现错误: 下面是我编译它的步骤:C++ 编译C++;使用SWI Prolog接口的程序,c++,g++,swi-prolog,ffi,C++,G++,Swi Prolog,Ffi,我正在编译找到的程序,在运行时出现错误: 下面是我编译它的步骤: $ 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 ‘cha
$ 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
无法找到动态库有关。有几种依赖于系统的方法来处理此问题。例如,打开以包括libswipl.so.6.0.2
所在的目录。
尽管编译警告与运行时错误无关,但修复它们仍然是一个好主意:
static const char * av[] = {"calc.pl", NULL};
....
const char * expression = "pi/2";