Click here to Skip to main content
15,886,199 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionCreate a Makefile from this mess Pin
pkfox8-Oct-22 2:56
professionalpkfox8-Oct-22 2:56 
AnswerRe: Create a Makefile from this mess Pin
Richard MacCutchan8-Oct-22 5:34
mveRichard MacCutchan8-Oct-22 5:34 
GeneralRe: Create a Makefile from this mess Pin
pkfox8-Oct-22 5:42
professionalpkfox8-Oct-22 5:42 
GeneralRe: Create a Makefile from this mess Pin
Richard MacCutchan8-Oct-22 5:57
mveRichard MacCutchan8-Oct-22 5:57 
GeneralRe: Create a Makefile from this mess Pin
pkfox8-Oct-22 6:17
professionalpkfox8-Oct-22 6:17 
AnswerRe: Create a Makefile from this mess Pin
k505413-Oct-22 5:53
mvek505413-Oct-22 5:53 
GeneralRe: Create a Makefile from this mess Pin
pkfox13-Oct-22 21:40
professionalpkfox13-Oct-22 21:40 
GeneralRe: Create a Makefile from this mess Pin
k505414-Oct-22 4:13
mvek505414-Oct-22 4:13 
CXX is defined in the bowels of make somewhere. It is the default variable for the C++ compiler, and is used in the rules for constructing default recipes. So for example, suppose you had an otherwise empty directory with only one file, hello.cpp, in it. Without needing to create a Makefile, you can build the hello executable just by saying "make hello". There's default rules for all kinds of things, C, Fortran, ranlib (.a) libraries, yacc, tex, and on and on. You can get a list of available recipes by saying "make -p", which for my version of make produces 1357 lines of output.

The CXX variable can be overridden by specifiying a shell variable of the same name at run time, so if for example you wanted to see what error messages clang++ spits out instead of g++ you can say
Bash
CXX=clang++ make target
Similarly you have CXXFLAGS and CPPFLAGS which pass arguments to the C++ compiler and the CPreProcessor, respectively. So you could say
Bash
CXX=clang++ CPPFLAGS="-I /path/to/includs" CXXFLAGS="-O2 -Wall -Wextra" LDFLAGS="-L /path/to/lib" LDLIBS="-lmylib1 -lmylib2" make hello
and make will apply the variables to the generated command line as expected, and produce:
clang++ -O2 -Wall -Wextra -I /path/to/includs -L /path/to/lib  hello.cc  -lmylib1 -lmylib2 -o hello

gnu make hack: You can rebuild everything from scratch, even if already compiled, without having to "make clean" by using the -B flag

It should also be noted that the Makefile I provided earlier uses GNU makeisms e.g. $(wildcard),$(patsubst). If you find yourself on a BSD or other unix like system that does not have GNU tools installed, the given make file will fail. But the variable substitutions mentioned here will still work.
Keep Calm and Carry On

QuestionIs this array of 2D vectors? Pin
Sk. Azraf Sami7-Oct-22 20:32
Sk. Azraf Sami7-Oct-22 20:32 
AnswerRe: Is this array of 2D vectors? Pin
Richard MacCutchan7-Oct-22 21:35
mveRichard MacCutchan7-Oct-22 21:35 
QuestionStyle question Pin
Mircea Neacsu3-Oct-22 15:33
Mircea Neacsu3-Oct-22 15:33 
AnswerRe: Style question Pin
Graham Breach3-Oct-22 21:23
Graham Breach3-Oct-22 21:23 
GeneralRe: Style question Pin
Mircea Neacsu4-Oct-22 2:27
Mircea Neacsu4-Oct-22 2:27 
AnswerRe: Style question Pin
CPallini3-Oct-22 23:47
mveCPallini3-Oct-22 23:47 
GeneralRe: Style question Pin
Mircea Neacsu4-Oct-22 2:28
Mircea Neacsu4-Oct-22 2:28 
GeneralRe: Style question Pin
CPallini7-Oct-22 1:35
mveCPallini7-Oct-22 1:35 
AnswerRe: Style question Pin
BernardIE53177-Oct-22 3:14
BernardIE53177-Oct-22 3:14 
GeneralRe: Style question Pin
Mircea Neacsu7-Oct-22 3:18
Mircea Neacsu7-Oct-22 3:18 
GeneralRe: Style question Pin
BernardIE53177-Oct-22 3:27
BernardIE53177-Oct-22 3:27 
GeneralRe: Style question Pin
Mircea Neacsu7-Oct-22 3:40
Mircea Neacsu7-Oct-22 3:40 
Question'System': a namespace with this name does not exist Pin
Kevin Marois3-Oct-22 6:12
professionalKevin Marois3-Oct-22 6:12 
AnswerRe: 'System': a namespace with this name does not exist Pin
Richard MacCutchan3-Oct-22 6:26
mveRichard MacCutchan3-Oct-22 6:26 
GeneralRe: 'System': a namespace with this name does not exist Pin
Kevin Marois3-Oct-22 6:30
professionalKevin Marois3-Oct-22 6:30 
GeneralRe: 'System': a namespace with this name does not exist Pin
Richard MacCutchan3-Oct-22 6:39
mveRichard MacCutchan3-Oct-22 6:39 
GeneralRe: 'System': a namespace with this name does not exist Pin
Kevin Marois3-Oct-22 6:43
professionalKevin Marois3-Oct-22 6:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.