Solved

How to create a Makefile that sorts out lots of dependencies

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
please append a correct root= boot option HELP! cant boot up linux server! 22 691
LDAP server on Linux Redhat 6 2 503
Problem to line 1 51
pipe to sed or perl, please help 5 128
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

810 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