ld: 치명적: 기호 참조 오류. mac1에 출력이 기록되지 않음 오류인데 고수님들 좀 봐주세요

ktkmyfeeling의 이미지

#undef DLPI_DEV

#ifdef HPUX
static char *dlpi_dev[] = {"/dev/dlpi", ""};
#define DLPI_DEV
#endif

#ifdef AIX
static char *dlpi_dev[] = {"/dev/dlpi/et", "/dev/dlpi/en",
"/dev/dlpi/tr", "/dev/dlpi/fddi", ""};
#define DLPI_DEV
/* AIX: remember to set up /etc/pse.conf or /etc/dlpi.conf */
#endif

#ifdef SunOS
static char *dlpi_dev[] = {"/dev/hme", "/dev/ie", "/dev/le", "/dev/eri"};
#define DLPI_DEV
#endif

#ifndef DLPI_DEV
static char *dlpi_dev[] = {"/dev/dlpi", ""};
/* unknown OS - hope that this will work ??? */
#define DLPI_DEV
#endif

/**********************************************************************/
/*
* implementation
*/

#define INSAP 22
#define OUTSAP 24

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include

#define bcopy(source, destination, length) memcpy(destination, source,length)

#define AREA_SZ 5000 /*­=­* buffer length in bytes *­=­*/
static u_long ctl_area[AREA_SZ];
static u_long dat_area[AREA_SZ];
static struct strbuf ctl = {AREA_SZ, 0, (char *)ctl_area};
static struct strbuf dat = {AREA_SZ, 0, (char *)dat_area};
#define GOT_CTRL 1
#define GOT_DATA 2
#define GOT_BOTH 3
#define GOT_INTR 4
#define GOT_ERR 128

/*­=­* get a message from a stream; return type of message *­=­*/
static int get_msg(int fd)
{
int flags = 0;
int res, ret;
ctl_area[0] = 0;
dat_area[0] = 0;
ret = 0;
res = getmsg(fd, &ctl, &dat, &flags);

if(res < 0)
{
if(errno == EINTR)
{
return(GOT_INTR);
} else {
return(GOT_ERR);
}
}

if(ctl.len > 0) {
ret |= GOT_CTRL;
}
if(dat.len > 0) {
ret |= GOT_DATA;
}

return(ret);
}

/*­=­* verify that dl_primitive in ctl_area = prim *­=­*/
static int check_ctrl(int prim)
{
dl_error_ack_t *err_ack = (dl_error_ack_t *)ctl_area;

if(err_ack->dl_primitive != prim) {
return GOT_ERR;
}

return 0;
}

/*­=­* put a control message on a stream *­=­*/
static int put_ctrl(int fd, int len, int pri)
{
ctl.len = len;

if(putmsg(fd, &ctl, 0, pri) < 0) {
return GOT_ERR;
}

return 0;
}

/*­=­* put a control + data message on a stream *­=­*/
static int put_both(int fd, int clen, int dlen, int pri)
{
ctl.len = clen;
dat.len = dlen;

if(putmsg(fd, &ctl, &dat, pri) < 0) {
return GOT_ERR;
}

return 0;
}

/*­=­* open file descriptor and attach *­=­*/
static int dl_open(const char *dev, int ppa, int *fd)
{
dl_attach_req_t *attach_req = (dl_attach_req_t *)ctl_area;

if((*fd = open(dev, O_RDWR)) == -1) {
return GOT_ERR;
}

attach_req->dl_primitive = DL_ATTACH_REQ;
attach_req->dl_ppa = ppa;
put_ctrl(*fd, sizeof(dl_attach_req_t), 0);
get_msg(*fd);

return check_ctrl(DL_OK_ACK);
}

/*­=­* send DL_BIND_REQ *­=­*/
static int dl_bind(int fd, int sap, u_char *addr)
{
dl_bind_req_t *bind_req = (dl_bind_req_t *)ctl_area;
dl_bind_ack_t *bind_ack = (dl_bind_ack_t *)ctl_area;
bind_req->dl_primitive = DL_BIND_REQ;
bind_req->dl_sap = sap;
bind_req->dl_max_conind = 1;
bind_req->dl_service_mode = DL_CLDLS;
bind_req->dl_conn_mgmt = 0;
bind_req->dl_xidtest_flg = 0;
put_ctrl(fd, sizeof(dl_bind_req_t), 0);
get_msg(fd);

if (GOT_ERR == check_ctrl(DL_BIND_ACK)) {
return GOT_ERR;
}

bcopy((u_char *)bind_ack + bind_ack->dl_addr_offset, addr,
bind_ack->dl_addr_length);

return 0;
}

/**********************************************************************/
/*
* interface:
* function mac_addr_dlpi - get the mac address of the "first" interface
*
* parameter: addr: an array of six bytes, has to be allocated by the
caller
*
* return: 0 if OK, -1 if the address could not be determined
*
*/

long mac_addr_dlpi ( u_char *addr)
{
int fd;
int ppa;
u_char mac_addr[25];
int i;

char **dev;

for (dev = dlpi_dev; **dev != '\0'; ++dev)
{
for (ppa=0; ppa<10; ++ppa)
{
if (GOT_ERR != dl_open(*dev, ppa, &fd))
{
if (GOT_ERR != dl_bind(fd, INSAP, mac_addr))
{
bcopy( mac_addr, addr, 6);

return 0;
}
}
close(fd);
}
}

return -1;
}

/**********************************************************************/
/*
* Main (only for testing)
*/
#ifdef MAIN
int main( int argc, char **argv)
{
long stat;
int i;
u_char addr[6];

stat = mac_addr_dlpi( addr);

if (0 == stat)
{
printf( "MAC address = ");
for (i=0; i<6; ++i)
{
printf("%2.2x", addr[i]);
}
printf( "\n");
}
else
{
fprintf( stderr, "can't get MAC address\n");

exit( 1);
}
return 0;
}
#endif

bash-3.00$ gcc -g -o mac1 mac1.c -lsocket -lnsl
정의되지 않음 첫번째 참조된
기호 파일:
main /usr/local/lib/gcc/sparc-sun-solaris2.10/3.4.6/crt1.o
ld: 치명적: 기호 참조 오류. mac1에 출력이 기록되지 않음
collect2: ld returned 1 exit status

이런 에러가 나옵니다. 인터넷에서 방법을 찾아서 다시 컴파일 해 보았지만
역시나 같은 증상입니다.
고수님들 좀 도와 주세요 ㅠ

익명 사용자의 이미지

main()이 없다고 하는것인데, main()이 #ifdef MAIN ... #endif 안에 있으니, 아마 MAIN이 정의 되지 않아서 그건 거겠죠. MAIN을 정의해주거나, #ifdef MAIN #endif를 제거해주거나 하면 될텐데... 소스고치기 싫으면 gcc -DMAIN -g -o mac1 mac1.c -lsocket -lnsl하면 되겠네요.

ktkmyfeeling의 이미지

감사합니다.
제가 초보라서 아직 오류 보는것도 힘들어서요...
해결 하였습니다.
감사합니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.