undefined reference 에러.. 인데..

ash84의 이미지

make 시, 다음과 같은 구문이 나오는데요

./src-gat/notes_conn.o(.text+0xab15): In function `CCon::GetData()':
: undefined reference to `WorkPackager_new()'
collect2: ld returned 1 exit status

일단 undefined reference 에러는 여기 찾아 보니까 링크시 못찾는걸로 나오는데,

제가 했던것을 말씀드리면,

libfasoopackagerC.so(고객사에서 받은 so 파일, 이것만 받았음)

위의 파일을 현재 make 한 프로그램의 lib/linux/drm 디렉토리에 두었습니다.

그리고 나서

DIR = ./lib/linux

CFLAGS += -I$(DIR)/drm
LFLAGS += -L$(DIR)/drm

LIBS += -lfasoopackagerC

이렇게 추가한후

CC = gcc

@$(CC) $(LFLAGS) -o $(OBINDIR)/$@ $(OBJS) $(LIBS)

make를 수행하였는데 위의 구문에서 링크 에러가 나네요.

근데 제가 알기로는(잘 모르지만) libfasoopackagerC.so 를 /usr/lib 가 아닌 특정 위치에 둘거면

-L로 명시해 두고 링크할 라이브러리를 -l 에 앞에 lib 랑 so 빼고 -lfasoopackagerC 라고 입력해 주면

되는거라고 알고 있는데 별도의 다른 작업을 해 주어야 하나요?

bushi의 이미지

nm -D 커멘드로 심볼 목록 뽑아서 WorkPackager_new 를 찾아보세요.
T 로 마크되어 있어야 합니다.

링크 할 라이브러리를 못 찾은 경우엔 다른 에러 메시지가 나옵니다.

[bushi@rose hiber_imgs]$ echo "int main() { return 0;}" | gcc -x c -o test -
[bushi@rose hiber_imgs]$ 
[bushi@rose hiber_imgs]$ echo "int main() { return 0;}" | gcc -x c -o test -lxxx -
/usr/bin/ld: cannot find -lxxx
collect2: ld returned 1 exit status
[bushi@rose hiber_imgs]$ 
[bushi@rose hiber_imgs]$ echo "int main() { return 0;}" | strace -F gcc -x c -o test -Lyyy -lxxx - 2>&1 | grep yyy
execve("/usr/lib/ccache/gcc", ["gcc", "-x", "c", "-o", "test", "-Lyyy", "-lxxx", "-"], [/* 49 vars */]) = 0
execve("/usr/bin/gcc", ["/usr/bin/gcc", "-x", "c", "-o", "test", "-Lyyy", "-lxxx", "-"], [/* 50 vars */]) = 0
[pid 18753] execve("/usr/libexec/gcc/i686-redhat-linux/4.4.4/collect2", ["/usr/libexec/gcc/i686-redhat-lin"..., "--eh-frame-hdr", "--build-id", "-m", "elf_i386", "--hash-style=gnu", "-dynamic-linker", "/lib/ld-linux.so.2", "-o", "test", "/usr/lib/gcc/i686-redhat-linux/4"..., "/usr/lib/gcc/i686-redhat-linux/4"..., "/usr/lib/gcc/i686-redhat-linux/4"..., "-Lyyy", "-L/usr/lib/gcc/i686-redhat-linux"..., "-L/usr/lib/gcc/i686-redhat-linux"..., ...], [/* 54 vars */] <unfinished ...>
[pid 18754] execve("/usr/bin/ld", ["/usr/bin/ld", "--eh-frame-hdr", "--build-id", "-m", "elf_i386", "--hash-style=gnu", "-dynamic-linker", "/lib/ld-linux.so.2", "-o", "test", "/usr/lib/gcc/i686-redhat-linux/4"..., "/usr/lib/gcc/i686-redhat-linux/4"..., "/usr/lib/gcc/i686-redhat-linux/4"..., "-Lyyy", "-L/usr/lib/gcc/i686-redhat-linux"..., "-L/usr/lib/gcc/i686-redhat-linux"..., ...], [/* 55 vars */]) = 0
[pid 18754] open("yyy/libxxx.so", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
[pid 18754] open("yyy/libxxx.a", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
[bushi@rose hiber_imgs]$
익명 사용자의 이미지

라이브러리링크는 되었습니다. 안되엇다면 윗글 메세지 처럼 나올거구요..

라이브러리 파일이 libfasoopackagerC.so 일 경우에
gcc -main.c -o exe -lfasoopackagerC 맞게 주신거 맞고요..

에러메세지가 함수관련 메세지로 보아
소스문제일 가능성이 높습니다.

./src-gat/notes_conn.o(.text+0xab15): In function `CCon::GetData()':
: undefined reference to `WorkPackager_new()'
collect2: ld returned 1 exit status

*근데 CCon::GetData() 요고 CPP 아닌가요?

ash84의 이미지

cpp 가 맞습니다만..

댓글 달기

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