Homebrew: brew.sh/ See the updated video for installation on Apple Silicon: • Install GCC on Macs wi... On the newer Macbooks with the Apple M1, M2, M3 processor, look for g++ in /opt/homebrew/bin
Thanks a ton. Most online resources tell you to install Xcode but it is extremely large for my small storage MacBook, now I can simply use brew install gcc without having the big Xcode and can compile my c++ and c files. Hooray!
while linking g++-11 to g++ , I got an error saying: operation not permitted. What should I do now. Also I am not seeing the g++-11 directory in the bin directory. It is just g++ and GCC (not with their versions).
In April 2023, the path for homebrew gcc is in opt directory, to get the g++ alias set to g++ from clang, just add the full path of g++ file in the ln command.
hey so i did all the steps but i have this error whenever i run my c++ code. "init-statement in selection statements only available with '-std=c++17' or '-std=gnu++17'" I understand I can just write -std=c++17 after g++ but is it possible to just use g++ without writing -std=c++17 everytime i run my code? I'm not sure if this is related to what I installed or not, but if you have an idea to help it would be appreciated. thanks!
You will need to add that command until g++ is updated to make the C++17 standard the default. Another option would be to adapt your C++ code so that it doesn't use C++17 features. One more option is to use a compile script like make to automatically pass the desired arguments to g++.
Sir "cd /usr/local/bin/" this line is not working .....my terminal says "cd: no such file or directory: /usr/local/bin/". And there is no issue when i try to run "brew install gcc"..installation was successful...Please help!!!
boss.i am having this error....what should i do... Updating Homebrew... Error: The following directories are not writable by your user: /usr/local/share/doc /usr/local/share/man /usr/local/share/man/man1 You should change the ownership of these directories to your user. sudo chown -R $(whoami) /usr/local/share/doc /usr/local/share/man /usr/local/share/man/man1 And make sure that your user has write permission. chmod u+w /usr/local/share/doc /usr/local/share/man /usr/local/share/man/man1
I think running the recommended commands in that error output should solve your problem. sudo chown -R $(whoami) /usr/local/share/doc /usr/local/share/man /usr/local/share/man/man1 chmod u+w /usr/local/share/doc /usr/local/share/man /usr/local/share/man/man1
Dr Hayes, How to run gdb? I get this error: Unable to find Mach task port for process-id 38330: (os/kern) failure (0x5). (please check gdb is codesigned - see taskgated(8))
Hey! @Dr.Hayes I have done my part till downloading the GCC using brew. But I am facing problem after that, I am not familiar with my location. And also I have already installed Xcode commands . It would be nice if you look towards this problem. Thank you!
@@fahadadil2209 I recommend trying again and noting the particular error message. Those messages give important information on what went wrong. If you post the exact message here, others may be able to help you.
Hey there, I followed the steps you said, however I need to work on vs code and I can't set up the environment I don't why, could you please help me out?
This video helped a lot, sometimes I wonder how people learns this kind of little stuff that are not on the web, I mean, What do they read? or What do they see?
Used homebrew installed gcc. There is a gcc in /usr/bin and it has the same inode as clang. I could not remove /usr/bin/gcc to create sym link to real gcc in /usr/local/bin/... sh-3.2# cd /usr/bin sh-3.2# ls -l gcc clang -rwxr-xr-x 76 root wheel 167120 Mar 26 01:21 clang -rwxr-xr-x 76 root wheel 167120 Mar 26 01:21 gcc sh-3.2# rm -f gcc rm: gcc: Operation not permitted sh-3.2# whoami root what is going on??? thanks!
Can you also help me running clang properly. As you probably know on a mac, in x-code my cpp files run fine, they run c++ 11 or 17 no problem . BUT when I try to run clang from the terminal it seems to only run an older version of c++ because for instance if my program has "int num1{}" it's seen as an error. Same problem with other text editors such as Atom or TextMate. What manipulation would I need to do to be able to run the latest versions of cpp from the terminal and text editors?? thank you so much if you can help. I would even do a live call with you and pay you if you can help me
Hello sir, could you please make a video on how MINGW or GCC can be installed on the new M1 chip? How can I run my code with GCC on my M1? It would help me a lot.
Hi. When I copied the brew.sh link into the terminal and started the installation it showed up a window that it cant be installed since its not available at the server at the moment? What does this depend on? Thanks!
Hey Dr. Hayes, I followed the steps, ran home brew, ran gcc and then ran the 'ln' command but my terminal is still showing 'clang' upon entering gcc and/or g++. Please provide assistance. Thanks.
Hi I'm getting the following error Error: The following formula gcc cannot be installed as binary package and must be built from source. Install the Command Line Tools: xcode-select --instal
is there not a site to just be able to down load GCC for Mac. my PC is no longer working and all I use is Mac but I don't understand anything you did because I didn't see where you used the program
Hello. I have tried several times to make this work. However, the process fails when I get to "ls" - the output I get is not the same as yours (I bear in mind that the update is 10.2 and not 8.2). When I try to proceed from there typing: ln -s g++-10 g++, I get this response: ln: g++: permission denied. What should I do?
If Homebrew properly installed GCC, you should have g++10 displayed in the list when you type ls. If not, that needs to be addressed before adding the link with the ln command. If you do see g++10, then the problem may be that you don't have admin writes to make the link. In that case, you may try adding sudo to the beginning of the command: sudo ln -s g++-10 g++
@@ProgrammingwithDrHayes Thank you for your response. I have checked several times if the GCC is properly installed and it is. However when typing ls it g++10 is not displayed, unfortunately. Do you have any idea why that might be? What is displayed on my screen is: Info, Install info, Make info, pdftexi2dvi, pod2texi etc.
@@lailaem8618 I may not be much help to you; I haven't experienced a setup like yours. Are you sure you are in /usr/local/bin? Does the compiler run when typing g++10? If not, you will need to rerun the Homebrew step to get it properly installed and confirm there are no errors in the output.
I would like to install gcc++ to work with Atom/PlatformIO without interfering with Xcode's use of clang. Is it possible to install gcc++ in a manner (rename/relocate) so that Xcode does not find it?
Try compiling from the terminal. If that works, then it may mean that xcode is not using the g++ compiler. I don't use xcode or bits/stdc++, so this is just my recommendation for tracking down the problem. If you figure it out, I would love to hear your solution!
I have a mac and downloaded x code along with the required command line tools but my code blocks doesn't read data from any txt files or display data into txt files, could this fix that or is this another issue? it always says "No such file or directory" but they do exist.
Are you saying that g++ doesn't read your files? The files need to have a valid C++ extension like .cpp, not .txt. I recommend you watch my video about compiling your first program. ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-hk9yiBfSd8Y.html
@@ProgrammingwithDrHayes thank you! , The program does compile other programs but I meant that it is not reading data from txt files like when you use fstream this is for my college course and the professor uses windows but I use a mac so idk what is wrong 😭
@@jannireambriz5522 Perhaps your text files are not in the same folder as your executable. Your comment is more related to my video on writing to files ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-MMp4zV05R5k.html or reading from files ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-QnCVoYnLIg8.html
The last step may make it easier for Netbeans to auto-recognize the compiler. However, I don't think you need to perform the last step. Instead, you can instruct Netbeans to to compile with gcc-8 or g++-8 in your project settings.
I think they change the file g++ goes to since when I tried to install gcc, it said ==> Pouring gcc--11.2.0.arm64_big_sur.bottle.tar.gz 🍺 /opt/homebrew/Cellar/gcc/11.2.0 When I looked at your Terminal, it said /usr/local/Cellar/gcc/8.2.0 instead of /opt/homebrew/Cellar/gcc/11.2.0 Therefore, I think that Big Sur has changed the directory it goes to.
I have tested this installation process on a fresh installation of Big Sur and can confirm that the g++11 link is still located in /usr/local/bin/. Of course, the other dependencies may be in a different place.
I am not an expert on Python (this video is about installing GCC for C and C++ work). However, you should be able to look at the error input and find out specifically why the gcc compiler failed. Scroll up the output until you see the first error output. Maybe other viewers will have additional Python help.
Hi Dr. Hayes I installed until the step cd/usr/local/bin/ after that I can't go to the bin directory why? can you please help me ...if I type cd/usr/local/bin/ then it doesn't go there..please help me
@@ProgrammingwithDrHayes i tried with all options ..kept spaces ...avoided spaces but didn't work. Can i be sure that every body would have the same path that you type i.e cd/usr/local/bin/ or that will be different for everyone? Thanks alot
@@afridinaseer The path to GCC should be the same for all macOS users that install it using Homebrew. Regardless, that path should exist on your macOS system.
@@ProgrammingwithDrHayes thanks sir yes it worked now. sir now i working and using sleep, clrscr(), system("pause") in eclipse using my macbook pro but these functions are not bering supported ...which i declared the directory for this e.g #include or #include then i am also getting directory delaration errow. how to fix these errors. should i do something in eclipse setter so that it should accept the directory declartion in the top or how to fix these errors so that my eclipse allow me to use the clear scree fun, also sleep funtion and as well as system pause fucn.... thanks naseer
@@afridinaseer The code you are describing is Microsoft Windows specific. I recommend avoiding platform specific code. If you would like to pause execution until the user hits enter, try something like this: std::cout
it doest work for me after i type install gcc i get the following: nstall [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode] [-o owner] file1 file2 install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode] [-o owner] file1 ... fileN directory
Did you Sign Out of your account and sign back it (or restart you machine)? If that did not work, go back to /user/local/bin/ and confirm that the link you made is pointing to g++-8 by typing ls -l