codelite GCC switch and linker setup - gcc

I'm trying to setup codelite using the GCC compiler. I'm trying to add the switches:
-fno-pie -no-pie
This works when using gcc in the terminal.
Below is where I have placed the switches.I have done this for the cross GCC (i686) aswell.
This doesn't seem to be working though. My disassembly doesn't seem to be the same as when I use gcc in my terminal to compile with the -fno-pie and -no-pie
How do I get this to work?
Thanks for any help.

You have gone from the IDE's top menubar through Settings -> Build Settings -> Compilers -> GCC -> Compiler Options -> New..., and added options
-fno-pie and -no-pie
What you have done is edited the global compiler options for GCC that CodeLite will make available to be enabled or disabled
in the Compiler options dialog of any project that uses the GCC compiler. You have not actually enabled either of those
options for any particular project that uses GCC.
The globally configured compiler options for GCC (or other compiler) are by default the
most commonly wanted ones. There is no need to edit this configuration to use any
other compiler options in a project. If you do edit the configuration to make them
available, then you also need to enable them in the project Settings of GCC projects
in which you want them enabled.
-fpie|-fno-pie are compilation options. -pie|-no-pie are not compilation options: they are
linkage options. If you wanted to make these linkage options available in all GCC projects
then you would proceed through Settings -> Build Settings -> Compilers -> GCC -> Linker Options -> New...
To add -fno-pie to the compiler settings of a GCC project MyProj, from the workspace
tree-view, navigate MyProj -> Settings -> {Debug|Release} -> Compiler -> {C++|C} Compiler Options.
Then, if you have not bothered to edit the GCC compiler options configuration, just
edit the edit-field on the right - probably already containing default compiler options such
as -g;-O0;-Wall - and append ;-fno-pie to whatever is there. If you have bothered
to add -fno-pie to the configured compiler options, then click on the '...' button
at the right of the edit-field, and select -fno-pie from the Compiler Options.
To add -no-pie to the linker settings of a GCC project MyProj, from the workspace
tree-view, navigate MyProj -> Settings -> {Debug|Release} -> Linker -> Linker Options
and apply -no-pie in the same way as you applied -fno-pie for the compiler options.

Related

using stoi problems(c++11) [duplicate]

I'm writing some code that requires to have C++11 support for my Code::Blocks 12.11. I am using default GNU GCC Compiler came with MingW. Is there any way I can do this?
Go to Toolbar -> Settings -> Compiler
In the Selected compiler drop-down menu, make sure GNU GCC Compiler is selected
Below that, select the compiler settings tab and then the compiler flags tab underneath
In the list below, make sure the box for "Have g++ follow the C++11 ISO C++ language standard [-std=c++11]" is checked
Click OK to save
The answer with screenshots (put the checkbox as in the second pic, then press OK):
A simple way is to write:
-std=c++11
in the Other Options section of the compiler flags. You could do this on a per-project basis (Project -> Build Options), and/or set it as a default option in the Settings -> Compilers part.
Some projects may require -std=gnu++11 which is like C++11 but has some GNU extensions enabled.
If using g++ 4.9, you can use -std=c++14 or -std=gnu++14.
Use g++ -std=c++11 -o <output_file_name> <file_to_be_compiled>

Build issue using code::blocks, intel c++compler

I am getting the following warning when I use Code::Block / Intel C++ Compiler:
"myLib.a is an archive, but has no symbols (this can happen if ar is used where xiar is needed)"
This is followed by Linker errors for missing symbols.
The project builds fine in gcc compiler.
How do I have code blocks run xiar instead of ar ?
How do I have code blocks run xiar instead of ar?
In the Code::Blocks IDE navigate Settings -> Compiler
Set Selected Compiler = Intel C++ (whatever you have called it)
Tab to Toolchain executables -> Program files
In the edit box Linker for static libs change ar to xiar (or
possibly path/to/xiar, if the Intel tools aren't in your PATH)

How can I add C++11 support to Code::Blocks compiler?

I'm writing some code that requires to have C++11 support for my Code::Blocks 12.11. I am using default GNU GCC Compiler came with MingW. Is there any way I can do this?
Go to Toolbar -> Settings -> Compiler
In the Selected compiler drop-down menu, make sure GNU GCC Compiler is selected
Below that, select the compiler settings tab and then the compiler flags tab underneath
In the list below, make sure the box for "Have g++ follow the C++11 ISO C++ language standard [-std=c++11]" is checked
Click OK to save
The answer with screenshots (put the checkbox as in the second pic, then press OK):
A simple way is to write:
-std=c++11
in the Other Options section of the compiler flags. You could do this on a per-project basis (Project -> Build Options), and/or set it as a default option in the Settings -> Compilers part.
Some projects may require -std=gnu++11 which is like C++11 but has some GNU extensions enabled.
If using g++ 4.9, you can use -std=c++14 or -std=gnu++14.
Use g++ -std=c++11 -o <output_file_name> <file_to_be_compiled>

Enable compiler warnings in Kdevelop

I'm using Kdevelop for a simple C++ project. I know that Kdevelop uses CMake to build the project, but the only thing that I known about CMake is that if I add a new .cpp source file in my project, I have to add it also in CMakeLists.txt.
Now I'm trying to enable tha gcc compiler warnings (i.e. compiling with g++ -Wall ...).
Does Kdevelop have a compiler settings section, or I have to edit directly the Makefile or another CMake settings file?
You can add compiler flags in CMake by adding the following command to your CMakeLists.txt:
list( APPEND CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")

Where to put makefile flags in a Xcode project?

In the makefile:
CUSTOM_CFLAGS=-Wall -ggdb3 -O3 -std=gnu99 -frename-registers -pthread -Wsign-compare -D_GNU_SOURCE
SYS_CFLAGS=-DNO_THREAD_LOCAL
LDFLAGS=-pthread -rdynamic
LIBS=-lm -ldl
Where should I put the above in Xcode project?
When building a Makefile-based project with Xcode using the "External Build System" template
…you can add any necessary environment variables such as CFLAGS or LDFLAGS to the build settings for the project, as shown below:
These values are then exported as environment variables during the build process, which make and the Makefile will pick up on, assuming your Makefile has, for example, something like this inside it:
CXXFLAGS=$(CFLAGS) $(LDFLAGS) -std=c++11
g++ $(CXXFLAGS) main.cpp
This is what I needed to do to build a Makefile-based project that depended on the GNU Scientific Library, using the gsl package from Macports, which puts everything in /opt/local instead of the "standard" places where Xcode looks for shared libraries and headers.
Maybe this can help somebody else in this situation.
Makefile flags correspond to Xcode build settings. Look into the following build settings:
Optimization Level for the -O3 flag.
C Language Dialect for the -std=gnu99 flag.
Other C Flags for the other flags in the CUSTOM_CFLAGS and SYS_CFLAGS flags.
Other Linker Flags for the LDFLAGS and LIBS flags.
Xcode may have build settings for some of the flags in the makefile's CUSTOM_CFLAGS flag list and the linker flags. I haven't memorized the build settings list. If you open the Quick Help inspector, you can read a description of each build setting by selecting the build setting from the build settings list. Choose View > Utilities > Show Quick Help Inspector to show the Quick Help inspector.
If you don't know where to find Xcode's build settings, read the following article:
Xcode 4: Accessing Build Settings

Resources