C++

I have been trying to compile and build my c++ program with nmake but it keeps writing this after everything. Please is there any tips to help me build this on windows.

C:\Users\devcp\Documents\Projects> nmake
nmake : The term 'nmake' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling
of the name, or if a path was included, verify that the path is correct and try again.
+ nmake
+ ~~~~~
+ CategoryInfo : ObjectNotFound: (nmake:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

NMAKE must run in a Developer Command Prompt window.

See https://docs.microsoft.com/en-us/cpp/build/reference/nmake-reference?view=msvc-170
If you type a command like nmake in the terminal, then the shell (command-line interpreter) will search the current directory as well as all directories specified in PATH for a program (or script) of that name.

One way to set up the "environment" for Visual C++ is by running this helper script:
"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat"

This will add the Visual C++ tools to the PATH of the current terminal session. It does not effect new terminals you open afterwards! So you have to run this inside of your current terminal before you try to use nmake.
Last edited on
@kigar64551,

I don't know if you already know this, the Visual Studio installer creates start menu shortcuts that will do that housekeeping for you. Developer Command Prompt, Developer PowerShell and several Native Tools command prompts.

I've only used the Developer Command Prompt a couple of times I mucked around with command-line compiling with VS.

https://docs.microsoft.com/en-us/cpp/build/walkthrough-compiling-a-native-cpp-program-on-the-command-line?view=msvc-170

Command-line compiling within a Developer Command Prompt can create the same diversity of applications the VS IDE can. Console-mode, full-blown Desktop WinAPI GUI, mobile, etc.

I prefer using the IDE. What the native tool command prompts do and how they differ from the developer command prompt I haven't a clue.
I know about those start-menu entries ;-)

Still, by using the vcvarsall.bat script, you can "enable" the Visual C++ tools in any running terminal session, rather than having to start a new terminal each time. Sometimes this comes in handy.

Also it is very useful for scripting. For example, you can create a build.bat in your project directory:
1
2
3
4
@echo off
call "%VS2022INSTALLDIR%\VC\Auxiliary\Build\vcvarsall.bat"
cd /d "%~dp0"
nmake
Last edited on
Still, by using the...

Not my coding style.

"IDE Is The Thing For Me!"

Knowing alternate ways to do things is not "wrong," though. The few times I've fired up a command prompt to do things with VS it has been the VS pre-installed environment links.

I'm a self-taught C++ programming hobbyist, my "work flow methods" work for what I want to do.

Other people might need different ways to do things, and be more productive.
For years I have only done commandline compiling with C++. However, I only use the pre-defined shortcuts George mentioned. However, a member here and friend of mine does it from scratch and builds his own batch file to build apps from. You know, there's one s**t pile of lib, include, binary paths that have all correctly to be worked out. We had a big go around on it here maybe a year or two ago. I'll see if I can dig up the posts. I use NMAKE to build my C Runtime Replacement, but I use it within Microsoft's shortcuts on the start menu.
freddie1 wrote:
For years I have only done commandline compiling with C++.

I've just briefly dabbled with that, using MSYS2's terminal setup. I know VS can do command-line compiling, I have done it once or twice.

I simply find it more difficult to separate out the editing, compiling, testing and debugging into individual steps outside of an IDE to be cumbersome. I am not a professional programmer, doing it is just a hobby.

Plus VS is currently the only compiler that is 100% C++20 compliant. My current "self-teach" objectives are to get more conversant with what C++20 (as well as C++17) puts into the toolbox, something only VS can do.

