C++ Linker Errors on M1 macbook.

Ive tried to fix this error for a couple of days now and everything i do just seem's to not work. I am using gcc/clang on the latest updated version and xcode.

This is the code im trying to compile:

#include <iostream>
int main(){
std::cout << "hello world";
return 0;
}

Specifically its a Linker error saying this: ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Another clue I found within the hundred thousand lines of error codes was this:

Undefined symbols for architecture arm64:
 "std::__1::locale::use_facet(std::__1::locale::id&) const", referenced from:
   std::__1::ctype<char> const& std::__1::use_facet<std::__1::ctype<char> >(std::__1::locale const&) in cardvalid-55edf7.o

And it keeps going with these references for a while. My guess is that it has something to do with the stdlib but im not sure. I have tried to uninstall xcode and reinstall it to no luck. If anybody has some idea it would be greatly apreciated.

Are you targeting aarm64?

The fragment of error that you've posted doesn't have enough info to diagnose this.

Maybe post all 100,000 lines of errors? Someone might spot the problem.

My guess is that you have something slightly borked in your build settings.

Are you building your project with Xcode? Or from the command line?

If you’re building from Xcode, create a new test project from the macOS > Command Line Tool template, choose C++ as your language, and try building that. Does that fail similarly?

Share and Enjoy

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

All the error's:

2022-08-31 15:51:04.636 xcodebuild[3182:15874] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionSentinelHostApplications for extension Xcode.DebuggerFoundation.AppExtensionHosts.watchOS of plug-in com.apple.dt.IDEWatchSupportCore 2022-08-31 15:51:04.637 xcodebuild[3182:15874] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionPointIdentifierToBundleIdentifier for extension Xcode.DebuggerFoundation.AppExtensionToBundleIdentifierMap.watchOS of plug-in com.apple.dt.IDEWatchSupportCore Undefined symbols for architecture arm64:  "std::__1::locale::use_facet(std::__1::locale::id&) const", referenced from:    std::__1::ctype const& std::__1::use_facet<std::__1::ctype >(std::__1::locale const&) in main-07c96a.o  "std::__1::ios_base::getloc() const", referenced from:    std::__1::basic_ios<char, std::__1::char_traits >::widen(char) const in main-07c96a.o  "std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >::__init(unsigned long, char)", referenced from:    std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >::basic_string(unsigned long, char) in main-07c96a.o  "std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >::~basic_string()", referenced from:    std::__1::ostreambuf_iterator<char, std::__1::char_traits > std::__1::__pad_and_output<char, std::__1::char_traits >(std::__1::ostreambuf_iterator<char, std::__1::char_traits >, char const*, char const*, char const*, std::__1::ios_base&, char) in main-07c96a.o  "std::__1::basic_ostream<char, std::__1::char_traits >::sentry::sentry(std::__1::basic_ostream<char, std::__1::char_traits >&)", referenced from:    std::__1::basic_ostream<char, std::__1::char_traits >& std::__1::__put_character_sequence<char, std::__1::char_traits >(std::__1::basic_ostream<char, std::__1::char_traits >&, char const*, unsigned long) in main-07c96a.o  "std::__1::basic_ostream<char, std::__1::char_traits >::sentry::~sentry()", referenced from:    std::__1::basic_ostream<char, std::__1::char_traits >& std::__1::__put_character_sequence<char, std::__1::char_traits >(std::__1::basic_ostream<char, std::__1::char_traits >&, char const*, unsigned long) in main-07c96a.o  "std::__1::cout", referenced from:    _main in main-07c96a.o  "std::__1::ctype::id", referenced from:    std::__1::ctype const& std::__1::use_facet<std::__1::ctype >(std::__1::locale const&) in main-07c96a.o  "std::__1::locale::~locale()", referenced from:    std::__1::basic_ios<char, std::__1::char_traits >::widen(char) const in main-07c96a.o  "std::__1::ios_base::__set_badbit_and_consider_rethrow()", referenced from:    std::__1::basic_ostream<char, std::__1::char_traits >& std::__1::__put_character_sequence<char, std::__1::char_traits >(std::__1::basic_ostream<char, std::__1::char_traits >&, char const*, unsigned long) in main-07c96a.o  "std::__1::ios_base::clear(unsigned int)", referenced from:    std::__1::ios_base::setstate(unsigned int) in main-07c96a.o  "std::terminate()", referenced from:    ___clang_call_terminate in main-07c96a.o  "___cxa_begin_catch", referenced from:    std::__1::basic_ostream<char, std::__1::char_traits >& std::__1::__put_character_sequence<char, std::__1::char_traits >(std::__1::basic_ostream<char, std::__1::char_traits >&, char const*, unsigned long) in main-07c96a.o    ___clang_call_terminate in main-07c96a.o  "___cxa_call_unexpected", referenced from:    std::__1::ostreambuf_iterator<char, std::__1::char_traits >::failed() const in main-07c96a.o    std::__1::ostreambuf_iterator<char, std::__1::char_traits >::ostreambuf_iterator(std::__1::basic_ostream<char, std::__1::char_traits >&) in main-07c96a.o  "___cxa_end_catch", referenced from:    std::__1::basic_ostream<char, std::__1::char_traits >& std::__1::__put_character_sequence<char, std::__1::char_traits >(std::__1::basic_ostream<char, std::__1::char_traits >&, char const*, unsigned long) in main-07c96a.o  "___gxx_personality_v0", referenced from:    std::__1::basic_ostream<char, std::__1::char_traits >& std::__1::__put_character_sequence<char, std::__1::char_traits >(std::__1::basic_ostream<char, std::__1::char_traits >&, char const*, unsigned long) in main-07c96a.o    std::__1::ostreambuf_iterator<char, std::__1::char_traits > std::__1::__pad_and_output<char, std::__1::char_traits >(std::__1::ostreambuf_iterator<char, std::__1::char_traits >, char const*, char const*, char const*, std::__1::ios_base&, char) in main-07c96a.o    std::__1::ostreambuf_iterator<char, std::__1::char_traits >::failed() const in main-07c96a.o    std::__1::ostreambuf_iterator<char, std::__1::char_traits >::ostreambuf_iterator(std::__1::basic_ostream<char, std::__1::char_traits >&) in main-07c96a.o    std::__1::basic_ios<char, std::__1::char_traits >::widen(char) const in main-07c96a.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

It compiles fine with xcode

Cool. That’s good because it establishes a known working case.

however is dislike the IDE very much and prefer to use the commandline.

You do you!

Which is why is suspect that xcode can compile but gcc cant.

OK, I need to clarify one point here:

  • Are you actually using GCC? That is, have you gone out of your way to install the GCC toolchain?

  • Or are you just using GCC as a synonym for C compiler?

This matters because the [Objective]C[++] compiler built in to Xcode is Clang, and I can definitely help you with that. However, if you’re using actual GCC, you’ll need to get help from its support channel.

Share and Enjoy

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

C++ Linker Errors on M1 macbook.
 
 
Q