Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fails on macOS due to linker error #58

Open
dg1yfe opened this issue Jul 14, 2019 · 2 comments
Open

Build fails on macOS due to linker error #58

dg1yfe opened this issue Jul 14, 2019 · 2 comments

Comments

@dg1yfe
Copy link

dg1yfe commented Jul 14, 2019

Hi,

for some reason the linker fails when building on/for macOS (10.13.6):

[eligs@aquila ~/projects/necpp:master] make
/Applications/Xcode.app/Contents/Developer/usr/bin/make  all-recursive
Making all in src
/bin/sh ../libtool  --tag=CXX   --mode=link g++  -g -O2 -all-static  -o nec2++ nec2cpp.o XGetopt.o libnecpp.la -lm 
libtool: warning: complete static linking is impossible in this configuration
libtool: link: g++ -g -O2 -o nec2++ nec2cpp.o XGetopt.o -Wl,-bind_at_load  ./.libs/libnecpp.a -lstdc++ -lm
ld: warning: ignoring file ./.libs/libnecpp.a, file was built for archive which is not the architecture being linked (x86_64): ./.libs/libnecpp.a

Due to the lib not being used, a lot of 'undefined Symbol' errors follow:

Undefined symbols for architecture x86_64:
  "usage()", referenced from:
      nec_main(int, char**, nec_output_file&) in nec2cpp.o
  "secnds(double*)", referenced from:
      nec_main(int, char**, nec_output_file&) in nec2cpp.o
  "load_line(char*, __sFILE*)", referenced from:
      nec_main(int, char**, nec_output_file&) in nec2cpp.o
      readmn(__sFILE*, __sFILE*, char*, int*, int*, int*, int*, double*, double*, double*, double*, double*, double*) in nec2cpp.o
(and so on)

When I probe libnecpp.a with objdump, it tells me things are build for mach-o-x86-64:

[eligs@aquila ~/projects/necpp:master] objdump -a src/.libs/libnecpp.a        
In archive src/.libs/libnecpp.a:

libnecpp_la-c_evlcom.o:     file format mach-o-x86-64
rw-r--r-- 0/0 294608 Jan  1 01:00 1970 libnecpp_la-c_evlcom.o
(and so on...)

So ... when the lib is built for 64 Bit x86, why does the linker refuse to use it?
Would it be possible/of some use to link dynamically instead of static?
Since I'm not that familiar with autotools and linking against libraries, I'm kind of lost here and would appreciate any help to get this project to build.
Thanks.

@dg1yfe
Copy link
Author

dg1yfe commented Jul 14, 2019

Some digging in the web resolved this issue (still don't understand the reasons):
After disabling the binutils installed via homebrew ('brew unlink binutils'), the project builds.

@tmolteno
Copy link
Owner

Thanks for looking into this. I'll leave this issue open, and close it after documenting in INSTALL.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants