码迷,mamicode.com
首页 > 其他好文 > 详细

solaris bind 符号未定义

时间:2014-07-22 22:53:33      阅读:218      评论:0      收藏:0      [点我收藏+]

标签:blog   http   java   os   io   art   

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 file
bind                                /var/tmp//ccOrrHMQ.o
recv                                /var/tmp//ccOrrHMQ.o
send                                /var/tmp//ccOrrHMQ.o
accept                              /var/tmp//ccOrrHMQ.o
listen                              /var/tmp//ccOrrHMQ.o
socket                              /var/tmp//ccOrrHMQ.o
ld: fatal: Symbol referencing errors. No output written to echos
collect2: ld returned 1 exit status

I 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 unresolved
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 echos echos.c -lsocket -lnsl
and the pthread is the same thing and the thread application can be compiled in the following way
gcc -o thread-create thread-create.c -lpthread.

You can find the lib in the dir /usr/lib

lrwxrwxrwx 1 root root 25 Aug  5  2009 libpthread.so -> ../../lib/libpthread.so.1
lrwxrwxrwx 1 root root 24 Aug  5  2009 libsocket.so -> ../../lib/libsocket.so.1

Reference Materials
http://beej.us/guide/bgnet/output/html/singlepage/bgnet.html#solaris
http://www.fortunecity.com/skyscraper/arpanet/6/cc.htm
http://developers.sun.com/solaris/articles/solaris_linux_app.html

solaris bind 符号未定义,布布扣,bubuko.com

solaris bind 符号未定义

标签:blog   http   java   os   io   art   

原文地址:http://www.cnblogs.com/dwchenxj/p/3855207.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!