Bryan

            BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
            37 Posts :: 3 Stories :: 24 Comments :: 0 Trackbacks
          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
          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
          posted on 2011-08-25 16:33 Life is no respector of any genius. 閱讀(1230) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 大丰市| 固阳县| 阳新县| 尉犁县| 津市市| 高淳县| 碌曲县| 乐都县| 涟源市| 富裕县| 易门县| 彭泽县| 禄丰县| 永新县| 礼泉县| 勐海县| 马边| 昭苏县| 连州市| 民权县| 鄢陵县| 高雄县| 通州市| 临清市| 汉川市| 叙永县| 景泰县| 永新县| 翁牛特旗| 抚远县| 襄汾县| 德令哈市| 江北区| 宁安市| 黎城县| 平舆县| 三都| 北票市| 沐川县| 无极县| 宁德市|