cross compile 하는 중에 소스가 semaphore.h를 인식하지 못하는 것 같아요...

bakdorazi의 이미지

저는 net-snmp-5.3.2의 agentx를 fedora11에서 크로스 컴파일 하고 있었습니다.

아래는 agentx Makefile 입니다.

============================================================================================

#
# Warning: you may need more libraries than are included here on the
# build line.  The agent frequently needs various libraries in order
# to compile pieces of it, but is OS dependent and we can't list all
# the combinations here.  Instead, look at the libraries that were
# used when linking the snmpd master agent and copy those to this
# file.
#
PROJDIR = /home/proj/msap/apps/sychoi
INSTDIR = $(PROJDIR)/rootfs/usr/sbin
SNMPINC = /home/proj/msap/apps/sychoi/install/usr
CC=ppc_82xx-gcc
STRIP=ppc_82xx-strip
 
OBJS += agentx.o
OBJS += fan.o
OBJS += exam.o
 
TARGETS = agentx
 
CFLAGS += -O2 -Dlinux -I. -I$(SNMPINC)/include
BUILDLIBS = -L$(SNMPINC)/lib -lnetsnmp -lcrypto -lm
BUILDAGENTLIBS = -L$(SNMPINC)/lib -lnetsnmpmibs -lnetsnmpagent -lnetsnmphelpers -lnetsnmp -ldl -lcrypto -lm
 
 
# shared library flags (assumes gcc)
DLFLAGS=-fPIC -shared -lpthread
 
all: $(TARGETS)
 
agentx: $(OBJS)
        $(CC) -o agentx $(OBJS) $(BUILDLIBS) $(BUILDAGENTLIBS)
        $(STRIP) agentx
 
install:
        cp -a agentx $(INSTDIR)
 
clean:
        rm -f $(OBJS) $(TARGETS)

===========================================================================================

그리하여 make 명령을 내리니..... 소스파일에서 에러가 나는군요...

===========================================================================================

[root@localhost nextest]# make agentx
ppc_82xx-gcc -O2 -Dlinux -I. -I/home/proj/msap/apps/sychoi/install/usr/include   -c -o agentx.o agentx.c
ppc_82xx-gcc -O2 -Dlinux -I. -I/home/proj/msap/apps/sychoi/install/usr/include   -c -o fan.o fan.c
ppc_82xx-gcc -O2 -Dlinux -I. -I/home/proj/msap/apps/sychoi/install/usr/include   -c -o exam.o exam.c
ppc_82xx-gcc -o agentx agentx.o fan.o exam.o -L/home/proj/msap/apps/sychoi/install/usr/lib -lnetsnmp -lcrypto -lm  -L/home/proj/msap/apps/sychoi/install/usr/lib -lnetsnmpmibs -lnetsnmpagent -lnetsnmphelpers -lnetsnmp -ldl -lcrypto -lm
exam.o: In function `init_exam':
exam.c:(.text+0x27c): undefined reference to `sem_init'
exam.o: In function `examNEXTable_get_next_data_point':
exam.c:(.text+0x370): undefined reference to `sem_wait'
exam.c:(.text+0x3f8): undefined reference to `sem_post'
exam.c:(.text+0x4cc): undefined reference to `sem_post'

===========================================================================================

문제는 exam.c 가 "semaphore.h" 를 인식하지 못하는 것 같은데요..

소스파일의 일부를 가져왔습니다.

==========================================================================

#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include "exam.h"
//#include "/opt/eldk-4.1/ppc_8xx/usr/include/semaphore.h"
 
#include <semaphore.h>
 
 
sem_t exam_sem;
 
 
....................................................................................
 
