Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to create a Makefile that sorts out lots of dependencies

Posted on 2006-07-24
5
Medium Priority
?
249 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 1500 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

660 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