Error compiling from command line

Posted on 1998-11-28
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
  • 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".

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?

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

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 200 total points
ID: 1416432
Problem solved by e-mail.  Needed to link to winmm.lib.

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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.…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

705 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now