- One should be very careful to use the right form of a package for GCC, VC++, or other compilers. For example a precompiled static library with extension .lib is for VC++ and with extension .a for gcc. So make sure you are using the right option of a package to install/download based on the compiler.
- Making executables with gcc requires a makefile. IDEs such as Eclipse can generate the makefile but in general the user should write the makefile or use other options (e.g. cmake). This document: https://www3.ntu.edu.sg/home/ehchua/programming/cpp/gcc_make.html has very concise and useful description of gcc and makefile syntax.
Once a packages is installed (either a) downloaded precompiled; b) configures and made by gcc after downloading source and header files; or c) or installed by an installer (yip, macport, etc.)) if include and library paths are not already added to default gcc locations they should be specified for the use in other projects.
Include and library paths:
Again similar to VC++ there are three ways to include/link an external package to a gcc project:
- Adding include, lib, (and bin, man, share, etc.) content of the package to corresponding default gcc folders:
- MinGW default folders and an example of added package GSL (http://www.gnu.org/software/gsl/) is shown below:
- Linux type system default directories are discussed in https://www3.ntu.edu.sg/home/ehchua/programming/cpp/gcc_make.html.
- IDE global include, library, etc. directories (similar to VC++). Based on this post this option is not possible for Eclipse.
- Specification of include, library, etc. folders for one project:
- Adding include, and lib folders to makefile is explained in Linux type system default directories are discussed in https://www3.ntu.edu.sg/home/ehchua/programming/cpp/gcc_make.html.
- Eclipse IDE: in eclipse all the commonly set directories and parameters are very nicely set in one place. Just right-click on a project and navigate to the page shown below from the properties.
Library file names
Once the path of libraries are determined by any of the means above, one should specify which library names are used for a project. Below shows a sample inclusion of library names. The list is separated by space.
Library file names
Library names are either specified in the makefile with option -l as discussed in https://www3.ntu.edu.sg/home/ehchua/programming/cpp/gcc_make.html or in Eclipse they are entered along with library paths and include directories as shown above.