Error compiling from command line

Posted on 1998-11-28
Medium Priority
Last Modified: 2013-12-03
I just purchased Petzold's "Programming Windows 95" and I'm
trying to compile the first program, "Hello, Windows 95!"

I ran two batch files as I was instructed to in the book,
to set DOS environment variables,
I have call statements in my autoexec.bat file to run these.

When I issue the command
nmake hellowin.mak
I get the following stuff:

hellowin.c(6) : fatal error C1034: windows.h: no include path set
NMAKE : fatal error U1077: 'c1' : return code '0x2'

I have the correct path under SET PATH in my autoexec.bat file.  So, I guess I'm supposed to set the path some other way.  

I tried changing #include <windows.h> in hellowin.c to
#include <e:msdev\include\windows.h> and that worked, except now the compiler wants the path to all the header files included in the windows.h file.  

So, how and where do I set the path so that the compiler can
find all the windows header files in my \msdev\include directory?

Question by:miredo
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
LVL 15

Expert Comment

by:Tommy Hui
ID: 1416421
In your autoexec.bat, use the following statement:

  set include=e:\msdev\include

If you have more than one include paths, then separate them with semicolons like this:

  set include=e:\msdev\include;e:\msdev\mfc\include


Author Comment

ID: 1416422
I put the following in my autoexec.bat file
SET INCLUDE=E:\msdev\include
and I got the following error when I issued the command nmake hellowin.mak:
hellowin.c(6) : fatal error C1083: Cannot open include file: 'windows.h': no such file or
I checked the e:\msdev\include directory -- it exists and the windows.h file is definitely there.
LVL 22

Expert Comment

ID: 1416423
1. did you check in DOS that the INCLUDE environment variable is still correct after the autoexec finishes?

type "SET" or "SET | MORE" at the command line to see what the environment is set to.

2. Is the makefile you are running actually for the version of VC that you are running?  (makefile syntax has changed over time. and also changes from product to product).  If not, your best bet might be to abandon the makefile and compile it "manually".
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments


Author Comment

ID: 1416424
I used the SET command -- the INCLUDE environment variable is right.

I'm supposed to be using Microsoft Visual C++ version 4.0, and I am.
(I went to Help/About Microsoft Developer Studio, and it says Visual C++ 4.0)

How do I go about compiling it "manually"?
LVL 22

Expert Comment

ID: 1416425
just create a project of the appropriate type (win32 application or win32 DLL (probably non-MFC unless this is an MFC example, but I doubt it.)

Then insert the source code files into the project, also insert any resources file it might use or any libraryes (probably none).  

Then compile it.  That should be it unless the example does things that would require you to tweak the project settings.  But most likely there will be few or no changes needed.

Author Comment

ID: 1416426
I followed those instructions.  Actually, after inserting the files into the project (a .c file
and a .wav file), the "compile" option is not active.  So, I chose "Build hellowin.exe" and
it seems to try to compile first -- before I get the identical error I got on the command line:
"No such file or directory"
All this program does is bring up a big window with "Hello Windows 95!" centered in it, and play the .wav file of Petzold saying those words.  If I needed to change settings, what
settings might I be changing?

LVL 22

Expert Comment

ID: 1416427
Does it say what file it is that it can't find?

You might want to destroy the make file.  If it can find the make file, it might be using it rather than compiling it using its settings.

Author Comment

ID: 1416428
I deleted the make file that was from the book, as well as the makefile that the compiler
created before, and clicked "Build Hellowin.exe".  Here's the error message:  

--------------------Configuration: hellowin - Win32 Debug--------------------
E:\Msdev\Bin\Hellowin.c(6) : fatal error C1083: Cannot open include file: 'windows.h': No such file or directory

Error executing cl.exe.
hellowin.exe - 1 error(s), 0 warning(s)

LVL 22

Expert Comment

ID: 1416429
In the future you should not be creating your projects in the VC's directories.  Put your projects in a sedperate part of the dircectory tree.  That makes it easher to manage as versions fo VC change.

Is windows.h being specified in angle brackets "<" ">" in your source code, rather than quotes?  It should be.

We need to check the include paths for VC.  What version of VC is this?  In 5 and 6 you go to the Tools menu, Options Item, and then the directories tab.  Then select "include files" from the list box on the top-right.  That should display the include directories.  You should check to make sure they are valid and that windows.h is in one of them.  (It should be a dirrectory like \DEVSTUDEO\VC\INCLUDE.)

Author Comment

ID: 1416430
Fixing the include path worked.  I have version 4.0 (which the book recommends for
the examples), but I went to the same place to change the include path.

Now I am getting this error:

--------------------Configuration: hellowin - Win32 Debug--------------------
Hellowin.obj : error LNK2001: unresolved external symbol __imp__PlaySoundA@12
Debug/hellowin.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
hellowin.exe - 2 error(s), 0 warning(s)

LVL 22

Expert Comment

ID: 1416431
It sounds like you are not linking to the window libraries.  This should be done automatically for a win 32 application.  Why don't you send me the files (including the original make file.)  I'll see if I can make it work and send back the steps I use.
LVL 22

Accepted Solution

nietod earned 800 total points
ID: 1416432
Problem solved by e-mail.  Needed to link to winmm.lib.

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question