2

I am porting code from Linux to Solaris(OmniOS v11 r151018), and get link error due to there is no port I/O implementation

This is simplest sample code:

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

It will compile success on Linux, but get outb undefined symbol on 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

Could someone help me to solve link error? Which library should I link with?

Brightshine
  • 975
  • 1
  • 7
  • 17
  • Looks like C with deprecated function signature to me. Why the C++ tag? Why the Linux tag when asking about Solaris? – too honest for this site Nov 16 '16 at 07:14
  • @Olaf I have removed unnecessary tags. What I need is outb() function implementation on Solaris, not a general solution for undefined symbol ! – Brightshine Nov 16 '16 at 07:37
  • Read the dup ! There is nothing special about "outb". If it is declared in the headers, it should be in the library, too! – too honest for this site Nov 16 '16 at 07:51
  • Yes, I think it is nothing special. But that's why I got confused. Man page never mention about where it is... Do you have any suggestion except for extracting each symbols for all .a and .so in my system ? – Brightshine Nov 16 '16 at 10:01
  • 2
    This question is not a duplicate of the linked quesiton. A review of the uses and the definition of `outb` on OpenSolaris code at http://src.illumos.org/source/search?q=outb&defs=&refs=&path=&hist=&project=illumos-gate seems to indicate that `outb` is a kernel-only function on Solaris. Note also that the [man page for outb](https://docs.oracle.com/cd/E19455-01/806-0639/6j9vsttt2/index.html) does not list the user-space library needed to link. Finally, the man page is in "man pages section 9F: DDI and DKI **Kernel Functions**" – Andrew Henle Nov 16 '16 at 13:08

0 Answers0