We are using the -Werror -Wextra -Wall -pedantic compiler flags, and C++11 diaelect. We want to use these for all of our projects. Currently we are setting these to each project by Project properties -> C/C++ Build -> Settings -> Tool Settings -> GCC C++ Compiler.
But this is a project-level setting.
I read lots of questions, i tried lots of things, but i did not found a working solution for setting the flags globally. Is there a way to do this? I am using the latest Eclipse (4.4 Luna), and the latest CDT (8.4).
I am also using eclipse luna.
In top menu : Window -> Preferences -> C/C++ -> Build -> Settings
Select Discovery tab, and change the CDT GCC Built-in settings (if you use gcc).
Default is like :
${COMMAND} -E -P -v -dD "${INPUTS}"
change to
${COMMAND} -E -P -v -dD "${INPUTS}" -Werror -Wextra -Wall -pedantic
Related
I'd like to ensure that a large set projects are build with the -fno-omit-frame-pointer flag for easier debugging with tools like ebpf.
One way of course would be to modify the build scripts of each of these projects, but that is a lot of work.
I've come across the possibility to configure gcc with --enable-frame-pointer which restores the old default from the early gcc4.x days of using -fno-omit-frame-pointer.
I've built gcc from source like that and confirmed:
❯ ./bin/gcc -m32 -O3 -Q --help=optimizers | grep omit
-fomit-frame-pointer [disabled]
❯ ./bin/gcc -m64 -O3 -Q --help=optimizers | grep omit
-fomit-frame-pointer [enabled]
Is anyone aware of a possibility to extend the effect of --enable-frame-pointer to the 64bit targets?
I believe you are using an older version of GCC because support of this flag on x64 has been enabled some time ago (see e.g. this commit).
I have Eclipse CDT Oxygen on Ubuntu 16.04, with the LLVM support installed. LLVM 5.0.0 is installed, and I want to experiment with libc++. The problem is building a project with libc++, but without libstdc++.
The first step is building a simple "Hello World" executable using c++ and libc++. For the project properties -> C/C++ Build -> Settings I have the following:
LLVM Clang (all options): -O0 -emit-llvm -g3 -Wall -c -fmessage-length=0 -std=c11
LLVM Clang++ (all options): -O0 -emit-llvm -g3 -Wall -c -fmessage-length=0 -stdlib=libc++ -std=c++17
LLVM Clang linker (all options): -v -L/usr/local/lib -L/usr/lib -L/usr/lib/gcc/x86_64-linux-gnu/5/ -nodefaultlibs
Note that "-L/usr/lib/gcc/x86_64-linux-gnu/5/" is added automatically and I cannot get rid of it.
The linked libraries are (in order): c++, c++abi, m, c, gcc_s, gcc, stdc++
The stdc++ lib is added automatically and seems impossible to strip out. This results in an executable that contains both libc++ and libstdc++ which we don't want. Does anyone know of a way to build a project without libstdc++ but with libc++ ?
So this is a followup question to Visual Studio 2015 Update 1, clang error
The error message I'm getting is
clang.exe : error : cannot specify -o when generating multiple output files
Basically, Hans Passant's workaround of disabling precompiled headers did not work for me. I'm still seeing the error. Anybody have any more ideas to work around this?
My VS-generated command line is: -fpic -std=c++1y -fstack-protector -x c++ "Debug\" -Wall -fno-strict-aliasing -ffunction-sections -I "c:\SDKs\VST3 SDK" -I "c:\SDKs\vstsdk2.4" -I "....\JuceLibraryCode" -I "......\JUCE\modules" -g2 -gdwarf-2 -O0 -x c++-header -D "_CRT_SECURE_NO_WARNINGS" -D "WIN32" -D "_WINDOWS" -D "DEBUG" -D "_DEBUG" -D "JUCER_VS2010_78A501D=1" -D "JUCE_APP_VERSION=1.0.0" -D "JUCE_APP_VERSION_HEX=0x10000" -D "_WINDLL" -frtti -fomit-frame-pointer -fdata-sections -fno-ms-compatibility -std=c11 -fexceptions -o "Debug\" -fms-extensions -fno-short-enums
I'm trying to build a C++ JUCE audio plugin in Windows with Clang because I ended up using a good amount of C++14 features when developing it initially on Mac and did not realize that other compilers were a bit more behind in C++ standard support. JUCE applications provide cross platform support by a VS/XCode project file or Makefile generated from the Introjucer/Projucer application. If I set up a new project with the VS2015 Cross-Platform C++ DLL with Clang 3.7 project template, everything compiles fine. But using the JUCE-generated VS project file and then switching the project preferences to use the Clang 3.7 project toolset is where I run into this error.
When I build a Release C++ project in NetBeans, it automatically configures it with the -O2 option.
I don't see anywhere in the compiler options where I can override this value. I know it's set to -O2 because I can see the cmdlines it uses in the Build window: g++ -O2 ...
If I add -O1 into the "Additional Otions" within the compiler settings it doesn't honour it because the cmdline now becomes g++ -O1 -O2 ... and so the -O2 supersedes my own setting.
So, where in the IDE can I set the -O optimization level compile setting?
I am using GNU compile tools on Linux if that makes any difference.
I finally found the solution by exploring a bit more. In the dialog from the OP there is the option, 'Development Mode' which is currently set to 'Release'. There are a number of options under there and each of those correspond to different optimization levels and/or debug output compile flags:
No Flags -c
Debug -c -g
Performance Debug -c -g -O
Test Coverage -g -c
Diagnosable Release -c -g -O2
Release -c -O2
Performance Release -c -O3
Although there doesn't seem to be an option for -O1, that's basically the intended way for you to select different optimization levels in NetBeans.
Please look at the nbproject/Makefile-Release.mk file.
nekto#ubuntu:~/host/ex/dt-netbeans-samples-cpp-Welcome$ grep -r O2 *
nbproject/Makefile-Release.mk: $(COMPILE.cc) -O2 -MMD -MP -MF "$#.d" -o ${OBJECTDIR}/welcome.o welcome.cc
It looks like the -O2 option presence in the Release configuration is the default and unchangeable, however you always can create your own build configuration (and you did as I see).
Each build configuration has its own nbproject/Makefile-<configuration name>.mk file, which contains following lines:
# CC Compiler Flags
CCFLAGS=-O1
CXXFLAGS=-O1
I've created a new configuration, made it active, and set the -O1 option above from the NetBeans properties pop-up window, C++ Compiler -> Additional Options, and my compilation line didn't contain the -O2 option. My Additional Options panel is below:
Is there an option to force the generated makefile read the CXXFLAGS and CFLAGS variables and use them as most of makefiles do?
Eclipse CDT generated makefiles have the following lines included:
-include ../makefile.init
-include ../makefile.defs
You can create the file makefile.defs in which you define CFLAGS or CXXFLAGS and then go to project Properties -> C++ Build Properties -> Settings -> GCC or G++ compiler -> Miscellaneous. Here you can add your $(CFLAGS) or $(CXXFLAGS) option in the Other flags field.
This should add your additional options to the compiler command line.
I solved this problem by not selecting the "Use default build command" radio box in the C/C++ Build Setting.
Specify custom Build command: make -f Makefile. You can add additional compiler options in the $CCFLAGS defined in the targeted Makefile.