symbol(s) not found for architecture x86_64 - c++

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:
How do I go about fixing the issue?

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.

Related

SublimeText won't let me compile C++

I keep getting the same error on a simple piece of code after I downloaded multiple compilers and added them to 'PATH' in windows settings
Error :
E:\Programs\sublimeProjects\helloWorld: file not recognized: File format not recognized
collect2.exe: error: ld returned 1 exit status
[Finished in 985ms]
I downloaded multiple compilers and added them to 'PATH' in windows settings
This is a very bad idea. You will run into a complete mess where parts of one compiler interfere with parts of the other compiler due to them all being on the PATH.
I would recommend to immediately remove all compilers from the PATH. Instead, what you should do is have a batch file or shell script that you run to set up the environment for just that window.
Some compiler installations come already set up this way (e.g. mingw-w64/MSYS2).
In SublimeText you can set it to use that batch file or script to set up the build environment, e.g. see https://gist.github.com/sagebind/9039773048a3900fa49a .

C++ build failing on MacOS

I'm trying to run my C++ program on my Macbook and I'm trying to run my program in VSCode by running the build task C/C++:clang++ build active file. However, every time I do this I get this error ld: can't open output file for writing: /Users/admin/first/first, errno=21 for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) The terminal process terminated with exit code: 1
This appears to be a simple permission problem here:
ld: can't open output file for writing
The linker cannot write to the file specified.
Edit: As correctly pointed to by molbdnilo, the error 21 is EISDIR, which means the file you are trying to write to already exists as a directory. So ... just this folder? :)
Did you brew install any c++ tools? Sometimes that is the source of these issues. The program is trying to use native OS versions of things when it should use Homebrew's or vice versa.

SDL test project Build Failure Error Message using Eclipse C/C++ IDE 2020-06 on Windows 10

*This is my first programming course in over 20 years, so I am basically clueless.
I am trying to complete the last project in the course which includes installing and configuring SDL. Right now all I have is the basic "Hello World" code. I get the error when I add #include .
When I installed SDL, I copied the SDL2 folder and the entire lib folder to MinGW-w64 - as instructed by a tutorial.
I have MinGW-w64 installed. Here is the build error:
C:/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o):crt0_c.c:(.text.startup+0x2e): undefined reference to `WinMain'
collect2.exe: error: ld returned 1 exit status
I've been googling for hours and cannot seem to find any help.*
Edit:
Thank you both so much for your quick responses.
Here is what I did in settings:
Do I need to put an 'l' in front of these items?
I got some help elsewhere and added #define SDL_MAIN_HANDLED. This allowed the project to build, but it still doesn't run. I get nothing at all when I try to run it. I tried calling SDL_GetError(), but still nothing.
also make sure your main has the following signature:
int main(int, char**) - SDL is pretty militant about it

IOS integrated unity 4.6.3 project(64-bit && IL2CPP). Appear the following such a mistake, how to fix it?

I want to add Unity to an existing ios Project,I have matched all the configuration of the two project, and import the frameworks.
I set Other Linker Flags : -weak_framework; -weak-lSystem; CoreMotion. just like the Unity Project.
and the error is:
clang: error: no such file or directory: 'CoreMotion'
when I deleted "CoreMotion" in Other Linker Flags, error changes:
ld: framework not found -weak-lSystem
how to fix it?
I have found that the order of the flags are important
It should be in this order :
-weak_framework
CoreMotion
-weak-lSystem;

symbol(s) not found for architecture armv7 when importing cpp file from iOS Sample Project

All,
I have downloaded a Sample Project for Audio conversion:
https://developer.apple.com/LIBRARY/IOS/samplecode/iPhoneExtAudioFileConvertTest/Introduction/Intro.html
I had to take away all CAXException codes and CADebugPrintf codes. But then when I was trying to call the ExtAudioFileConvert.cpp's DoConvertFile function, it shows
"_DoConvertFile", referenced from:
....
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Please help.
Followed this post to remove "Preprocessor Macros" Setting
iOS,CoreAudio: a strange 'CADebugPrintf.h: no such file or directory ... ' error
and followed this post to add a .mm file as C++ wrapper to call DoConvertFile
How to add C/C++ functions to Objective-C code (iphone related)
Problem fixed!