Thread: please help with the Makefile

  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    11

    please help with the Makefile

    Hi All

    I am a Ph.D student in Physics and a newbie in programing. I am running a code made by someone else and now I am stuck badly at a point.
    I have a set of C codes [A1.c, A2.c, A3.c, A4.c].
    A2.c, A3.c and A4.c have different tasks and A1.c is the main program which is calling the other 3 codes as and when required.
    To compile all of them togtether, I have a Makefile which is :

    Code:
    LIBS= -lm 
    CPATHS= -L /usr/local/lib
    ALL : prog
    prog :	A1.c
    	cc $(CPATHS) -O4 -Wall -o prog A1.c A2.c A3.c A4.c $(LIBS) 
    clean :
    	rm prog
    To compile and run, I do the following :

    alice@alice-laptop:~$ make clean
    alice@alice-laptop:~$ make
    alice@alice-laptop:~$ ./prog value1 value2

    But now I have identified some problem in A4.c and need to use a package, SUNDIALS package.
    To run a single code, say equations.c, INDEPENDENTLY (i.e. not being compiled simultaneously with other codes) in SUNDIALS, I have to run a command :

    alice@alice-laptop:~$ cc -I/usr/local/sundials/include equations.c -L/usr/local/sundials/lib -lsundials_cvode -lsundials_nvecserial -lm

    But now I have to run A4.c using SUNDIALS, along with the other codes (i.e. A1.c A2.c A3.c), as I was doing earlier.

    What modifications should I make in my Makefile so that A1.c A2.c A3.c A4.c are all compiled together, as it was being done earlier, but A4.c can also use the package SUNDIALS ??


    Please help.
    Regards
    Alice

  2. #2
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Code:
    LIBS= -lm -L/usr/local/sundials/lib -lsundials_cvode -lsundials_nvecserial
    CPATHS= -L /usr/local/lib -I/usr/local/sundials/include
    ALL : prog
    prog :	A1.c
    	cc $(CPATHS) -O4 -Wall -o prog A1.c A2.c A3.c A4.c $(LIBS) 
    clean :
    	rm prog
    Ought to do it.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  3. #3
    Registered User
    Join Date
    Oct 2010
    Posts
    11

    Smile Solved: Makefile problem

    Thanx brewbuck,

    What u said has worked.

    Thanks a lot. This forum is great.

    Alice

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Makefile errors
    By Akalic in forum C Programming
    Replies: 2
    Last Post: 12-07-2009, 10:30 AM
  2. Makefile help please
    By TriKri in forum C++ Programming
    Replies: 3
    Last Post: 09-24-2009, 12:36 AM
  3. Replies: 2
    Last Post: 08-11-2009, 06:45 AM
  4. Building a project using a Makefile
    By starcatcher in forum Windows Programming
    Replies: 2
    Last Post: 11-23-2008, 11:50 PM
  5. Need help with Makefile
    By xshapirox in forum C++ Programming
    Replies: 14
    Last Post: 09-28-2004, 03:32 PM