Windows source I found won't compile

Pages: 12
Still no luck James. Here's my console screen...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Microsoft Windows [Version 10.0.18362.1082]
(c) 2019 Microsoft Corporation. All rights reserved.

C:\Users\freddie>cd\

C:\>CD C:\Code\CodeBlks\C++\Form1

C:\Code\CodeBlks\C++\Form1>VSCPP.BAT Main gui -m64
Using Visual Studio BuildTools 2019
The system cannot find the path specified.
Compiling "Main.cpp" To
'cl.exe' is not recognized as an internal or external command,
operable program or batch file.
Finished

C:\Code\CodeBlks\C++\Form1>VSCPP.BAT Main -m64 gui
Using Visual Studio BuildTools 2019
The system cannot find the path specified.
Compiling "Main.cpp" To "a Windows Gui App"
'cl.exe' is not recognized as an internal or external command,
operable program or batch file.
Finished

C:\Code\CodeBlks\C++\Form1>


I had changed Main.cpp as you mentioned....

1
2
3
4
5
6
#include <windows.h>
#include <tchar.h>
#pragma comment(lib,"kernel32.lib")
#pragma comment(lib,"user32.lib")
....
....
The system cannot find the path specified.
Something is going wrong in your .bat file. Have you been able to compile a simple "hello world" program from the command-line? Try that first.

But also, just find where cl.exe is on your system, and add the directory to your Path variable.

e.g. try
C:\Program Files (x86)>dir /s cl.exe


For just the paths themselves:
C:\Program Files (x86)>dir /a /b /s cl.exe


Edit: Sorry I think I'm confusing your post with jcfuller. I didn't see the batch file in the previous page. I guess ignore this post.
Last edited on
Fred,
It appears this file does not exist on your system in the same directory as it does on mine???

C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat

Can you locate vcvarsall.bat on your system?

James
Last edited on
Are you using VS community or professional?
In Professional, that file is located @
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\

I'm not sure about community.

The other problem appears to be that vanilla batch file scripting is fundamentally fragile and error-prone.

1
2
3
IF EXIST C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat(
    echo hello
}

Appears to print "hello" for me regardless of if the file in question exists. Probably has to do with some combination of spaces and lack of quotes in the filename, and the opening parenthesis.

It works for me once I do add quotes and a space:
IF EXIST "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvarsall.bat" (
    echo hello
)

Last edited on
Thanks Ganado I do believe that was the issue.
I have the Community build on all the machines I test on so I never saw the failure

James
Here's where my vcvarsall.bat file is located....

%comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"

As noted above, I only install the free community edition. I don't deign to use the ide at all. I just use the build tool chain.

It might depend on whether the moon is full or not as to where Microsoft puts stuff.

Oh, I see you want vcvarsall.bat. Give me a second.
Last edited on
Got lots of vcvarsall.bat...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
C:\Program Files (x86)>dir /s vcvarsall.bat
 Volume in drive C is Windows
 Volume Serial Number is 3230-2F4C

 Directory of C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build

05/17/2020  12:22 PM             9,859 vcvarsall.bat
               1 File(s)          9,859 bytes

 Directory of C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC

11/05/2015  09:31 PM             2,539 vcvarsall.bat
               1 File(s)          2,539 bytes

 Directory of C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC

01/05/2005  01:51 PM             1,247 vcvarsall.bat
               1 File(s)          1,247 bytes

     Total Files Listed:
               3 File(s)         13,645 bytes
               0 Dir(s)  846,705,942,528 bytes free

C:\Program Files (x86)>
Thanks Fred.
I updated my batch file post here (and emailed one to you) It was just as Ganado said: Missing double quotes and a space before the "("

I apologize to the original poster for hijacking the thread..

James

Thanks James and Ganado!

I may not be able to test for a few days as my wife has company coming any minute, so I may be 'going dark' for awhile.

Fred
Works now James!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Microsoft Windows [Version 10.0.18362.1082]
(c) 2019 Microsoft Corporation. All rights reserved.

C:\Users\freddie>cd\

C:\>CD C:\Code\CodeBlks\C++\Form1

C:\Code\CodeBlks\C++\Form1>VSCPP.BAT Main -m64 gui
Using Visual Studio Cummunity 2019
**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.5.5
** Copyright (c) 2019 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
Compiling "Main.cpp" To "a Windows Gui App"
Main.cpp
Finished

C:\Code\CodeBlks\C++\Form1>
I don't think you hijacked the thread James. Look at it this way...

Alexander's whole problem here seems to be in setting up a Visual Studio C++ project to create a Win32 SDK based Api program. There was nothing at all wrong with the code he posted which he apparently obtained from a tutorial somewhere. So there are two bodies of 'know how' involved 1) C++ coding skills; 2) Knowledge of how to use a complicated IDE and what it does to build a binary. I tested his code to determine if there were any problems with it and there weren't. I mentioned I built the code from the command line, I posted that output, and he asked....


Thanks. I will try Visual Studio 2019, but how do you compile without starting a project?


That's when you posted your original batch file.

I've always thought that folks learning C or C++ ought to become familiar with command line compiling/linking. In 2016 I submitted a tutorial here on that topic. Its still 'awaiting' approval. At this time its outdated as I spent a fair amount of time explaining how to download and install the Windows 7 SDK, and how to use the command line interface to build code. Maybe the administrators here didn't think my tutorial was any good. I never heard from them. I did my best with it.
Maybe the administrators here didn't think my tutorial was any good. I never heard from them.
Actually the admin appeared 2012 the last time. See:

http://www.cplusplus.com/forum/lounge/71307/4/#msg383059

So chances are that there are no administrators.
Maybe the administrators here didn't think my tutorial was any good.

Or maybe the administrators/site owner gave up expanding/updating the site, real life became more important. The last approved article is dated 16 Sept 2016.
Well, that makes me feel a little better coder and Furry Guy. I'm not really very much up on how internet sites work so on and so forth. It must take some effort and expense to keep a site up, doesn't it?
Last edited on
Maintaining a site like CPP -- other than the forum as long as the database of posts stays intact -- is quite a lot of effort, especially if one wants the information to be up-to-date and accurate.

The internet usage bills for the bandwidth consumed are not insignificant either. Also the cost of hosting the site, keeping the domain name active, etc.

And, no, I don't have much of a clue of the administrative details of having an active website as well. :Þ

For a site that APPEARS to be under little to no active maintenance having CPP up and running with no problems (at least to us chickens users) is simply amazing.
Last edited on
Registered users can post here. Sign in or register to post.
Pages: 12