ld: symbol(s) not found for architecture arm64

Hi All,

I'm writing a c program on my m1 macbook, but when i compiled the project, error occurs:

Undefined symbols for architecture arm64:
  "_fp", referenced from:
      _main in main.c.o
  "_init", referenced from:
      _main in main.c.o
ld: symbol(s) not found for architecture arm64

and also, when i exec ld command, it will return some warnings:

ld: warning: platform not specified
ld: warning: -arch not specified
ld: warning: No platform min-version specified on command line
ld: no object files specified

I only install the xcode command line tools and use vscode, i believe it's a link problem but have no idea if it's a bug or my config fault.

Someone has any idea?Thanks

It’s hard to say what’s going on here because you’ve not provided any details about your code or the commands you use to compile your code. Here’s a minimal example of compiling code on an Apple silicon Mac using command-line tools:

% mkdir test
% cd test
% cat > main.c
#include <stdio.h>

int main(int argc, char ** argv) {
    printf("Hello Cruel World!\n");
}
^D
% clang main.c
% ./a.out
Hello Cruel World!

Does this example work on your machine? If so, tweak it to replicate the problem and then post the details here.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

It turns out that it was an error in my Makefile and ld can't find some functions. I thought it was an error related to platforms as the error messege refers to arm64.

Sorry for the ambigious message as it's not a personal project so I can only intercept a few message related to the possible error.

Thank you all the same.

I'm facing the same error!

Well, it seems like a related error, but it’s hard to be sure because of the formatting of your post. I recommend that you start a new thread and put the info in there. Use the same tags so that I see it go by. And feel free to reference this thread if you think the context would be valuable.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

ld: symbol(s) not found for architecture arm64
 
 
Q