Solved

How to create a Makefile that sorts out lots of dependencies

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Linux daemon 11 353
linux / python expert needed 3 88
Ubuntu 16.04 Emergency Boot 2 169
Linux "time" command output redirection 16 122
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 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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

864 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

22 Experts available now in Live!

Get 1:1 Help Now