0

I have two libraries libA, libB and an application 'app'. libB uses functions from libA, and 'app' uses symbols from both libraries. I added two new functions - 'print_data' and 'print_data_char' to libA which I call only in libB, and now getting:

undefined reference to 'print_data'
undefined reference to 'print_data_char'

Here is the actual command

arceb-linux-gcc apps/applications/dpi/dpi_app/build/Obj_linux_arc_sim/src/main.o apps/applications/dpi/dpi_app/build/Obj_linux_arc_sim/src/utl.o ./dpe/dp/lib/ezdp_linux_arc_sim.a ./dpe/sft/lib/sft_linux_arc_sim.a ./dpe/dpi/lib/dpi_linux_arc_sim.a  -O2 -o apps/applications/dpi/dpi_app/bin/ezdpi_app_linux_arc_sim

libA = sft_linux_arc_sim.a

libB = dpi_linux_arc_sim.a

I checked libA with nm:

ezpacket_internal.o:
00000001 a __ARCCOMPACT__
         U __udivsi3
         U fprintf
         U fputc
         U fputs
         U fwrite
0000001c T print_data
00000000 T print_data_char

Also there are other symbols in libA which libB does recognize. It seems that only the two new symbols are missing.

Any ideas?

Thanks in advance.

Elad Weiss
  • 3,662
  • 3
  • 22
  • 50

1 Answers1

0

Ghosh's answer: -lA -lB -lA -lB fixed it :)

(It took me about an hour to understand that it's not a typo)

Apparantly there is importance to the lib order when linking. See: https://stackoverflow.com/questions/45135/...

In fact I believe even -lB -lA would solve it :)

Thanks!

Community
  • 1
  • 1
Elad Weiss
  • 3,662
  • 3
  • 22
  • 50