当前位置: 技术问答>linux和unix
solaris 下gcc编译为什么出现这问题~~
来源: 互联网 发布时间:2016-04-30
本文导语: 在Solaris 10上刚重新安装的gcc test.c是一个很简单的程序 为什么编译通不过呢~~ #/usr/local/bin/gcc -g test.c Undefined first referenced symbol in fi...
在Solaris 10上刚重新安装的gcc test.c是一个很简单的程序
为什么编译通不过呢~~
#/usr/local/bin/gcc -g test.c
Undefined first referenced
symbol in file
main /usr/local/lib/gcc/i386-pc-solaris2.10/3.4.6/crt1.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status
为什么编译通不过呢~~
#/usr/local/bin/gcc -g test.c
Undefined first referenced
symbol in file
main /usr/local/lib/gcc/i386-pc-solaris2.10/3.4.6/crt1.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status
|
从楼主链接错误看,必需的是
-lsocket -lnsl
其实很简单,在Solaris下man socket就能看到了。
Sockets Library Functions inet(3SOCKET)
NAME
inet, inet6, inet_ntop, inet_pton, inet_addr, inet_network,
inet_makeaddr, inet_lnaof, inet_netof, inet_ntoa - Internet
address manipulation
SYNOPSIS
cc [ flag ... ] file... -lsocket -lnsl [ library...]
#include
#include
#include
#include
Sockets Library Functions socket(3SOCKET)
NAME
socket - create an endpoint for communication
SYNOPSIS
cc [ flag ... ] file ... -lsocket -lnsl [ library ... ]
#include
#include
int socket(int domain, int type, int protocol);
DESCRIPTION
The socket() function creates an endpoint for communication
and returns a descriptor.
Sockets Library Functions connect(3SOCKET)
NAME
connect - initiate a connection on a socket
SYNOPSIS
cc [ flag ... ] file ... -lsocket -lnsl [ library ... ]
#include
#include
int connect(int s, const struct sockaddr *name, int
namelen);
-lsocket -lnsl
其实很简单,在Solaris下man socket就能看到了。
Sockets Library Functions inet(3SOCKET)
NAME
inet, inet6, inet_ntop, inet_pton, inet_addr, inet_network,
inet_makeaddr, inet_lnaof, inet_netof, inet_ntoa - Internet
address manipulation
SYNOPSIS
cc [ flag ... ] file... -lsocket -lnsl [ library...]
#include
#include
#include
#include
Sockets Library Functions socket(3SOCKET)
NAME
socket - create an endpoint for communication
SYNOPSIS
cc [ flag ... ] file ... -lsocket -lnsl [ library ... ]
#include
#include
int socket(int domain, int type, int protocol);
DESCRIPTION
The socket() function creates an endpoint for communication
and returns a descriptor.
Sockets Library Functions connect(3SOCKET)
NAME
connect - initiate a connection on a socket
SYNOPSIS
cc [ flag ... ] file ... -lsocket -lnsl [ library ... ]
#include
#include
int connect(int s, const struct sockaddr *name, int
namelen);