Click here to Skip to main content
15,795,318 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionCreate a Makefile from this mess Pin
pkfox8-Oct-22 3:56
professionalpkfox8-Oct-22 3:56 
AnswerRe: Create a Makefile from this mess Pin
Richard MacCutchan8-Oct-22 6:34
mveRichard MacCutchan8-Oct-22 6:34 
GeneralRe: Create a Makefile from this mess Pin
pkfox8-Oct-22 6:42
professionalpkfox8-Oct-22 6:42 
GeneralRe: Create a Makefile from this mess Pin
Richard MacCutchan8-Oct-22 6:57
mveRichard MacCutchan8-Oct-22 6:57 
GeneralRe: Create a Makefile from this mess Pin
pkfox8-Oct-22 7:17
professionalpkfox8-Oct-22 7:17 
AnswerRe: Create a Makefile from this mess Pin
k505413-Oct-22 6:53
mvek505413-Oct-22 6:53 
GeneralRe: Create a Makefile from this mess Pin
pkfox13-Oct-22 22:40
professionalpkfox13-Oct-22 22:40 
GeneralRe: Create a Makefile from this mess Pin
k505414-Oct-22 5:13
mvek505414-Oct-22 5: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 21:32
Sk. Azraf Sami7-Oct-22 21:32 
AnswerRe: Is this array of 2D vectors? Pin
Richard MacCutchan7-Oct-22 22:35
mveRichard MacCutchan7-Oct-22 22:35 
QuestionStyle question Pin
Mircea Neacsu3-Oct-22 16:33
Mircea Neacsu3-Oct-22 16:33 
AnswerRe: Style question Pin
Graham Breach3-Oct-22 22:23
Graham Breach3-Oct-22 22:23 
GeneralRe: Style question Pin
Mircea Neacsu4-Oct-22 3:27
Mircea Neacsu4-Oct-22 3:27 
AnswerRe: Style question Pin
CPallini4-Oct-22 0:47
mveCPallini4-Oct-22 0:47 
GeneralRe: Style question Pin
Mircea Neacsu4-Oct-22 3:28
Mircea Neacsu4-Oct-22 3:28 
GeneralRe: Style question Pin
CPallini7-Oct-22 2:35
mveCPallini7-Oct-22 2:35 
AnswerRe: Style question Pin
BernardIE53177-Oct-22 4:14
BernardIE53177-Oct-22 4:14 
GeneralRe: Style question Pin
Mircea Neacsu7-Oct-22 4:18
Mircea Neacsu7-Oct-22 4:18 
GeneralRe: Style question Pin
BernardIE53177-Oct-22 4:27
BernardIE53177-Oct-22 4:27 
GeneralRe: Style question Pin
Mircea Neacsu7-Oct-22 4:40
Mircea Neacsu7-Oct-22 4:40 
Question'System': a namespace with this name does not exist Pin
Kevin Marois3-Oct-22 7:12
professionalKevin Marois3-Oct-22 7:12 
AnswerRe: 'System': a namespace with this name does not exist Pin
Richard MacCutchan3-Oct-22 7:26
mveRichard MacCutchan3-Oct-22 7:26 
GeneralRe: 'System': a namespace with this name does not exist Pin
Kevin Marois3-Oct-22 7:30
professionalKevin Marois3-Oct-22 7:30 
GeneralRe: 'System': a namespace with this name does not exist Pin
Richard MacCutchan3-Oct-22 7:39
mveRichard MacCutchan3-Oct-22 7:39 
GeneralRe: 'System': a namespace with this name does not exist Pin
Kevin Marois3-Oct-22 7:43
professionalKevin Marois3-Oct-22 7: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.