从C-PROGRAMM接口X code到SWI-Prolog的 [英] Interface from C-Programm in XCode to SWI-Prolog

查看:264
本文介绍了从C-PROGRAMM接口X code到SWI-Prolog的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用X code IDE Mac OS X下到SWI-Prolog的从C-code接口。

i want to interface from c-code using XCode IDE under MAC OS X to SWI-Prolog.

从来就包含头文件和使用下面的示例code:

I´ve included the header files and use the following sample code:

#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;
}

我也是在构建设置的头和lib路径链接

头文件搜索路径:/opt/local/lib/swipl-6.2.2/include

Header Search Path: /opt/local/lib/swipl-6.2.2/include

库搜索路径:/opt/local/lib/swipl-6.2.2/lib/i386-darwin12.2.1

Library Search Path: /opt/local/lib/swipl-6.2.2/lib/i386-darwin12.2.1

但在运行code,而我得到以下错误:

But while running the code i get the following errors:

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)

有谁可以帮我把我的code运行?

Does anyone can help me to get my code running?

在此先感谢和亲切的问候

Thanks in Advance and Kind regards

Solick

推荐答案

我在Ubuntu(是的,在Windows中,仍然)工作,我来AP preciate的的 pkg配置的支持。

I work in Ubuntu (and yes, in Windows, still), and I've come to appreciate the pkg-config support.

如果你已经熟悉它,注意,当本地编译,SWI-Prolog的生成目录〜/ lib目录/ pkgconfig。

If you are already comfortable with it, note that when compiled locally, SWI-Prolog generates a directory ~/lib/pkgconfig.

然后,你可以添加目录pkg配置配置,并使用带(恕我直言)很好地支持西南。

Then you could add that directory to pkg-config configuration, and use the SW with (IMHO) a good support.

这篇关于从C-PROGRAMM接口X code到SWI-Prolog的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