Showing posts with label GCC. Show all posts
Showing posts with label GCC. Show all posts

2020-10-25

2020-10-25 Sunday - GNU Compiler Collection (GCC) 10.2


 

For one who seeks to be a master of their craft - you must continually attend to sharpening the saw.

Today: A deep dive back into C++ POSIX threaded programming, using the G++ compiler, available with the GNU Compiler Collection (GCC 10.2) - and exploring the differences in C++17, and the experimental implementation of some C++20 features.

GCC References

Eclipse: C/C++ Development Toolkit (CDT) Resources

Although I usually rely on Microsoft Visual Studio (or Visual Studio Code) as my primary IDEs - I'm forcing myself to use Eclipse ("2020-09" CDT release) - so that I maintain familiarity & proficiency:

  • https://www.eclipse.org/cdt/
    • https://www.eclipse.org/cdt/documentation.php  
      • "The C/C++ Development Toolkit (CDT) is a collection of Eclipse-based features that provides the capability to create, edit, navigate, build, and debug projects that use C and/or C++ as a programming language."
      • "The CDT does not include the necessary compilers and debuggers to convert C/C++ code into executable programs and to debug those programs, but it does provide the frameworks that allow such tools to be integrated in a consistent fashion. This allows you to mix and match such tools depending on your project requirements."
  •  ...which leads to suggesting:

Cygwin

  • https://cygwin.com/
  • Once you have the GCC G++ elements installed, run "g++ -v" at the command line, and you should get something like this:

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-cygwin/10/lto-wrapper.exe
Target: x86_64-pc-cygwin
Configured with: /mnt/share/cygpkgs/gcc/gcc.x86_64/src/gcc-10.2.0/configure --srcdir=/mnt/share/cygpkgs/gcc/gcc.x86_64/src/gcc-10.2.0 --prefix=/usr --exec-prefix=/usr --localstatedir=/var --sysconfdir=/etc --docdir=/usr/share/doc/gcc --htmldir=/usr/share/doc/gcc/html -C --build=x86_64-pc-cygwin --host=x86_64-pc-cygwin --target=x86_64-pc-cygwin --without-libiconv-prefix --without-libintl-prefix --libexecdir=/usr/lib --with-gcc-major-version-only --enable-shared --enable-shared-libgcc --enable-static --enable-version-specific-runtime-libs --enable-bootstrap --enable-__cxa_atexit --with-dwarf2 --with-tune=generic --enable-languages=c,c++,fortran,lto,objc,obj-c++ --enable-graphite --enable-threads=posix --enable-libatomic --enable-libgomp --enable-libquadmath --enable-libquadmath-support --disable-libssp --enable-libada --disable-symvers --with-gnu-ld --with-gnu-as --with-cloog-include=/usr/include/cloog-isl --without-libiconv-prefix --without-libintl-prefix --with-system-zlib --enable-linker-build-id --with-default-libstdcxx-abi=gcc4-compatible --enable-libstdcxx-filesystem-ts
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.0 (GCC)

Or, alternatively, you may wish to try LLVM

LLVM & Clang

"The LLVM Project is a collection of modular and reusable compiler and toolchain technologies. Despite its name, LLVM has little to do with traditional virtual machines. The name "LLVM" itself is not an acronym; it is the full name of the project."

"LLVM began as a research project at the University of Illinois, with the goal of providing a modern, SSA-based compilation strategy capable of supporting both static and dynamic compilation of arbitrary programming languages. Since then, LLVM has grown to be an umbrella project consisting of a number of subprojects, many of which are being used in production by a wide variety of commercial and open source projects as well as being widely used in academic research. Code in the LLVM project is licensed under the "Apache 2.0 License with LLVM exceptions" "

  • "clang fully implements all of standard C++98 except for exported templates (which were removed in C++11), all of standard C++11, C++14, and C++17, and most of C++20."

Suggested Books:


  • "Coverage begins with the basics, then ranges widely through more advanced topics, including many that are new in C++17, such as move semantics, uniform initialization, lambda expressions, improved containers, random numbers, and concurrency. The tour even covers some extensions being made for C++20, such as concepts and modules, and ends with a discussion of the design and evolution of C++."
Some older books, that may also be of interest as background reading:

Useful Tutorials - General C++

Useful Tutorials - POSIX Threads

References

2016-03-04

2016-03-04 Friday - GCC, The GNU Compiler Collection

Today I've spent time setting-up my Windows 10 development environment to be able to work with GCC, the GNU Compiler Collection - and integrating that into my Eclipse IDE.

