Solved

How to create a Makefile that sorts out lots of dependencies

Posted on 2006-07-24
5
228 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
  • 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now