Skip to main content

4 posts tagged with "gcc"

View All Tags

· 2 min read
Hreniuc Cristian-Alexandru


# Make sure pip is using python3
pip install conan

# Cmake
sudo apt-get install cmake

# gcc + make
sudo apt-get install build-essential

Install clang for automatic formatting:


# Use this script to install the clang formatter and all its utilities.
# Install Clang(Used for clang-format)
# ============================================================================ #
mkdir -p ~/programs/clang && cd ~/programs/clang &&
clang_version="9.0.0" &&
archive_name="clang+llvm-${clang_version}-x86_64-linux-gnu-ubuntu-18.04" &&
wget${clang_version}/${archive_name}.tar.xz &&
tar xf ${archive_name}.tar.xz &&
rm -Rf ${archive_name}.tar.xz &&
unlink clang_latest # Just in case there was another sym link
ln -sf ${archive_name} clang_latest &&
echo "CLANG_INSTALL_PATH=\"/mnt/programs/clang/clang_latest\"" &&
echo "export PATH=\"\${CLANG_INSTALL_PATH}/bin:\$PATH\"" &&
echo -n "export LD_LIBRARY_PATH=\"\${CLANG_INSTALL_PATH}/lib" &&
echo ":\$LD_LIBRARY_PATH\""
) >> ~/.bashrc
# ============================================================================ #


Use QtCreator.

Activate these plugins:

Go to Help -> About plugins:
- C++
- Check ClangCodeModel
- Check ClangFormat
- Beautifier
- Code Analyzer
- Check ClangTools
- Utilities
- Check Todo

Set these settings:

Go to Tools -> Options:
- Text Editor
- Behavior:
- Tab policy: Spaces Only
- Tab size: 2
- Indend size: 2
- Align continuation lines: With Spaces
- Clean whitespace (upon saving)
- Display:
- Display right margin at column: 80
- Display line numbers
- Display folding markers
- Visualize whitespace
- Highlight search results on the scrollbar
- Highlight current line
- Highlight blocks
- Animate matching parentheses
- Highlight matching parentheses
- Completion:
- Enable Doxygen blocks
- Generate brief description
- Add leading asterisks
- Beautifier
- Enable auto format on file save
- Clang Format
- Use predefined style: `File`
- Debugger
- General:
- Set breakpoints using full absolute path

· One min read
Hreniuc Cristian-Alexandru

We encountered a problem when using the debugger from qtcreater with the gcc 9.1.0. The values of the std::string were not printed, they were marked as : <not accessible>. We found the fix on stackoverflow.

The fix is simple, you need to change the file: /usr/share/qtcreator/debugger/ as shown in the diff:

< (size, alloc, refcount) = d.split("ppp", value.address() + d.ptrSize())
> (size, alloc, refcount) = d.split("ppp", data - 3 * d.ptrSize())
< if size > 1000:
< size = 1000
> d.check(0 <= size and size <= alloc and alloc <= 100*1000*1000)

· 2 min read
Pamparau Sebastian

gcc and g++ are both compiler drivers. First one is used for C applications while the last one for C++. Even so, they both can be used interchangeably (e.g. use gcc for C++ or g++ for C). This is because in the end both will end up using the same tools (at least for .cpp files) for running the desired action, only the default flags used will differ. This can be analysed by appending the flag -v to both drivers, which will make them output the things done in the background.

The table below shows the notable differences.

Driver commandCompiler flagsAssembler flagsLinker flags
gcc main.cpp -o test -v---lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed
g++ main.cpp -o test -v---lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc Also the option -shared-libgcc was automatically given as a gcc option
gcc main.c -o test -vcc1--lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed
g++ main.c -o test -vcc1plus -D_GNU_SOURCE--lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc Also the option -shared-libgcc was automatically given as a gcc option

Basically, g++ is equivalent to gcc -shared-libgcc -lstdc++ -lm and for c files, g++ will also use the compiler cc1plus while gcc will use cc1.

Later edit: If you're interested in the --as-needed flag you can checkout this stackoverflow link