【发布时间】:2015-08-13 01:14:45
【问题描述】:
我运行以下ccall's:
status = ccall((:ioperm, "libc"), Int32, (Uint, Uint, Int32), 0x378, 5, 1)
ccall((:outb, "libc"), Void, (Uint8, Uint16), 0x00, 0x378)
在第二个ccall 之后,我收到以下错误消息:
ERROR: ccall: could not find function outb in library libc
in anonymous at no file
in include at ./boot.jl:245
in include_from_node1 at loading.jl:128
in process_options at ./client.jl:285
经过一番研究和折腾,我发现了以下信息:
-
ioperm在 libc 中,但outb不在 - 但是,
ioperm和outb都在同一个头文件<sys/io.h>中定义 - 等效版本的 C 代码编译并顺利运行。
-
outb在glibc中,但是在系统上glibc定义为libc - 与完整路径名
/lib/x86_64-linux-gnu/libc.so.6相同的问题
编辑:
感谢@Employed Russian 的洞察力!我没有仔细观察以实现extern 声明。现在,我上面所有的笔记都说得通了!
太好了,我们发现ioperm 是在<sys/io.h> 中声明的libc 函数,而outb 不在libc 中,但在<sys/io.h> 中定义为易失汇编指令。
我应该使用哪个库或文件路径?
ccall 的实现。
【问题讨论】: