473,387 Members | 1,899 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,387 software developers and data experts.

Error When Building C++

Hi

(I' am using: c++,Eclipse,CDT,Mingw & GDB on windows xp)

When i have my header files in 'scorce folder' then it's working fine..

but if i have my header files in separate 'header folder' then comes the error..

'function1' was not declared in this scope
function1.h: No such file or directory

I tried with these 2 makefile files but it seem to be not working, please see if someone can help me in this.


1)
main.exe: main.o function1.o
g++ main.o function1.o -o main.exe
main.o: main.cpp function1.h
g++ -c main.cpp
function1.o: function1.cpp function1.h
g++ -c -I"C:\Documents and Settings\kdevarajan\workspace\Mycpp\Header" function1.cpp

2)
main.exe: main.o function1.o
g++ main.o function1.o -o $@
.cpp.o: function1.h
g++ -c -I"C:\Documents and Settings\kdevarajan\workspace\Mycpp\Header" $< -o $@

Thanks in advance...
Feb 25 '08 #1
1 1312
Hi,

Hi

(I' am using: c++,Eclipse,CDT,Mingw & GDB on windows xp)

When i have my header files in 'scorce folder' then it's working fine..

but if i have my header files in separate 'header folder' then comes the error..

'function1' was not declared in this scope
function1.h: No such file or directory

I tried with these 2 makefile files but it seem to be not working, please see if someone can help me in this.


1)
main.exe: main.o function1.o
g++ main.o function1.o -o main.exe
main.o: main.cpp function1.h
g++ -c main.cpp
function1.o: function1.cpp function1.h
g++ -c -I"C:\Documents and Settings\kdevarajan\workspace\Mycpp\Header" function1.cpp

2)
main.exe: main.o function1.o
g++ main.o function1.o -o $@
.cpp.o: function1.h
g++ -c -I"C:\Documents and Settings\kdevarajan\workspace\Mycpp\Header" $< -o $@

Thanks in advance...
I use the same configuration (c++, Eclipse, etc.), except that Eclipse manages the makefile for me :). But if I remember correctly, you need to specify the path to the header file when you include it.
E.g. if the file you want to include function1.h into is in the folder "source" and "Header" is a subfolder of "source", then you need to type #include "Header/function1.h".
Or if the folder "source" and "Header" are in the same folder (siblings), then write #include "../Header/function1.h".
I use this in my projects and works fine.

Bye,
Feb 27 '08 #2

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

Similar topics

6
by: M. Faust | last post by:
Hi, after having installed F2PY-2.43.239_1806 I get the following error when trying to run the hello.f example from the /docs directory: f2py.py --fcompiler=compaqv -c -m hello hello.f...
2
by: Don Sealer | last post by:
I have a database that I going to use for tracking expenses/income. I've used functions and other things I've learned here. Anyway all went well, everything works very nicely. As I was building...
4
by: ½ðÖÇΰ | last post by:
Hi£¬you guys, I'm a newbee in VS .Net I installed a VS .Net 2003 Chinese Professional in my Chinese WinXP PC. When compiling any cpp file, I got chaos codes in my output window, such as: ...
5
by: amitbadgi | last post by:
Hi guys, I am getting the following error in teh insert statement , I am converting this asp application to asp.net, here is teh error, Exception Details:...
3
by: coinjo | last post by:
#include<iostream> using namespace std; struct time { int hours,minutes,seconds; }; struct lecture {
0
by: Rich | last post by:
I am trying to obtain more debugging information for an issue I reported (ref. Bug #37185 <http://bugs.php.net/bug.php?id=37185&edit=2>). Unfortunately, I do not have access to the now-ancient...
2
by: DCC700 | last post by:
VS 2005 Converted Header causing error when publishing After converting from Visual Studio 2003 to 2005, I have had several issues with a header that is used throughout the project. The...
0
by: mchuc7719 | last post by:
Hello, I have a Vb.Net 2005 ClassLibrary, when I try to compile using MSBee, only get errors. Before I to run the command line, I open in notepad the .vbproj and I was add the next line: ...
6
by: guxu | last post by:
I have a managed C++ code which calls some methods in unmanaged C++ DLL. In my unmanaged DLL, I have a PROTECTED virutal function in a base class and derived class has a PRIVATE function which...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.