pBook‎ > ‎

c++ command line compile Widnows g++ cl

posted Nov 27, 2014, 8:18 PM by Javad Taghia   [ updated Nov 28, 2014, 4:55 AM ]

YouTube Video

To specify a directory to search, you just use -L:


To specify the actual library name, you use -l:

-lfoo  # (links libfoo.a or libfoo.so)

To specify a directory to search for include files (different from libraries!) you use -I:


So I think what you want is something like

g++ -g -Wall -I/data[...]/lib testing.cpp fileparameters.cpp main.cpp -o test

GCC provides experimental support for the 2011 ISO C++ standard. This support can be enabled with the -std=c++11 or -std=gnu++11 compiler options; the former disables GNU extensions.

Now consider there is a file named xxx.cpp and needs libs in lib folder and include folder that is one level up. The equivalent of g++ and microsoft compiler cl are as below: libfftw3.a and libfftw3-3.lib are in lib folder

cl xxx.cpp /I ..\include ..\lib\libfftw3-3.lib ..\lib\libfftw3f-3.lib ..\lib\libfftw3l-3.lib

g++ xxx.cpp -I ../include -L ../lib -lfftw3 -lfftw3f -lfftw3l