0

I'm getting this error message when I tried to compile "respknt" program under Rosetta 2 on my macOS-arm64 (apple silicon/M1 chip):

gfortran -g runtest.o runcmd.o -o bin//runtest

ld: warning: ignoring file runtest.o, building for macOS-arm64 but attempting to link with file built for macOS-x86_64

ld: warning: ignoring file runcmd.o, building for macOS-arm64 but attempting to link with file built for macOS-x86_64

Undefined symbols for architecture arm64: "_main", referenced from:

 implicit entry/start for main executable

ld: symbol(s) not found for architecture arm64

collect2: error: ld returned 1 exit status

make: *** [runtest] Error 1.

Please note that, "respknt" is a seismological software that is built on reflection matrix method of Kenneth 1986.

I switched the architecture on my Mac terminal from arm64 to MacOS x86_64 to test if I could compile the "respknt" program. I even verified if I have switched the architecture to MacOS x86_64 by invoking the "gcc -v" command:

Apple clang version 14.0.0 (clang-1400.0.29.202)

Target: x86_64-apple-darwin22.3.0 Thread model: posix

InstalledDir: /Library/Developer/CommandLineTools/usr/bin.

Also, I got "i386" when I invoked "arch" command.

I would appreciate it if you could tell me what I'm doing wrong. Thank you for your time!

6
  • This question is similar to: What is an undefined reference/unresolved external symbol error and how do I fix it?. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. (Also see stackoverflow.com/q/70057202/62576). Please always search for error messages before posting. This question has been asked many, many times before.) Commented Aug 16, 2024 at 1:06
  • The relevant portion of the error you posted is in Undefined symbols for architecture arm64: "_main". Commented Aug 16, 2024 at 1:10
  • How were runtest.o and runcmd.o compiled? Are you using that GitHub repo that has object files and .DS_Store committed? If so, then my guess is that your gfortran is actually arm64-only and cannot produce Intel binaries. Commented Aug 16, 2024 at 3:14
  • @KenWhite different issue. The OP is neither failing to link against a library nor to supply the relevant object files on the command line - the error is due to the linker skipping the provided object files because there seems to be some mismatch on the selected target architecture. Commented Aug 16, 2024 at 3:15
  • @Siguza: Then please explain to me why a gold badge user used it as a reason to close this question that contains the same exact error message. Commented Aug 16, 2024 at 3:20

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.