1.0 Cygwin Setup

At the time of this writing Cygwin 2.4 was the latest available

The Cygwin documentation may be of help, if you are not familiar with it

See: Using GCC with Cygwin
There are a number of packages that you'll want to select for installation - that are not auto-selected in the default (Base package) Cygwin installation configuration:

  • Here are some additional packages that I either selected to be installed for my setup - or were added as dependencies of packages I selected...
    • Admin
      • libattr1
    • Archive
      • bzip2
      • libarchive13
      • libbz2_1
      • xz
    • Base
      • (take the defaults)
    • Database
      • libdb5.3
      • libmysqlclient18
      • libsqlite3_0
    • Devel
      • autoconf2.5
      • binutils
      • bison
      • byacc
      • cccc
      • clang
      • clang-analyzer
      • clisp
      • cmake
      • cmake-doc
      • cppunit
      • cygwin-devel
      • dmalloc
      • flex
      • gcc-core
      • gcc-g++
      • gcc-objc
      • gcc-objc++
      • gdb
      • libargp
      • libcloog-isl4
      • libtdll7
      • make
      • mcpp
      • patch
      • patchutils
      • w32api-headers
      • w32api-runtime
      • windows-default-manifest
    • Doc
      • clang-doc
      • cygwin-doc 
    • Interpreters
      • clisp
      • gawk
      • libguile17 
      • m4
      • perl
      • perl_autorebase
      • pre_base
      • python
    • lib
      • libargp
      • libatomic1
      • libattr1
      • libblkid1
      • libclang3.7
      • libclog-isl4
      • libcrypt0
      • libcurl4
      • libedit0
      • libexpat1
      • libffi6
      • libgcc1
      • libgdbm4
      • libgmp10
      • libgomp1
      • libssapi_krb5_2
      • libiconv
      • libiconv2
      • libidn11
      • libintl8
      • libisl10
      • libisl13
      • lib5crypto3
      • libkrb5_3
      • libkrb5support0
      • libllvm3.7
      • liblzma5
      • liblzo2_2
      • libmcpp0
      • libmpc3
      • libmpfr4
      • libncursesw10
      • libnettle4
      • libnghttp2_14
      • libobjc4
      • libopenldap_2_4_2
      • libopenssl100
      • libp11-kit0
      • libpcre1
      • libpipeline1
      • libpsl5
      • libquadmath1
      • libreadline7
      • libsigsegv2
      • libsmartcols1
      • libsqlte3_0
      • libssp0
      • libstdc++6
      • libtasn1_6
      • libunistring2
      • libuuid-devel
      • libuuid1
      • libvtv0
      •  libxml2
      • p11-kit
      • p11-kit-trust
      • popt
      • zlib0
    • Math
      • clisp
      • libgmp10
      •  libmpc3
      • libmpfr4
    • Net
      • ca-certificates
      • curl 
      • libopenldap2_4_2
      • libssh2_1
      • libtasn1_6
      • openssl
    • Perl
      • perl
      • perl_autorebase
      • perl_base 
    • Python
      • python
    • Shells
      • bash
      • clisp
      • dash
      • mintty
    • System
      • libattr1
      • libcom_err2
      • rebase
    • Text
      • groff
      • less
      • patchutils
    • Utils
      • diffutils
      • libssal2_3
      • patchutils
      • rebase


2.0 Eclipse CDT

At the time of this writing, CDT 8.8.1 was the latest available.

You can install the CDT version of Eclipse by downloading from here:
 
If you have an existing Eclipse environment already setup, and you just want to add the CDT plugins - you can add this p2 software repository link via the Help > Install New Software menu option

If you will be using Cygwin GCC compilers, then you'll probably want to make it your default:




You'll eventually need to debug something, so check to see that you have the correct debugger installed and configured properly for CDT:


Doug Schaefer is co-head of the Ecllipse CDT project - and has a few blog posts that may be of interests to CDT users


3.0 GCC, The GNU Compiler Collection References

4.0 Success! Code Compiled (...and ran)


5.0 Debugging

You'll need to setup a Debug profile for your program, and specify the executable - and source file





 Set your breakpoints, and begin a debugging session...



6.0 Additional References

If you run into an issue such as "Symbol 'cout' could not be resolved", or "Symbol 'std' could not be resolved" - you may need to manually add the appropriate Cygwin include directories, select the correct toolchain entry, and try closing and opening the project. These links were helpful to me in resolving this issue:




Copyright

© 2001-2025 International Technology Ventures, Inc., All Rights Reserved.