ld: 9 duplicate symbols for architecture x86_64
is the final error I receive when I attempt to make a dylib on MacOS using these files -> main.c, subhook_unix.o, subhook_x86.o, subhook.o.
This is the command I used: g -dynamiclib -fPIC -o Gexecute.dylib subhook_unix.o subhook_x86.o subhook.o
Below is the returned error.
subhook_x86.o
subhook.o
duplicate symbol '_subhook_read_dst' in:
subhook_x86.o
subhook.o
duplicate symbol '_subhook_unprotect' in:
subhook_unix.o
subhook.o
duplicate symbol '_subhook_disasm' in:
subhook_x86.o
subhook.o
duplicate symbol '_subhook_install' in:
subhook_x86.o
subhook.o
duplicate symbol '_subhook_remove' in:
subhook_x86.o
subhook.o
duplicate symbol '_subhook_free' in:
subhook_x86.o
subhook.o
duplicate symbol '_subhook_free_code' in:
subhook_unix.o
subhook.o
duplicate symbol '_subhook_alloc_code' in:
subhook_unix.o
subhook.o
I predict that I have used either the incorrect command, or the code in the .o files has errors.
CodePudding user response:
It looks like that you link three version of a same lib, of course there are same function or variable names among them. Try only link one of them.