LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-27-2012, 10:22 AM   #1
vasilythecat
LQ Newbie
 
Registered: Aug 2012
Posts: 1

Rep: Reputation: Disabled
Question Need help with Makefiles and compiling


Hi,
I'm very new to Makefiles and I need some help...
I have a C++ program with 3 directories (A, B, and C). I want to create a Makefile in each directory where it will only compile files in that directory. One of the problems is that files in A #include header files in B and C and those files either don't compile yet or the compiler tells me that FileInB.h doesn't exist...

I want to create a Makefile to compile FileInA who's header looks like this:
Code:
#ifndef FILEINA
#define FILEINA

#include "FileInB.h"

class FileInA {
   // some functions
}
#endif
The Makefile in A is simply this (don't laugh...):
Code:
all:
   g++ FileInA.cpp
When I run make in the A directory, I get:
"FileInB.h: No such file exists"

It sounds like I need to set the path to FileInB.h in A's Makefile, right? How would I do that and would it let me compile without compiling anything in B or C?

I really appreciate any help anyone can offer.
Thanks
 
Old 08-27-2012, 10:28 AM   #2
abrinister
Member
 
Registered: Dec 2010
Location: /home
Distribution: RL: Arch x64 VM: Debian
Posts: 460

Rep: Reputation: 38
Because FileInB.h is in another folder. So your include should reflect that. Make will follow those include paths. You just have to set the right one.

Alex Brinister
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Regarding makefiles abhishekgit Linux - Newbie 11 04-06-2012 03:49 AM
LXer: Beyond Makefiles: GNU make is For More Than Just Compiling LXer Syndicated Linux News 0 06-15-2010 02:20 PM
compiling and makefiles dasy2k1 Linux - Newbie 7 06-09-2006 09:26 PM
Makefiles deveshs Linux - Software 2 05-02-2005 06:26 AM
Why makefiles parthi4u Programming 4 03-08-2003 04:14 PM


All times are GMT -5. The time now is 08:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration