Professional Web Applications Themes

Makefile problems in OS X 10.2.8 - Mac Programming

Hi all. I am a scientific unix programmer trying to port some numerical c++ code over to my Apple lapotp. Here's my makefile, it is very straightforward. #----------------------------- # C++ compiler and flags #----------------------------- CC = g++ CFLAGS = -funroll-loops -ffast-math -O2 #----------------------------- # Linker and flags #----------------------------- LINKER = g++ LFLAGS = -funroll-loops -ffast-math -O2 -I/usr/lib/ -I. #----------------------------- # Libraries #----------------------------- LIBS = -lm -lstdc++ #----------------------------- # Header and include files #----------------------------- HEADERS = Heterogeneous.h HydrogenBonding.h Frequencies.h Dynamics.h Plot2D.h Statics.h ABCVector.h Vector.h Order.h BaseVector.h Filehandles.h Tetrahedron.h Conversions.h Functions.h Water.h Diffusion.h Complex.h Plot.h RDF.h Observables.h Lookup.h Correlation.h Histogram.h Hbonding.h Plot3D.h ...

  1. #1

    Default Makefile problems in OS X 10.2.8

    Hi all. I am a scientific unix programmer trying to port some
    numerical c++ code over to my Apple lapotp. Here's my makefile, it is
    very straightforward.


    #-----------------------------
    # C++ compiler and flags
    #-----------------------------
    CC = g++
    CFLAGS = -funroll-loops -ffast-math -O2
    #-----------------------------
    # Linker and flags
    #-----------------------------
    LINKER = g++
    LFLAGS = -funroll-loops -ffast-math -O2 -I/usr/lib/ -I.

    #-----------------------------
    # Libraries
    #-----------------------------
    LIBS = -lm -lstdc++
    #-----------------------------
    # Header and include files
    #-----------------------------
    HEADERS = Heterogeneous.h HydrogenBonding.h Frequencies.h Dynamics.h
    Plot2D.h Statics.h ABCVector.h Vector.h Order.h BaseVector.h
    Filehandles.h Tetrahedron.h Conversions.h Functions.h Water.h
    Diffusion.h Complex.h Plot.h RDF.h Observables.h Lookup.h
    Correlation.h Histogram.h Hbonding.h Plot3D.h Hist3d.h Perturbation.h
    HOD.h Distributions.h CrossCorr.h Matrix.h Raman.h nr.h nrutil.h
    nrtypes.h

    #------------------------------------------
    # object files derived from C++ source
    #------------------------------------------
    C_OBJS = Heterogeneous.o HydrogenBonding.o Frequencies.o Dynamics.o
    Statics.o Order.o main.o BaseVector.o Filehandles.o Tetrahedron.o
    Conversions.o Functions.o Water.o Diffusion.o Complex.o Plot.o RDF.o
    Observables.o Lookup.o Correlation.o Histogram.o Hbonding.o Plot3D.o
    Hist3d.o Perturbation.o HOD.o Distributions.o CrossCorr.o Raman.o
    ran1.o gasdev.o indexx.o
    #================================================= =
    # TARGETS
    #================================================= =
    md.out : $(C_OBJS)
    $(LINKER) $(LFLAGS) $(C_OBJS) $(LIBS) -o md.out

    clean :
    rm -f md.out $(C_OBJS) 2>/dev/null

    #---------------------------------
    # Rules
    #---------------------------------
    %.o:%.cc $(HEADERS)
    $(CC) -c $(CFLAGS) $<


    When I run make, the actual execution does not call the CFLAGS, which
    is problematic. I have not been able to solve this. Also, when it
    compiles, I get a laundry list of errors that generate even from the
    standard c++ libary, the most prolific of them being "Template with C
    linkage" errors -- whatever that's supposed to mean. Specs for the
    compiler are below:

    $~ g++ -v
    Reading specs from /usr/libexec/gcc/darwin/ppc/3.1/specs
    Thread model: posix
    Apple Computer, Inc. GCC version 1175, based on gcc version 3.1
    20020420 (prerelease)


    Any help would be greatly appreciated!

    Joel
    Jack Guest

  2. #2

    Default Re: Makefile problems in OS X 10.2.8

    In article <google.com>,
    com (Jack Mackrel) wrote:
     

    Do you mean that it doesn't use your CFLAGS variable, that no files
    compile, or something else altogether?
     

    You're using an old version of Apple's developer tools. I'd suggest
    heading over to <http://connect.apple.com/> and downloading the
    December 2002 developer tools, plus the August 2003 gcc update.

    Hope this helps,
    Eric

    --
    Eric Albert edu
    http://rescomp.stanford.edu/~ejalbert/
    Eric Guest

  3. #3

    Default Re: Makefile problems in OS X 10.2.8

    Thanks for the tip, I guess I should've tried this first. I meant
    that it doesn't use my CFLAGS variable.

    Joel

    Eric Albert <edu> wrote in message news:<stanford.edu>... 
    >
    > Do you mean that it doesn't use your CFLAGS variable, that no files
    > compile, or something else altogether?

    >
    > You're using an old version of Apple's developer tools. I'd suggest
    > heading over to <http://connect.apple.com/> and downloading the
    > December 2002 developer tools, plus the August 2003 gcc update.
    >
    > Hope this helps,
    > Eric[/ref]
    Jack Guest

  4. #4

    Default Re: Makefile problems in OS X 10.2.8

    On 18 Dec 2003 18:53:39 -0800, Jack Mackrel wrote: 

     
     
     
     
     

     

    I don't see offhand why it wouldn't be using your CFLAGS, but your
    Makefile is confusing to read, because you have written it as if your are
    building a C project instead of a C++ project. Make has its own built-in
    rules about how to build C programs, and although it looks like you have
    replaced the obvious candidates with the corresponding C++ rules, it's
    possible that you missed something and make is applying a "C" rule
    inappropriately. Perhaps that is causing the "C linkage" problem
    somehow.

    The normal convention in a GNU Makefile is to use CXX for the name of the
    C++ compiler (the default is g++), and CXXFLAGS for the C++ compiler
    flags. The macros CC and CFLAGS normally refer to the C compiler, not
    C++. You might want to try a "make -n" and take note of the actual
    commands that are being generated by make, to see that they actually make
    sense for a C++ program. If you use CXX and CXXFLAGS, you will have
    make's default rules working with you instead of against you.

    You could shorten your "%.o:%.cc $(HEADERS)" rule to just a dependency
    "$(C_OBJS): $(HEADERS)" and let make use the default rule for compiling.
    You also shouldn't need to specify -lstdc++, since that is automatic as
    long as you are using g++.


    --
    Dave Seaman
    Judge Yohn's mistakes revealed in Mumia Abu-Jamal ruling.
    <http://www.commoncouragepress.com/index.cfm?action=book&bookid=228>
    Dave Guest

  5. #5

    Default Re: Makefile problems in OS X 10.2.8

    Hmmm...

    I'm also getting the same error in the latest version of gcc (3.3) and
    the developer tools... Fresh out of ideas.

    Joel
    Jack Guest

  6. #6

    Default Re: Makefile problems in OS X 10.2.8

    On 19 Dec 2003 07:36:51 -0800, Jack Mackrel wrote: 
     

    It works fine with gcc 3.3 and OS X 10.3.1.


    --
    Dave Seaman
    Judge Yohn's mistakes revealed in Mumia Abu-Jamal ruling.
    <http://www.commoncouragepress.com/index.cfm?action=book&bookid=228>
    Dave Guest

  7. #7

    Default Re: Makefile problems in OS X 10.2.8

    In article <google.com>,
    com (Jack Mackrel) wrote:
     

    OK...is it using your .cc->.o rule at all? Try adding an 'echo "In
    here"' line to that rule. If the line doesn't get printed for each .cc
    file, you'll have to figure out why the rule isn't being invoked.

    -Eric

    --
    Eric Albert edu
    http://rescomp.stanford.edu/~ejalbert/
    Eric Guest

  8. #8

    Default Re: Makefile problems in OS X 10.2.8

    That was great advice, and did the trick. You're right, I took a
    makefile that was written for a C program and naively ported it over
    to c++. All that needed to be changed was CC-> CXX and corresponding
    change to the CFLAGS variable.

    Thanks!

    Joel
     
    Jack Guest

Similar Threads

  1. Simplest Makefile.PL
    By Inventor in forum PERL Modules
    Replies: 3
    Last Post: July 27th, 10:30 PM
  2. Makefile in Unix
    By Mathieu in forum UNIX Programming
    Replies: 4
    Last Post: October 26th, 02:44 AM
  3. Makefile problem
    By Capoe in forum UNIX Programming
    Replies: 2
    Last Post: October 19th, 07:40 PM
  4. perl makefile.pl --help
    By King in forum PERL Miscellaneous
    Replies: 8
    Last Post: September 30th, 01:47 AM
  5. Makefile for 5.6 when 5.004 is default
    By Pete Butler in forum PERL Miscellaneous
    Replies: 2
    Last Post: July 18th, 06:17 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139