g++ 링크 에러문제 입니다 2.9x.x 버전에서는 잘 되는데 3.x.x

바람이의 이미지

를 못가져오는 문제입니다.

SunOS 5.8 에서 gcc/g++ 2.95.2, 2.95.3일 경우에는 아무런 이상없이 a.out이 만들어집니다.
그러나 3.x 버전일 경우 (3.0.3, 3.4.2, 3.2.2에서 테스트 해 봤습니다) 컴파일 되더라도 링크시 JTCThread 관련 라이브러리를 못 찾는지 다음과 같은 에러메시지를 출력합니다.
라이브러리는 ./lib/libJTC.a 입니다

g++ -o exefile test1.o test2.o test3.o test4.o test5.o test6.o -REENTRANT -frepo -L. -lsocket -lnsl -lpthread -L/usr/local/lib/gcc-lib/spar
c-sun-solaris2.8/3.0.3 -L/usr/local/mysql/lib -fpermissive -lposix4 -lmysqlclient -L./lib -lJTC
test2.o: In function `main':
test2.o(.text+0x268): undefined reference to `JTCInitialize::JTCInitialize(int&, char**)'
test2.o(.text+0x324): undefined reference to `JTCThread::start()'
test2.o(.text+0x388): undefined reference to `JTCInitialize::~JTCInitialize()'
test2.o(.text+0x3a4): undefined reference to `JTCInitialize::~JTCInitialize()'
test5.o: In function `XXXXXX::test5::test5()':
test5.o(.text+0x258): undefined reference to `JTCThread::JTCThread(JTCHandleT<JTCRunnable>, char const*)'
test5.o(.text+0x268): undefined reference to `JTCMonitor::JTCMonitor()'
test5.o(.text+0x3e4): undefined reference to `JTCMonitor::~JTCMonitor()'
test5.o(.text+0x40c): undefined reference to `JTCThread::~JTCThread()'
test5.o: In function `XXXXXX::test5::test5()':
test5.o(.text+0x480): undefined reference to `JTCThread::JTCThread(JTCHandleT<JTCRunnable>, char const*)'
test5.o(.text+0x490): undefined reference to `JTCMonitor::JTCMonitor()'
test5.o(.text+0x610): undefined reference to `JTCMonitor::~JTCMonitor()'
test5.o(.text+0x63c): undefined reference to `JTCThread::~JTCThread()'
test5.o: In function `XXXXXX::test5::~test5()':
test5.o(.text+0x740): undefined reference to `JTCMonitor::~JTCMonitor()'
test5.o(.text+0x754): undefined reference to `JTCThread::~JTCThread()'
test5.o: In function `XXXXXX::test5::~test5()':
test5.o(.text+0x858): undefined reference to `JTCMonitor::~JTCMonitor()'
test5.o(.text+0x870): undefined reference to `JTCThread::~JTCThread()'
test5.o: In function `XXXXXX::test5::~test5()':
test5.o(.text+0x974): undefined reference to `JTCMonitor::~JTCMonitor()'
test5.o(.text+0x98c): undefined reference to `JTCThread::~JTCThread()'

여기에서 검색해보니 비슷한 경우가 있어서 순서도 바꾸어보고 해당 라이브러리를 직접 링크하도록 해봐도 여전합니다.
어떤 게시물에서 g++ 2.9x, g++ 3.0~3.1, g++ 3.3 이 세 버전간의 이진 호환성이 보장되지 않는다는 글과 함께 3.2.2를 설치해서 (저와는 다른 공개라이브러리였지만,) 해결했다는 글을 보고 g++ 3.2.2를 설치해서 해봐도 마찬가지입니다.
2.95.x 버전에서 3.x 버전으로 가면서 무엇이 달라졌나요?
이런 경우 어떻게 조치해주어야 할런지 고수님들 지도 바랍니다...

세이군의 이미지

libJTC를 G++3.2.2 로 컴파일 한 다음에 다시한번해보시는 것은 어떨까요??
( 소스가 없다면 대략난감이긴 한데.... -_-)

바람이의 이미지

달랑 libJTC.a 라이브러리 파일과 헤더파일만 가지고 있습니다.
저두 전임자로부터 받을때 JTCThread란걸 썼다 라는거만 전해듣고
문제가 없길래 그쪽은 신경도 쓰지 않았거든요.
오늘 www.ooc.com 가보니 상용 라이브러리인듯 하니 아마도 배포받을때도 libXXX.a 파일과 헤더파일만 제공받지않았나 싶습니다.
그럼 소스가 없다면 방법이 없는건가요?

늦은시간 관심갖고 답변 달아주신 drssay님 감사드립니다.

pynoos의 이미지

gcc 2.x와 gcc 3.x 로 각각 만들어진 C++의 library는 mangling 규칙이 다르기 때문에 서로 링크될 수 없습니다.

같은 컴파일러를 사용해야만 합니다.

가지고 계신것이 2.9x로 만들어진 .a 파일만 있다면, 2.9x로 컴파일러를 바꿔야겠군요.

바람이의 이미지

그렇지 않을까 의심해보기는 했지만... 역시나 그런거였군요.^^;;
명쾌한 답변 감사합니다.

댓글 달기

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