I have just installed codeblock and seems my all breakpoints are ignored. I have checked that I have unchecked "strip" and after I see the full compile command I find there is no flag as -s, but still.
This is the first time that I use ubuntu and codeblock and maybe I have overlooked something obvious. Thanks for any help.
-------------- Build: Debug in matrix ---------------
g++ -Wall -g -Wall -g -fexceptions -c /home/ubuntu/Documents/C++/matrix/main.cpp -o obj/Debug/main.o
g++ -o bin/Debug/matrix obj/Debug/main.o
Output size is 160.36 KB
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 0 warnings
Have you actually set-up a debugger, which you can see in the Active debuggers menu? (see screenshot)
If you actually have a debugger, you can start a debugging session from the debug menu. (or use F8 if you have the same shortcuts)
Screenshot link: Debug Menu
Can't post image directly here, since my rep is to low.
Related
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:
Can someone share their compiler settings .. CLANG...toolchain from CodeBlocks ?
Solution
Edit in retrospect
... Can I change the execute mode (chmod) on a particular hard drive partition?
Short term solution ... execute from the home directory
Since I only have comments below I am not sure I can mark an answer.
I will leave my misunderstanding below.
I am on Linux Mint
Partial Success .... Clang does appear to examine and compile code.
Cleaned "test200 - Debug"
-------------- Build: Debug in test200 (compiler: Clang Hand Labor)---------------
clang++ -Wall -fexceptions -g -c "/media/transcend/Seagate Replica/cpp2011/test200/test200/main.cpp" -o obj/Debug/main.o
clang++ -o bin/Debug/test200 obj/Debug/main.o
Output size is 27.32 KB
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 0 warnings (0 minutes, 0 seconds)
Console Output (typed by Hand .... I cannot copy from tiny console of CodeBlocks)
This is the !!!Error!! ... Just cout << "Hello"
elided
sh: 1: /path/st200 permission denied
returned 126
Compiler Settings in CodeBlocks IDE
C..clang
C++ clang++
Linker clang++
Linker for static ... ar
Resource Compiler ... nothing
make program ...........make
I used Software Manager of Linux for CodeBlocks IDE
There was no CLANG options present ... this fact makes me think I have something old
I copied the GCC Settings and typed clang and clang++
Thanks
Build Log Elided
clang++ -Wall -fexceptions -g -I/usr/lib/llvm-3.2/include elided -Wcast-qual -c "/media/transcend2020/Seagate Replica/cpp2011/test200/test200/main.cpp" -o obj/Debug/main.o
clang++ -o bin/Debug/test200 obj/Debug/main.o -lLLVMAsmParser elided -L/usr/lib/llvm-3.2/lib -lpthread -lffi -ldl -lm
Output size is 51.20 KB
Whenever I try to compile a c++ code with g++ on terminal, I can't seem to get g++ to output any error messages even though I am certain that there are errors that should be caught during compile time (such as syntax, reference types...).
I tried several ways such as this make file:
all:
g++ -W -Wall -Werror main.cpp
All it does is output:
make: *** [all] Error 1
which isn't that useful, obviously...
Typing things like this:
g++ -W -Wall -Werror main.cpp
directly to terminal (without the make file) doesn't output any messages at all.
However this successfully outputs all of the errors while compiling:
cc main.cpp
My question is: how do I make g++ to output error messages so I can know where to correct my code?
Just guessing - is it possible your terminal doesn't print stderr? Say, for example, it moves it to a log file or something?
Try running
g++ [whatever your arguments are] |& cat
(this is if you use tcsh)
or
g++ [whatever] 2>&1 | cat
if you use bash.
Try something simple like this:
g++ -c main.cpp
Make reports an error when one of it's tasks returns non-0 status. If g++ silently returns non-0 - well, i suppose it's broken somehow. Check $? after you've run g++. Also, try g++ --version - will it report anything at all? Also you could run it under debugger, just to be sure.
Try adding a line like
#warning hello from here
(or perhaps #error instead of #warning) into main.cc near the beginning (perhaps as the first line).
If
gcc -Wall -v main.cc
don't give any output (notably no warnings or errors) that means that your gcc is broken. Perhaps type /usr/bin/gcc instead of just gcc
BTW, Apple don't like GCC (because they dont like its GPLv3+ license). Maybe it is worth your time to build [using e.g. ..../configure --program-suffix=-local] and install a newer GCC (perhaps from the released source tar ball of the compiler). Current version is 4.8.1!
I've got some server in c++ (commands acquired from build-system):
g++ -o obj/server.o -c -m64 -isystem/opt/boost/include -Wall -Werror -march=core2 -ftest-coverage -fprofile-arcs -DGCOV_ENABLED= -Iinclude -I/opt/hydraOST/lzopro/include -I/usr/include/libxml2 -Idaemon/include src/server.cpp
g++ -o bin/server.exe -rdynamic -ftest-coverage -fprofile-arcs -m64 -Wl,-rpath=\$ORIGIN -Wl,-rpath=/opt/hydraOST/lzopro/lib obj/server.o (+ other libs)
As it's daemon and I'm stopping it with signal but to enforce dumping gcov data before kill $PID I'm using gdb:
gdb -p $PID -batch -x gcov/dumpGcovData
where contents of gcov/dumpGcovData:
call __gcov_flush()
thread apply all call __gcov_flush()
I know that linking should be with -lgcov but as it was working in that way so I didn't change it in build system. The problem occured just after added -rdynamic flag (without that flag it worked properly).
I know that linking should be with -lgcov
That is incorrect: gcc will add -lgcov automatically given your flags; no explicit -lgcov needed.
The problem occured just after added -rdynamic flag (without that flag it worked properly).
I can't imagine what -rdynamic may have to do with the problem. A trivial test case shows that it works either way, so either your claim of "it stopped working with addition of -rdynamic" is wrong, or there is some more complicated interaction going on (which I am not reproducing in my trivial test).
You may want to begin by
Verifying that in fact re-linking server.exe without -rdynamic as the only change makes it work again.
Showing the output from g++ -o bin/server.exe ... -Wl,-y,__gcov_flush and readelf -s bin/server.exe | grep __gcov_flush. Here is what it should look like:
g++ -ftest-coverage -fprofile-arcs cov.c -g -rdynamic -Wl,-y,__gcov_flush
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/libgcov.a(_gcov.o): definition of __gcov_flush
readelf -s a.out | grep gcov_fl
66: 00000000004023c0 131 FUNC LOCAL HIDDEN 14 __gcov_flush
After added -Wl,-y,__gcov_flush it printed out line (and flag -rdynamic does not matter):
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/libgcov.a(_gcov.o): definition of __gcov_flush
Unfortunately, looks like -rdynamic flag does not afftect the output:
with -rdynamic:
readelf -s server.exe | grep gcov_flush
1203: 0000000000808370 107 FUNC LOCAL HIDDEN 12 __gcov_flush
and without -rdynamic:
readelf -s server.exe | grep gcov_flush
1203: 0000000000808380 107 FUNC LOCAL HIDDEN 12 __gcov_flush
Anyway, I've got very simple solution (or rather workaround): add -rdynamic ONLY if its build not for gcov:
if CONFIG == gcov:
addFlags(["-ftest-coverage", "-fprofile-arcs"])
else:
addFlags(["-rdynamic"])
So, main problem seems to be not solved, anyway got some workaround (works for me, because I rather don't use gcov config for debugging - just for generating coverage report). Anyway, thanks for help!
I have a simple ./compile.make script that produces a bunch of object .o files. The contents are like this (first 5 lines printed):
compile.make:
gfortran -c -O3 active.f
gfortran -c -O3 alchemy.f
gfortran -c -O3 analysis.f
I run the script by doing ./compile.make. I'd like to compile everything with the -g flag so I can debug using (gdb) but I was wondering if there is a better way to add the "-g" flag without having to manually edit every line of my compile.make file.
*EDIT: I know that find/replace option is available and not much of a hassle at all. I was just curious as to whether the flags can be added upon execution of the script.
http://www.brunolinux.com/02-The_Terminal/Find_and%20Replace_with_Sed.html