我想在 MAC OS X 下使用 XCode IDE 从 c 代码连接到 SWI-Prolog。
我已经包含了头文件并使用以下示例代码:
#include <stdio.h>
#include <SWI-Prolog.h>
#include <SWI-Stream.h>
int main(int argc, const char * argv[])
{
char *av[10];
int ac = 0;
av[ac++] = "/opt/local/lib/swipl-6.2.2/bin/i386-darwin12.2.1/swipl";
av[ac++] = "-x";
av[ac++] = "mystate";
av[ac] = NULL;
#ifdef READLINE /* Remove if you don't want readline */
PL_initialise_hook(install_readline);
#endif
if ( !PL_initialise(ac, av) )
PL_halt(1);
PL_halt(PL_toplevel() ? 0 : 1);
printf("done...\n");
return 0;
}
我还在构建设置中链接到头文件和库路径:
标头搜索路径:/opt/local/lib/swipl-6.2.2/include
库搜索路径:/opt/local/lib/swipl-6.2.2/lib/i386-darwin12.2.1
但是在运行代码时出现以下错误:
Undefined symbols for architecture x86_64:
"_PL_halt", referenced from:
_main in main.o
"_PL_initialise", referenced from:
_main in main.o
"_PL_toplevel", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
有谁可以帮助我让我的代码运行?
提前致谢和亲切的问候
索利克