Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


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

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

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:
#ifndef FILEINA
#define FILEINA

#include "FileInB.h"

class FileInA {
   // some functions
The Makefile in A is simply this (don't laugh...):
   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.
Old 08-27-2012, 09:28 AM   #2
Registered: Dec 2010
Location: Boston, MA, USA
Distribution: Arch Linux
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.


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 02:49 AM
LXer: Beyond Makefiles: GNU make is For More Than Just Compiling LXer Syndicated Linux News 0 06-15-2010 01:20 PM
compiling and makefiles dasy2k1 Linux - Newbie 7 06-09-2006 08:26 PM
Makefiles deveshs Linux - Software 2 05-02-2005 05:26 AM
Why makefiles parthi4u Programming 4 03-08-2003 03:14 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:24 PM.

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