• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1122
  • Last Modified:

Error compiling from command line

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,
VCVARS32.BAT and MSC.BAT
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
hellowin.c(6) : fatal error C1034: windows.h: no include path set
NMAKE : fatal error U1077: 'c1' : return code '0x2'
Stop.

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?






0
miredo
Asked:
miredo
  • 6
  • 5
1 Solution
 
Tommy HuiEngineerCommented:
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


0
 
miredoAuthor Commented:
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
directory
I checked the e:\msdev\include directory -- it exists and the windows.h file is definitely there.
0
 
nietodCommented:
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".
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
miredoAuthor Commented:
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"?
0
 
nietodCommented:
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.
0
 
miredoAuthor Commented:
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?


0
 
nietodCommented:
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.
0
 
miredoAuthor Commented:
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--------------------
Compiling...
Hellowin.c
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)

0
 
nietodCommented:
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.)
0
 
miredoAuthor Commented:
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--------------------
Compiling...
Hellowin.c
Linking...
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)

0
 
nietodCommented:
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.
0
 
nietodCommented:
Problem solved by e-mail.  Needed to link to winmm.lib.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now