Tag: swi prolog

从XCode中的C-Programm到SWI-Prolog的接口

我想使用MAC OS X下的XCode IDE到SWI-Prolog从c代码接口。 我已经包含了头文件并使用以下示例代码: #include #include #include 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 […]

DSO中的SIGSEGV,混合C / C ++

我正在为C ++使用SWI-Prolog 外语接口 ,试图集成其他一些资源。 它主要起作用,但任何抛出exception的尝试都会导致SIGSEGV。 例外通常用于validation用户参数,因此是界面的基本部分。 我正在从源代码(通过提供的脚本)编译SWI-Prolog,并且CXX标志是 -c -O2 -gdwarf-2 -g3 -Wall -pthread -fPIC 我正在使用相同的标志来编译我的C ++代码,它是在.so中组装的,在SWI-Prolog中动态加载(我认为通过dlopen)。 在SEGV显示IP在,__cxa_allocate_exception内部之后检查堆栈(通过GDB)。 可能__cxa_get_globals @ plt无法访问。 Dump of assembler code for function __cxa_allocate_exception: 0x00007ffff1d80220 : push %r12 0x00007ffff1d80222 : lea 0x80(%rdi),%r12 0x00007ffff1d80229 : push %rbp 0x00007ffff1d8022a : mov %r12,%rdi 0x00007ffff1d8022d : push %rbx 0x00007ffff1d8022e : callq 0x7ffff1d1de30 0x00007ffff1d80233 : test %rax,%rax […]