3

I am compiling a program on AIX. It is compiled successfully but gives following warnings:

ld: 0711-224 WARNING: Duplicate symbol: .basename
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.

I tried to find this symbol I found in my "common.o" file.

nm -X64 -f common.o | fgrep '.basename'

.basename            T        3776         120

But when find this symbol on executable I find following:

nm -X64 CCF | fgrep '.basename'
.basename            T  4295089984         120
.basename            T  4295174672
.basename            t  4295174672          40
  • Can I display the libraries name that contains this symbol?

  • Does this symbol present in my source file ? (may be sound silly but I do not really know)

I have find the answer to this question that it can be traced in source.

  • What steps should I take to remove this warning? Also does this duplicate symbol can cause application crash? In my case it is crashing.
QMG
  • 719
  • 2
  • 7
  • 16
  • Did you take the linker's suggestion? `Use the -bloadmap or -bnoquiet option to obtain more information.` – Ed S. Sep 27 '12 at 20:19
  • I did not try but I change the function name in my sources. Now the duplicate symbol warning is no more there. – QMG Sep 28 '12 at 09:49

1 Answers1

1

According to the man page, there are two versions of basename(), one POSIX and one GNU, and it looks like you are linking in both of them. You will need to choose one and suppress the other, depending on your needs. The man page explains how.

Because they behave differently, code that is compiled for one will likely crash when the linker/loader binds it to the other one. If you have a choice of compilers, choosing the non-gcc one might help.

Randall Cook
  • 6,728
  • 6
  • 33
  • 68
  • Thank for your reply. Does this warning cause program crash? – QMG Sep 28 '12 at 09:48
  • 1
    Probably. Code compiled for one version of a library can crash when it is linked at runtime against another version. This happens in C++ all the time when you mix code and libraries from different gcc/g++ versions. – Randall Cook Sep 28 '12 at 13:31
  • Thank Randall for reply. removed this warning but it seems like some other area is also causing memory leaking :( on AIX – QMG Sep 28 '12 at 14:55
  • No problem, QMG. Good luck with your memory leak. If you found my answer useful, please consider upvoting or accepting it. :) – Randall Cook Sep 28 '12 at 16:06