How do I compile a c++ file on mac? [closed] - c++

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
The code I have tried porting from windows to compile c++ on a mac does not work.
g++ -W -Wall -pedantic filename.cpp

Try using the following:
g++ -o filename filename.cpp

You could also use XCode.
But ofc, not all the cpp files from Windows could be directly ported on mac: it depends on their content.
You should consider also something like this:
http://mac.sillydog.org/dev/visual_studio.php
Best

Related

The term 'g++' is not recognized as the name of a cmdlet, function, script file, or operable program [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
Could you guys tell me why a simple c++ file can't work and gives me errors in the terminal.Is it a simple error? Thank you.The photo is on the link:
You are invoking g++ in Windows. You must guarantee that this compiler and the relevant development tools are installed and configured correctly first.
These are the prerequisites before you start to use them:
https://code.visualstudio.com/docs/cpp/config-mingw#_prerequisites
You can refer to:
Instructions on the MSYS2 website to install Mingw-w64.
VSCode tutorial Using GCC with MinGW, this is quite clear, for example prerequisites point 4 tells you how to add the path to your Mingw-w64 bin folder to the Windows PATH environment variable carefully.

Which compiler options to use with gfortran? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I am using Fortran 90 with the gfortran compiler. It's my first experience with a compiled language. Why not just use all of the compiler options when compiling? Would it slow down running the executable? Which compiler options do you recommend? Also, how does gfortran compare to other compilers for Fortran 90? What is important to know about it?
For developing and debugging: -Og -g -Wall -pedantic -fcheck=all
For maximum performance once you have a functioning program, benchmark and test, but as a starting point look in the manual what -O2, -O3, -Ofast, -ffast-math, -funroll-loops, -march=native do. Be particularly careful wrt -Ofast and -ffast-math.

cant run any c/c++ program [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
Anytime I try to run a simple C or C++ program in CLion or emacs, no output shows up.
EDIT: Using virtual environment, C was not installed properly.
CLion doesn't ship with a C/C++ compiler. You need to install your own compiler, and then set it up with CLion.
For windows, you can install:
MinGW
Cygwin (make sure you select gcc-core and g++ during setup)
CLion will detect these environments automatically during installation if you set them up in their default locations.

How to get compiler warnings JUCE - Ubuntu [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I was recently dealing with an error that should have easily been realized with a simple compiler warning.
Does anyone know how to get compiler warnings to show up when compiling JUCE projects with make on Ubuntu?
I attempted:
make -Wall from the gcc/gnu Warning Options docs -> no change
make V=1 as commented in the makefile -> it was verbose, but didn't show the warnings
Editing the live build settings in the Projucer -> live build doesn't work on Ubuntu
Edit: Answered by OMGtechy
To add compiler warnings to the build: edit the Linux Makefile settings in the Exporter tab of the Projucer File Manager (See the picture in his answer). However, I didn't see any "uninitialized variable" warnings until I also ran with the optimization flag -O2. Apparently gcc is bad with that warning.
You want to add -Wallto your exporter compiler flags, possibly with -Werror too. Just adding them to the live build flags will only affect the Projucer's live build feature.

Minimal compile environment on Windows 8.1 [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Trying to compile this WinURL tool from source on Win 8.1:
http://www.chiark.greenend.org.uk/~sgtatham/winurl/
(src zip on that page if you want to take a look)
The reason is that I want to change the keybinding from Win+W to something else as Win 8.1 takes over Win+W for search and the tool no longer works on Win 8.1
What are my choices for a minimal dev env on Win 8.1? I'm not interested in installing GBs of tools if I can get away with something very simple that just lets me compile the above. Would something like Cygwin gcc or MinGW work or do I need some sort of Visual Studio and if so is there a simple free edition I can use?
If you're looking for a lightweight compiler-only solution, don't look beyond MinGW. You can install it and add its bin folder to the Environment PATH variable.
If you want an IDE too, I would recommend CodeBlocks, or DevC++.
I would recommend CodeBlocks over DevC++ as people report to DevC++ being slow, and also its development cycle is very slow.
These are all free and open source solutions. And lightweight.
I got it to compile just fine with MinGW using the following script:
del *.o winurl.exe
windres winurl.rc winurlres.o
gcc -c winurl.c
gcc -o winurl.exe winurl.o winurlres.o C:\MinGW\lib\libgdi32.a -mwindows
strip winurl.exe
del *.o