Object files not added to archive on Mac

I am trying to create an archive from a collection of object files. I do this with

ar -rs my_archive.a foo.o bar.o other_object_files.o

...

Everything is fine on linux machine, but when I try to execute the same command on my mac, only some object files seem to be added. This results in undefined characters corresponding to subroutines, for example other_object_files.o

.

Also, if I try to manually link the object files that resulted in undefined characters, I can create the executable correctly.

it

ifort -o my_exec main.o other_object_files.o my_archive.a

      

works great.

Is there not enough difference between linux and mac regarding this?

EDIT

From the nm other_object_files.o

symbols they look great, so they really look like something that wasn't added to the archive incorrectly.

Here are a few lines of the file on my_archive.a

both linux and mac (object names and archive files are, of course, different)

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 and

libtool -static -arch_only x86_64 -o my_archive.a foo.o bar.o other_object_files.o

after this SO post , but again no progress.

+2


source to share


1 answer


The problem is, by default, common characters are not added by default.

Option 1:

ar -rs my_archive.a foo.o bar.o other_object_files.o ranlib -c my_archive.a



Option 2:

libtool -c -static -o my_archive.a foo.o bar.o other_object_files.o

+2


source







All Articles