我正在将代码从Linux移植到Solaris(OmniOS v11 r151018),并且由于没有端口I / O实现而导致链接错误
这是最简单的示例代码:
#if defined(__linux__)
#include <sys/io.h>
#elif defined(__sun)
#include <sys/ddi.h>
#include <sys/sunddi.h>
#endif
int main() {
int port = 0;
unsigned char value = 0;
#if defined(__linux__)
outb(value,port);
#elif defined(__sun)
outb(port,value);
#endif
return 0;
}
它将在Linux上编译成功,但在Solaris上获取未定义的符号:
$ gcc main.c
Undefined first referenced
symbol in file
outb /var/tmp//ccC6aqoL.o
ld: fatal: symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status
有人可以帮我解决链接错误吗?我应该链接哪个库?