1

Ive downloaded a sample code from here, but when I try opening it using visual studio code, I keep getting the following error:

ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation

I have tried using xCode but this time it wont open at all, As it can be figured Im using a mac, with the m1 chip to be precise.

This is a picture of the error: enter image description here

How do I go about fixing the issue?

Reza Rahemtola
  • 1,182
  • 7
  • 16
  • 30
Brad
  • 11
  • 3
  • Not enough information in the post be be able to give much help. Could be you've misconfigured Visual Studio Code, could be you've misconfigured the project, could be a lot of things. You'd help yourself out quite a bit if you added the full build output (the little bit you showed will be preceded by diagnostics saying what went wrong in detail) to the question as text (do NOT take and post a picture). We probably still won't be able to solve the problem outright, but we'll have a better idea of what else you'll need to show. – user4581301 Jun 24 '21 at 23:13
  • 1
    General rule of thumb: Process the errors top to bottom. Often fixing the top one will eliminate several below it. – user4581301 Jun 24 '21 at 23:16
  • @user4581301 would you kindly give an example, I opened the filefolder using file>open>(thefolder) in visual studio code, I opened other files before using the software but mostly are one single page this one contains a header file and cpp file. Not sure what you mean by "misconfigured visual studio code" ? – Brad Jun 24 '21 at 23:28
  • I'd love to rake in the sweet sweet rep and adulation from helping you out with your question, but I don't have enough information to be able to give you a useful example. All I can do is repeat what I said above, hopefully with better wording this time. *ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation* is the end of the linker output. It contains no useful information by itself. The good stuff is in the messages that came before it. Add the full build output to the question and we can start to help you. – user4581301 Jun 24 '21 at 23:54
  • The relevant part of the error message is not the one you put in the title. It's **symbol(s) not found for architecture x86_64**, which you can use as a search expression here on this site or via your favorite search engine. – Ken White Jun 25 '21 at 00:00
  • thanks for pointing out, I just added a picture of the error, and modified the title. Hope that helps clear out the issue. – Brad Jun 25 '21 at 00:03
  • Did you miss what I said about using it as a search expression? :-) Have you tried searching this site with what you've got in your post title now? – Ken White Jun 25 '21 at 00:13
  • Note that it's really hard to search pictures of code or error messages. This is why I said not to post a picture earlier. Unless the question is about the image, a rendering error for example, all a picture is good for around here is collecting downvotes and scorn. In this case it does allow me to throw you a bone: Upgrade your compiler. The one you are using is too old to compile your code without adding extra compiler commands to tell it to compile to the 2011 C++ Standard revision. In 2021 this should be on by default with the 2020 Standard being opt-in. – user4581301 Jun 25 '21 at 00:25
  • @user4581301 The compiler tells me that no update is available, I checked for the version and this is what came up: Version: 1.57.1 Commit: 507ce72a4466fbb27b715c3722558bb15afa9f48 Date: 2021-06-17T13:28:32.912Z (1 wk ago) Electron: 12.0.7 Chrome: 89.0.4389.128 Node.js: 14.16.0 V8: 8.9.255.25-electron.0 OS: Darwin x64 20.1.0 – Brad Jun 25 '21 at 00:31
  • @Ken White Yea I did check this possibility, still not finding the problem. – Brad Jun 25 '21 at 00:32
  • You looked at all 3,900+ questions with that title? – Ken White Jun 25 '21 at 00:46
  • Odd. I need to go back to clang 5 (2017) to get the `auto` warning message. clang 9 or better is what I'd consider up to date. Tell Visual Studio Code to compile for at least C++11. Not sure where you put this in, but [this looks promising](https://stackoverflow.com/questions/53995830/compiling-c11-in-visual-studio-code) – user4581301 Jun 25 '21 at 01:06

1 Answers1

0

One can modify the configuration of Visual Studio code to support multiple files (header(s) and cpp ) running simultaneously on Mac.

  • Step 1

On the Virtual studio menu bar select ->terminal->configure task->Select the first option(C_Cpp_Runner)

  • Step 2

Go ahead and open the file folder in VS Code ->cmd+O ->select the file folder (with cpp and header included.)

At this point try running the code, if the same error still persist then, do Cmd+shift+P and make sure the Auto-header extension is installed.

That's what helped fixing my issue, hope it can benefit someone else out there.

Brad
  • 11
  • 3