![]() |
|
#1
|
|||
|
|||
Linking to an Include FileI have just started using MS VC++ 6 after a long lay off and have one of those problems that are irritating because you know the answer is "obvious"
here is the problem. I am trying to run a demo program which uses a file something.h which I have a copy of the code looks like CPP / C++ / C Code:
I am getting an error message: "fatal error C1083: Cannot open include file: 'something.h': No such file or directory" Obviously I need to register something.h or link to it or whatever. The question is HOW??? Last edited by LuciWiz : 29-Jan-2007 at 12:21.
Reason: Please insert your C/C++ code between [cpp] & [/cpp] tags
|
|
#2
|
||||
|
||||
Re: Linking to an Include FileIs 'something.h' a file of your own, in the project's directory?
If so, then you probably need to try: CPP / C++ / C Code:
See #include in the help for more information. __________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! |
|
#3
|
|||
|
|||
Re: Linking to an Include FileQuote:
This is somebody else's code and I am trying to understand it. Have now got it working but not sure why! When I leave the code as: #include<something.h> it appears to find it OK if it is in the directory where the code is but am not clear why as I have copied the whole lot across from the C: drive to my L: drive! I guess it just has a good sniff around in the same directory but that seems a little crude .... There is some stuff here from good old microsoft: http://support.microsoft.com/kb/85956 "The online help provides the following information about the #include preprocessor directive: If the file is still not found or if the path-spec is enclosed in angle brackets, the next directories searched are the ones specified using the /I custom compiler option. After those have been searched, the compiler searches the directories specified in the INCLUDE environment variable. This documentation is correct if the compiler is invoked from the command line. However, from within the Visual WorkBench, the INCLUDE environment variable is ignored. Instead, the directories searched are those set by choosing Directories from the Options menu in Visual C++ for Windows and in Visual C++ 32-bit edition versions 1.0 and 2.x, or by choosing the Directories Tab from the Options dialog box in Visual C++ version 4.x. This information also applies to the LIB environment variable. To set the directories searched for include files in Visual C++ version 4.x, use the following steps: 1. Select Options... from the Tools menu. 2. Select the Directories tab in the Options dialog box. 3. Select the appropriate platform (e.g., Win32) in the Platform drop-down list box. The directories to be searched will be specific to this platform. 4. Select "Include files" in the Show directories for drop-down list box. 5. Enter the full paths of the directories to be searched in the Directories editable list box, one directory per line. The directories will be searched in the order listed. 6. Press OK to confirm the selections. For more information on setting directories in Visual C++ version 4.x, search for "Setting Directories" in the Books Online. For more information on the #include preprocessor directive, search the online documentation for "#include"." |
|
#4
|
|||
|
|||
Re: Linking to an Include FileIf the file something.h is a header file that you created in your project then to include it use :
CPP / C++ / C Code:
if it is a standard header for c++ you have to use : CPP / C++ / C Code:
|
|
#5
|
|||
|
|||
Re: Linking to an Include FileQuote:
In fact, both the C standard and the C++ standard say that the paths searched for files indicated in #include <something> and also in #include "something" are implementation-defined. In other words one compiler vendor might write his preprocessor so that the <form> doesn't search the current directory but the "form" does. Or both or neither. Many compilers follow the conventions suggested by the original author of the C language, as commented in K&R first and second editions. (See Footnote.) "Any source line of the form #include "filename"or #include <filename>is replaced by the contents of the file filename. If the filename is quoted, searching for the file typically begins where the source program was found. If it is not found there, or if the name is enclosed in < and >, searching follows an implementation-defined rule to find the file." Note that this is consistent with killzone's recommendation, except his words "have to" would have to be omitted for some compilers. So: some compilers do it one way and some do it the other. I perceive that it's not very productive for me to try to guess (or argue) how someone else's compiler works. Even if I have one from the same source/vendor, installation details may cause different behavior from system to system. In other words: Your Mileage May Vary. If one way doesn't work, try the other. If it's a project managed from the Visual C++ Integrated Development Environment, add it to your project (you may have to navigate to the right directory in the project files pane). Regards, Dave Footnote: C Programmers in the 20th century knew what "K&R" meant: the book The C programming Language by Brian Kernighan and Dennis Ritchie. When the first edition was published (somewhere around 1978) there were no other books about C. UNIX had just been unleashed on the world, and much (most?) of UNIX was written in C. The second edition of K&R was published in 1988, just about the time that the first C Standard was released, and has almost everything in the so-called C89 standard. The second edition of K&R is still in print, and is as good a language reference as the Standard. And it has many examples of uses of various C language features. (And the code in the book really works!!!!!) Almost all serious C compilers comply with almost all of the language requirements spelled out in the C89 standard. That doesn't help with things specific to C++ (classes, operator overloading, function overloading, namespaces, etc.) but an awful lot of C++ is really C. (The original name of what we now call C++ was "C with Classes".) |
Recent GIDBlog
Toyota - 2008 July Promotion by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Airport Log program using 3D linked List : problem reading from file | batrsau | C Programming Language | 11 | 29-Feb-2008 07:44 |
| fltk-2.0 cvs | Plumb | FLTK Forum | 20 | 13-Nov-2004 07:10 |
| help with classes | bucho | MS Visual C++ / MFC Forum | 3 | 20-Oct-2004 06:16 |
| CD burner wont burn!! | robertli55 | Computer Hardware Forum | 1 | 18-Jun-2004 10:53 |
| Yet another CD burner problem: Lite-On LSC-24082K | Erwin | Computer Hardware Forum | 1 | 22-May-2004 11:28 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The