Recently, I am learning the Unix C and come to know that Sockets are:
– Special files used for network communication (or local interprocess communication)
– Not available in all UNIX versions (some don't represent network connections as files in the file system)
finally I get one example Unix Domain Socket from the website
http://beej.us/guide/bgipc/output/html/singlepage/bgipc.html#unixsockserv.when trying to compile the application on platform solaris, It always produces the error message as follows:
Undefined first referenced symbol in filebind /var/tmp//ccOrrHMQ.orecv /var/tmp//ccOrrHMQ.osend /var/tmp//ccOrrHMQ.oaccept /var/tmp//ccOrrHMQ.olisten /var/tmp//ccOrrHMQ.osocket /var/tmp//ccOrrHMQ.old: fatal: Symbol referencing errors. No output written to echoscollect2: ld returned 1 exit statusI know It's linkage error and the c application could not find the related library file,but donot know how to solve it ,after one afternoon research, I find that we need to link to the socket library when compiling the c socket application on solaris.
-lmylib (lower case 'L') Search the library named mylib for unresolvedgcc -o echos echos.c -lsocketand the pthread is the same thing and the thread application can be compiled in the following way
symbols (functions, global variables) when linking. The actual name of
the file will be libmylib.a, and must be found in either the default
locations for libraries or in a directory added with the -L flag.
gcc -o thread-create thread-create.c -lpthread.
You can find the lib in the dir /usr/lib