Error “ld: symbol not found for architecture x86_64”

Muhammad Muizzsuddin
1 min readJun 2, 2019

--

This article has been posted for more information in https://mozzlog.com/blog/ld-symbol-not-found-for-architecture

Before you read: Invitation to Network Spy

Wait. Thank you for stopping by. This is a special invitation. You can jump to read the article if you want. 🙌

With Network Spy, you can monitor, inspect, and modify your network traffic during development. Perfect for debugging and more analysis. 🙌 Join the Waitlist Today! https://mozzlog.com/projects/network-spy

This error indicates that your code, usually from the C family language, has imported a header but has not yet been linked to it’s implementation.

For example, there is a header SimpleMath.h

// SimpleMath.hint divide_by_zero(int i);

Then we import it intomain.c

// main.c#include "SimpleMath.h"int main() {
int result = divide_by_zero(100);
printf("Result is %d", result);
}

When we compile it without implementation of SimpleMath.h then we we’ll get ld: symbol not ... (bla-bla-bla)

The solution is to compile it with SimpleMath.c

clang main.c SimpleMath.c -o program

Or to link it with system implementation if there any.

clang main.c -LSimpleMath -o program

Fixed? Not yet. You’ll want to read more about C language then.

Oh yes, our SimpleMath.c implementation is

// SimpleMath.c#include "SimpleMath.h"int divide_by_zero(int i) {
exit(1);
}

Happy fixing error!

--

--

No responses yet