libc - How to create a shared library (.so) having two functions with the same name -


i first compiled 2 object files (.o) :

  • string-memcpy.o
  • machine-memcpy.o

they both define function memcpy(). now, want create shared library (.so) :

gcc -shared -o test.so string-memcpy.o machine-memcpy.o 

this fails due "multiple definition of memcpy". there way ? thank you!

in fact encounter problem when trying compile shared library libc (newlib-1.16). can find on internet how build static library it. hint on how achieve appreciated.

a static library '.ar' file (a primitive predecessor tar) containing .o files . nothing involved in process knows or cares whether there symbol conflicts. if multiple .o files in .ar file contain same symbol, linker pick first 1 sees. if later tries use other .o file satisfy symbol, you'll error.

a shared lib, on other hand, linker output, , linker not willing create files duplicate symbol names.

there complex options ld might allow work around this, might make problems worse.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -