Solved

How to create a Makefile that sorts out lots of dependencies

Posted on 2006-07-24
5
245 Views
Last Modified: 2010-04-22
Hi everybody,

My problem is that I can't compile the test class because the header it uses also uses several headers that again uses their headers etc.
the Library I'm working on is called ghmm (www.ghmm.org) the main directory for ghmm where the configuration etc is, is /ghmm/
Where the headers and their sources are locted is at /ghmm/ghmm/
The Test files are located, this is also where my files are stored /ghmm/tests/

Cheers
Idar
0
Comment
Question by:Idarhillgaar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 17167649
# asuming C or C++ source files:
gcc -MM list of your C-files >>Makefile
0
 
LVL 8

Accepted Solution

by:
manish_regmi earned 500 total points
ID: 17168512
you can also use the -I option of GCC
-I./ -I../ -I<your header path 1> -I<your header path 2> -I<your header path n>


Here is a simple makefile

# Makefile for easy compilation.:-)

OPTIONS = -Wall -O2
INCLS = -I. -I../ -I<your list of path to headers>

CC = gcc
LD = ld
      
OBJS = $(wildcard *.o) #// you can also give list of .o  files

all: <your executable name>
.c.o:
      $(CC) -c $(OPTIONS) $(INCLS) $< -o $@

<your executable name>: $(OBJS)
      $(LD) -o <your executable name> $(OBJS)
clear:
      rm -f $(OBJS)
      rm -f *.c~ *~

regards
Manish Regmi


0
 

Author Comment

by:Idarhillgaar
ID: 17169253
Hi guys, I solved it here, my problem was that the link did now know where to look

Solved:
test.c
     gcc -o output.run test.o -lstdc++ ../ghmm/.libs/libghmm.a -lm -lpthread

test.o: test.c
   gcc -c test.o output.run -I..   (the class must then help the make file find the library by ie #include <ghmm/sequences.h>
 

clean:
       rm test.o output.run

thanks though, Manish you were closest to my final solution - thanks
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 17169811
> .. you were closest to my final solution ..
.. which (suggestion and solution) has nothing to do with the initial question :-/
0
 

Author Comment

by:Idarhillgaar
ID: 17170076
just simpler thats all - implemented before I saw your solution though
0

Featured Post

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question