I don’t know much about MinGW, but it uses GCC, right?
If so, this may be relevant:
So the simple solution is to just include these extra include paths on the compiler command-line with -I<path> options.
There’s also finding libraries in search paths and adding those to the link command-lines as well (e.g. -L<path>, -l<library>, etc.)
For starters, you can do this yourself so you know how it works. Then an easy next-step is to encode these commands you’re running into a Makefile so that you can build everything just by typing “make” in your source directory.
An even higher level than that is to use something like CMake to automate searching for headers and libraries on your system and building a custom Makefile (and/or MSVS solution/project files) which will build your application.
Here’s a short Makefile tutorial to get you started: Makefiles: A Tutorial by Example. The syntax is simple. You’ll have this mastered in minutes. I’d recommend doing this first.
Later once you want to automate finding includes and libraries on your system (and/or supporting multiple PCs and platforms), here’s a simple “CMakeLists.txt” input file for CMake that automates the generation of both: 1) MSVS solution/project files on Windows, and 2) Makefile generation on Linux for some GLUT+GLEW example programs. The generated build files will build executables for these examples.
cmake_minimum_required( VERSION 2.8 FATAL_ERROR )
# Help Windows find libaries
if ( WIN32 )
# NOTE: You should add these directories to your PATH (for .dlls):
# C:\Tools\glew-2.0.0\bin\Release\Win32
# C:\Tools\freeglut-3.0.0\bin
set(CMAKE_PREFIX_PATH "C:/Tools/glew-2.0.0;C:/Tools/freeglut-3.0.0")
set(CMAKE_LIBRARY_PATH "C:/Tools/glew-2.0.0/lib/Release/Win32;C:/Tools/freeglut-3.0.0/lib")
endif()
# Find packages of additional libraries
# - GLEW
find_package( GLEW REQUIRED )
if ( GLEW_FOUND )
include_directories( ${GLEW_INCLUDE_DIRS} )
link_libraries ( ${GLEW_LIBRARIES} )
endif()
# - GLUT
find_package( GLUT REQUIRED )
if ( GLUT_FOUND )
include_directories( ${GLUT_INCLUDE_DIR} )
link_libraries ( ${GLUT_LIBRARIES} )
endif()
# - OpenGL
find_package( OpenGL REQUIRED )
if ( OPENGL_FOUND )
include_directories( ${OPENGL_INCLUDE_DIRS} )
link_libraries ( ${OPENGL_LIBRARIES} )
endif()
# C++11
macro(use_cxx11)
if (CMAKE_VERSION VERSION_LESS "3.1")
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set (CMAKE_CXX_FLAGS "--std=c++11 ${CMAKE_CXX_FLAGS}")
endif ()
else ()
set (CMAKE_CXX_STANDARD 11)
endif ()
endmacro(use_cxx11)
use_cxx11()
# Specify exec_name followed by source and header files
add_executable ( tst tst.cpp )
add_executable ( probe_gl probe_gl.cpp )
To use cmake to build, you just do something like this:
# One-time setup
mkdir build
cd build
cmake ..
# To build your code, use one of the following two commands.
#
make
OR
cmake --build .