Undefined symbols for architecture x86_64: “_main”, referenced from: implicit entry/start for main executable ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Explanation:

This error message is produced by the linker when it cannot find the definition for the “main” function in your code. The “main” function is the entry point of a C/C++ program, and it must be defined for the program to run correctly.

The error message also mentions the architecture x86_64, which indicates that the issue is specific to 64-bit systems. It states that the symbols needed for the architecture are not found, resulting in a linker error.

Example:

Let’s consider a simple C program:

#include 

void someFunction() {
    printf("Hello, World!\n");
}

int main() {
    someFunction();
    return 0;
}

In this example, we define a function called “someFunction” that prints “Hello, World!”. The “main” function then calls this function before returning 0.

If we try to compile this program without a “main” function, we will encounter the error message mentioned in the query:

Undefined symbols for architecture x86_64:
   "_main", referenced from:
       implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

This error occurs because our code lacks a “main” function, which is necessary in order to run the program successfully. Adding the missing “main” function will resolve this error.

Read more interesting post

Leave a comment