공유라이브러리에 공유라이브러리 추가 시키기

beggarstar의 이미지

안녕하세요

빌드 단계에서 어려움에 봉착해서 질문 드립니다.

조건 설명입니다.
=================================================================================================
libA.so -> aaa() 함수

libB.so -> b(){ aaa(); } : b()가 libA.so의 aaa() 사용
-> libB.so 빌드시 -lA 옵션으로 링킹

libC.so -> c(){ aaa(); } : c()가 libA.so의 aaa() 사용
-> libC.so 빌드시 -lA 옵션으로 링킹

app 실행체
-> libB.so의 b(), libC.so의 c() 함수 사용, libA.so의 aaa() 함수는 호출하지 않음
-> app 빌드시 -lB -lC 옵션으로 링킹

=> app 실행체 빌드시 링크 에러
uclibc/bin/ld: warning: libA.so, needed by libB.so, not found (try using -rpath or -rpath-link)
libA.so: undefined reference to `aaa'
=================================================================================================

app 실행체 빌드시 -lB -lC에 -lA 까지 주게 되면 빌드는 되지만
제가 원하는건 app 실행체를 빌드 시에 -lA 옵션을 주지않아도 빌드 시킬 수 있느냐는 점입니다.

물론 빌드가 성공했다면 app 를 실행할때 libA.so libB.so libC.so 를 링크 가능하도록 위치 시킵니다.

위에서 보면 아시겠지만
제가 원하는 건 app 실행체를 빌드 할때 libA.so 존재를 모르게 하기 위한겁니다.
해서 app 실행체 빌드시 -lA 를 넣어주지 않아도 컴파일 되게 하고 싶은데 방법이 없나요?

beggarstar의 이미지

reflesh

bushi의 이미지

GCC라면... 없습니다.

사실, 있기는 한데... app 에 -lA 붙여주는 것 보다 더 요란 뻑적지근해서 마음에 들지 않으실 겁니다.
그래도 알고 싶다면 GNU ld 옵션 메뉴얼에서 undefined symbol 에 대한 것을 찾아보세요.

beggarstar의 이미지

그렇군요 그 요란 뻑적지근(?) 한거라도 찾아봐야 겠습니다.
감사합니다

beggarstar의 이미지

libB.so 를 readElf로 읽어 보면 라이브러리 의존 정보를 볼수있습니다.
===============================================================================
Dynamic section at offset 0x94 contains 30 entries:
Tag Type Name/Value
0x00000001 (NEEDED) Shared library: [libdirectfb-1.4.so.5]
0x00000001 (NEEDED) Shared library: [libfusion-1.4.so.5]
0x00000001 (NEEDED) Shared library: [libdirect-1.4.so.5]
0x00000001 (NEEDED) Shared library: [libpthread.so.0]
0x00000001 (NEEDED) Shared library: [libc.so.0]
0x00000001 (NEEDED) Shared library: [libdl.so.0]
0x00000001 (NEEDED) Shared library: [libz.so.1]
0x00000001 (NEEDED) Shared library: [libm.so.0]
0x00000001 (NEEDED) Shared library: [libA.so]
===============================================================================
위를 보면 알 수 있듯이 libB.so빌드를 위해 libdirectfb.so, libA.so 등을 -l 옵션과 함께 사용해서 링크 시켜줬죠
근데 libc.so(printf등 사용을 위한 C 표준 라이브러리), libdirectfb-1.4.so 등의 라이브러리가 제가 만들어 넣은 libA.so와 뭐가 다른지
app 빌드시 -lc -ldirectfb-1.4 등은 빼줘도 에러가 안나는데 -lA를 빼주면 에러가 납니다...
" gcc -o app app.o -lB" 이런식으로 사용했습니다.

댓글 달기

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