........
 
 
netsnmp_variable_list *
examNEXTable_get_next_data_point(void **my_loop_context,
                                 void **my_data_context,
                                 netsnmp_variable_list * put_index_data,
                                 netsnmp_iterator_info *mydata)
{
    struct examNEXTable_entry *entry = (struct examNEXTable_entry *) *my_loop_context;
    netsnmp_variable_list *idx = put_index_data;
    printf("entry :%d  put_index_data: %d\n", entry, put_index_data);
 
    struct examNEXTable_entry *ptr, *prev;
    int find =0;
 
    sem_wait(&exam_sem);
    printf("sema_wait end!!\n");
 
    for(prev =NULL, ptr=examNEXTable_head; ptr!=NULL; prev=ptr, ptr=ptr->next){
 
        if(entry==ptr)
         find =1;
         printf("find : %d  ptr : %d  entry: %d\n", find, ptr, entry);
      }
 
 
    if (entry && find) {
        snmp_set_var_value(idx, (u_char *)entry->name, strlen(entry->name));
        printf("entry->name : %s   len : %d  \n", (u_char *)entry->name, strlen(entry->name));
 
        idx = idx->next_variable;
        printf("idx : %d  idx->nex_variable : %d \n", idx, idx->next_variable);
        *my_data_context = (void *) entry;
        printf("my_data_context : %d \n", *my_data_context);
        *my_loop_context = (void *) entry->next;
        printf("my_loop_context: %d \n", *my_loop_context);
        sem_post(&exam_sem);
        printf("put_index_data : %d\n", put_index_data);
        return put_index_data;
 
    } else {
 
         sem_post(&exam_sem);
         printf("else!!\n");
         return NULL;
    }
}

==========================================================================

저는 "semaphore.h"가 ppc_82xx format 이 아니라서 그런 에러가 나나 생각했습니다.

그래서 ppc_82xx format의 "semaphore.h" 을 include 했는데...

아래와 같은 에러가 나더군요..

==========================================================================

[root@localhost nextest]# make agentx
ppc_82xx-gcc -O2 -Dlinux -I. -I/home/proj/msap/apps/sychoi/install/usr/include   -c -o agentx.o agentx.c
ppc_82xx-gcc -O2 -Dlinux -I. -I/home/proj/msap/apps/sychoi/install/usr/include   -c -o fan.o fan.c
ppc_82xx-gcc -O2 -Dlinux -I. -I/home/proj/msap/apps/sychoi/install/usr/include   -c -o exam.o exam.c
In file included from exam.c:10:
/opt/eldk-4.1/ppc_8xx/usr/include/semaphore.h:30:28: error: bits/semaphore.h: No such file or directory
In file included from exam.c:10:
/opt/eldk-4.1/ppc_8xx/usr/include/semaphore.h:37: error: parse error before '*' token
/opt/eldk-4.1/ppc_8xx/usr/include/semaphore.h:40: error: parse error before '*' token
/opt/eldk-4.1/ppc_8xx/usr/include/semaphore.h:43: error: parse error before '*' token
/opt/eldk-4.1/ppc_8xx/usr/include/semaphore.h:43: warning: data definition has no type or storage class
/opt/eldk-4.1/ppc_8xx/usr/include/semaphore.h:46: error: parse error before '*' token
/opt/eldk-4.1/ppc_8xx/usr/include/semaphore.h:55: error: parse error before '*' token
/opt/eldk-4.1/ppc_8xx/usr/include/semaphore.h:67: error: parse error before '*' token
/opt/eldk-4.1/ppc_8xx/usr/include/semaphore.h:70: error: parse error before '*' token
/opt/eldk-4.1/ppc_8xx/usr/include/semaphore.h:73: error: parse error before '*' token
exam.c:14: error: parse error before 'exam_sem'
exam.c:14: warning: data definition has no type or storage class
make: *** [exam.o] 오류 1

==========================================================================

뭐가 문제가 되서 그런 걸까요...

다른 소스에도 가 포함된 것이 많은데...

단순히 cross compile 할 때만 이런 에러가 나는군요...

아시는 분은 답변 달아주시면 감사하겠습니다....

제가 초보라서 그러니... 좀 어이 없는 질문이라도 양해 부탁드립니다.

bakdorazi의 이미지

저만 그런가요... 일단 semaphore.h 가 involve 되지 않으면서 sem_init, sem_post등을 모른다고 나오는 것 같은데요...

semaphore.h 는 /usr/lib 에 있습니다.... 이 문제 때문에...자꾸만 일이 뒤쳐지는데요...조금이라도 아시는 분 계시면 답글 부탁드립니다.

bushi의 이미지

맨 처음의 에러는 링크 에러입니다.
glibc 라면 Makefile 수정해서 -lrt 로 librt 를 같이 링크해주시면 될 겁니다.

그 이후의 에러는 ... 머리싸매고 고민하실 필요없습니다.
문제를 고치려고 노력하신게 아니라, 원래 없던 새로운 문제들을 계속 만들어내고 계십니다.
복사한 거, 고친 거... 원래대로 전부 복구하시거나 새로 설치하세요.

/usr/include 에 sempahore.h 할애비가 있어도 크로스 컴파일과는 상관없습니다.

OTL

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.