I am trying to build an archive from a collection of object files. I am doing this with
ar -rs my_archive.a foo.o bar.o other_object_files.o
.
On a linux machine everything is fine but when I try the very same command on my mac it seems like only some object files are added. This results in undefined symbols corresponding to subroutines in, let's say, other_object_files.o
.
Moreover, if I try to manually link the object files that gave rise to undefined symbols, I can properly build the executable.
That is
ifort -o my_exec main.o other_object_files.o my_archive.a
works fine.
Am I missing some difference between linux and mac regarding this?
EDIT
From nm other_object_files.o
the symbols look fine, so it is really like they where not properly added to the archive.
Here are some lines of the my_archive.a
file in both linux and mac (the names of the object and archive files are different of course)
Linux:
ed_2.1-opt.a:decomp_coms.o:0000000000000000 T decomp_coms._
ed_2.1-opt.a:decomp_coms.o:0000000000000038 R decomp_coms___debug_param_const
ed_2.1-opt.a:decomp_coms.o:0000000000000030 D decomp_coms_mp_cwd_frac_
ed_2.1-opt.a:decomp_coms.o:0000000000000008 D decomp_coms_mp_decay_rate_fsc_
ed_2.1-opt.a:decomp_coms.o:0000000000000000 D decomp_coms_mp_decay_rate_ssc_
ed_2.1-opt.a:decomp_coms.o:0000000000000010 D decomp_coms_mp_decay_rate_stsc_
ed_2.1-opt.a:decomp_coms.o:0000000000000004 C decomp_coms_mp_decomp_scheme_
ed_2.1-opt.a:decomp_coms.o:0000000000000044 C decomp_coms_mp_f_labile_
Mac:
ed_2.1-opt.a:decomp_coms.o: 0000000000000000 T _decomp_coms._
ed_2.1-opt.a:decomp_coms.o: 000000000000058c S _decomp_coms._.eh
ed_2.1-opt.a:decomp_coms.o: 0000000000000010 C _decomp_coms_mp_cwd_frac_
ed_2.1-opt.a:decomp_coms.o: 0000000000000010 C _decomp_coms_mp_decay_rate_fsc_
ed_2.1-opt.a:decomp_coms.o: 0000000000000010 C _decomp_coms_mp_decay_rate_ssc_
ed_2.1-opt.a:decomp_coms.o: 0000000000000010 C _decomp_coms_mp_decay_rate_stsc_
ed_2.1-opt.a:decomp_coms.o: 0000000000000010 C _decomp_coms_mp_decomp_scheme_
ed_2.1-opt.a:decomp_coms.o: 0000000000000050 C _decomp_coms_mp_f_labile_
EDIT
Tried also
libtool -static -arch_only x86_64 -o my_archive.a foo.o bar.o other_object_files.o
following this SO post but again no progress.
ar -rs my_archive.a foo.o bar.o other_object_files.o
ranlib my_archive.a
but with no success. – Formula