I'm a slow, methodical learner. I like to create multiple examples that show off a different part of a feature.
Pretty much with you George. Agree with a lot of what you said. However, I found it really interesting a few months back I bought an old Book on C++ coding (around the 2014 time span, by none other than Bjarne Stroustrup. In the early pages of the book (first 50 when discussing elementery things), Stroustrup specifically mentioned command line compiling several times. I'll not provide his exact word (I could, I have the book), but basically he said he knows a lot of professional programmers who do command line compiling, and he knows a lot who use an IDE of some kind or other. So it's simply up to one's preferences, same as the font or colours one uses in his/her editor. However, I do have to admit I get just a bit aggravated when I hear folks telling me I'm foolish for building from the command line.

I'm old, retired, and dying of cancer. Before I read Stroustrup's book above I lauglingly joked that the only two people in the world that did command line compiling was Freddie and Jim Fuller (a registered member here who only rarely posts) I owe Jim an email, but was a bit loathe in providing his name, because like I, he is old and is struggling at times. He showed me here how he does it in posts mayber a year or two ago, but I looked hard and could not find them. Jim writes all his code from scratch to invoke all MS compiler functionality.

Another person who definitely knows how to build with MS C/C++ without the shortcuts on Visual Studio's Start Menu is Steve Hutcheson who runs the masm32 forum. Both of these individuals have, as I have, their rather atypical uses and valid reasons for doing command line compiling (they both create install scripts for other programming languages, where somehow or other C++ tool chain figures in.

For anyone interested why I do it, I make a very unusual use of C++. Very, very unusual. I do not use the default C Runtime provided by Microsoft for my coding. I use nothing from any parts of the C++ specific part of the Standard Library. I've worked with many different programming languages in my lifetime, and what I do works for me, same as the font I use for my bad eyes and my colors I use in whatever code editor I choose to use

continued...
Do a search for vcvarsall.bat. On my box for VS 2019 it's here...

[CODE]
%comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\
[\CODE]

If anyone wants to write their own personal and unique copy of that, it's fine with me. Have at it. I've no desire myself.

The only other thing I can add is that TDM GCC-64 works much better with this. To invoke that C++ compiler, one needs to simply use CD (Change Directory) to navigate to one's source code, and maybe execute a Set %PATH%= command to tell the compiler where the build chain is at - depending on whether in your installation you told the installer to install the PATH.
I don't post here often because I am not a c++ programmer.
As Fred said I am on old fart but with my roots in BASIC: Atari Basic -> MS Basics -> PowerBASIC -> BCX.
In my opinion c++ is "THE" language but I dislike the nomanclature.I learned just enough c++ to get by in my basic world .
I am not as minimalistic as Fred. I embrace the c++ STL where needed but I do enjoy using his TCLIB for tiny apps.
My language of choice is BCX, a Basic to c/c++ translator. The editor I use is capable of setting environment variables before shelling out to my batch files.
I emailed my batch file to Fred and he will post it if it works for him

James
Where the BAT files (yes, there are several) are located depends on which VS version we are talking about, I currently have both VS 2019 and VS 2022 installed, on a secondary data drive separate from my boot drive.

D:\Programming\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build
or
D:\Programming\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build

There still are a lot of support files "littering up" my C:\ boot drive for 2019/2022.

I had VS 2017 installed along with VS 2019 before VS 2022 was officially released until one day 2017 went all "wiggy." Bunches of errors on startup that even a "repair installation" wouldn't correct. There are still a handful of 2017 SDK/support files installed that became integrated into 2019 and now 2022 so removal won't be a clean surgical slice and snip affair.
Heard from James Fuller and also finally found James batch file code which does command line compiling using Visual Studio without the shortcuts of Visual Studio's Start Menu. Here the link from around October 2020.....

http://www.cplusplus.com/forum/windows/273083/

None of this is easy. I doubt if James' code (an expert at batch file work) is any easier to follow than Microsoft's vcvarsall.bat If the OP has abandoned this post which is most likely, then all I can say is shame and typical newbie BS. You want to do something hard, and when the going gets tough and others who have spent years and years working everything out won't spoon feed you the information, then you quit and start pestering other folks about some other wierd bs.
Just reread the OP's original post. He's trying to use Microsoft's version of *nix make - NMAKE, under a directory that looks like a Dev-C++ installation directory.

Personally, I've never succeeded in using MAKE where building Windows Mingw programs.

NMAKE, on the other hand, works well when using the MSVC build chain.

If the OP has installed a version of mingw, for exmple TDM - GCC-64 (or anything), I'd be very happy to show how it's done. I've done it over and over for many years. The issue concerns using very simple system commands such as Change Directory (CD) or Set Path, etc.
Registered users can post here. Sign in or register to post.