473,408 Members | 1,982 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

C++ includes problem

Hi all,
I have to include files from different projects in the solution file. I mean I have a temp.cpp in the project Test1 and work.h,work.cpp in the project Test 2 in my visual studio solution.

The structure is -
Test1\temp.cpp
Test2\work.h
Test2\work.cpp

If I have to include work.h in temp.cpp, I'm using the following code

#include "../Test2/work.h"

I'm getting the following error -
Error 1 fatal error C1083: Cannot open include file: '../Test2/work.h': No such file or directory c:\documents and settings\santosh singh\my documents\visual studio 2005\projects\mySolution\Test1\temp.cpp 13

I tried giving all possible combinations -

#include "..\Test2\work.h"
#include "..//Test2//work.h"
#include "..\\Test2\\work.h"

it did'nt work. Please help me out.


Thanks in advance.

Regards,
SC
Mar 17 '07 #1
7 1668
horace1
1,510 Expert 1GB
Expand|Select|Wrap|Line Numbers
  1. #include "..\\Test2\\work.h"
  2.  
should work if subdirectories Test1 and Test2 are in the same directory?
Mar 17 '07 #2
Hi,
Thanks for the reply.

Yes, Test1 and Test2 are in the same parent directory.

mySolution\Test1
mySolution\Test2

I have to include files from Test2 in Test1

Thanks again,
SC

Expand|Select|Wrap|Line Numbers
  1. #include "..\\Test2\\work.h"
  2.  
should work if subdirectories Test1 and Test2 are in the same directory?
Mar 17 '07 #3
horace1
1,510 Expert 1GB
Hi,
Thanks for the reply.

Yes, Test1 and Test2 are in the same parent directory.

mySolution\Test1
mySolution\Test2

I have to include files from Test2 in Test1

Thanks again,
SC
in that case when compiling a file in Test1
Expand|Select|Wrap|Line Numbers
  1. #include "..\\Test2\\work.h"
should include file work.h in Test2

have a read thru
http://msdn2.microsoft.com/en-us/library/36k2cdd4(VS.80).aspx
Mar 17 '07 #4
Hi,
Thanks for the reference. I went through it. I'm giving the fully qualified name of the include file as #include "..\\Test2\\work.h"

I guess my problem is with the syntax.

Please let me know if the syntax is right as I couldn't find much help elsewhere.

Thanks again,
SC


in that case when compiling a file in Test1
Expand|Select|Wrap|Line Numbers
  1. #include "..\\Test2\\work.h"
should include file work.h in Test2

have a read thru
http://msdn2.microsoft.com/en-us/library/36k2cdd4(VS.80).aspx
Mar 17 '07 #5
DeMan
1,806 1GB
I have occasionally encountered similar problems when using an IDE (rather than a command line compiler). There is usually an option in the menus (Project Options or similar) where you can specify the directories where the compiler will look for code. To use the same path you have, you can make sure that "mySolution/Test1" is in the path, alternatively, If you add "mySolution/Test2" to the path, you can simply #include "work.h".

If you are working from a command line, make sure the path includes "." (or "./")
Mar 18 '07 #6
horace1
1,510 Expert 1GB
Hi,
Thanks for the reference. I went through it. I'm giving the fully qualified name of the include file as #include "..\\Test2\\work.h"

I guess my problem is with the syntax.

Please let me know if the syntax is right as I couldn't find much help elsewhere.

Thanks again,
SC
the syntax looks fine and similar code works on my machine OK with gcc.
I guess it could be a problem with Visual Studio which I don't use. DeMan made some suggestions - try them out.
Can you compile from the command line ? or try with a different compiler?
Mar 18 '07 #7
Hi,
I figured out what the problem was. In VC++, the compiler takes the debug directory as the reference. So, I just have to give ../../file.h.

Thanks a lot for your support.

SC


the syntax looks fine and similar code works on my machine OK with gcc.
I guess it could be a problem with Visual Studio which I don't use. DeMan made some suggestions - try them out.
Can you compile from the command line ? or try with a different compiler?
Mar 24 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Yannick Turgeon | last post by:
Hello all, We are currently changing our web server and, in the process, updating PHP version from 4.3.0 to 4.3.5. The problem we've got is that our way to include some files in other ones is no...
11
by: Yannick Turgeon | last post by:
Oups! I did a typing error in my last post. Fixed. ----------- Hello all, We are currently changing our web server and, in the process, updating PHP version from 4.3.0 to 4.3.5. The problem...
2
by: Joe Mowry | last post by:
First off, I'm posting this question for a friend that doesn't have access to the news groups. Problem: Using PHP as the base and has several PHP < includes > for various functions, all this...
4
by: Patrick | last post by:
I have an ASP site with about 50 ASP files, all of which are currently including a common "includes.asp" file near the top of the file, responsible for generating the <HEAD/> section of the HTML ...
7
by: MyndPhlyp | last post by:
I am building up a library of Class'es that represent various columns of table layouts. One often used column is "name" and each occurrence is treated identically. (What a concept, eh?) Part of...
4
by: Generic Usenet Account | last post by:
I am seeing some unexpected behavior while using the STL "includes" algorithm. I am not sure if this is a bug with the template header files in our STL distribution, or if this is how it should...
8
by: Jim | last post by:
Hi: Do we have some common style for includes when working on a project with lots of c and h files. Wat I mean is do we have a rule in C when a file includes several files and those file in turn...
12
by: tshad | last post by:
I am not sure why I am getting this error: I have the following code I want to run from another include file that holds all my functions. functions.inc...
6
by: William F. Zachmann | last post by:
We've got a project going that involves moving an old web site with a massive dll written in C++ that produces most of the output from a SQL 7.0 data base on NT4 onto IIS on Windows 2003 Server...
6
by: kwest | last post by:
I just setup a new server with PHP 5 and ran into a problem with includes. Everytime I call something like require_once './includes/test.inc' I get a permissions message like this: Warning:...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.