Trying to build the LEVMAR math library on a mac using the Accelerate Framework

后端 未结 2 1274
面向向阳花
面向向阳花 2021-01-15 22:29

I want build levmar-2.5 math library on a mac using the included Makefile. It requires LAPACK,
another math library which is included in the Accelerate Framework. I do

相关标签:
2条回答
  • 2021-01-15 22:44

    For reference, here's the makefile that will work:

    #
    # Unix/Linux GCC Makefile for Levenberg - Marquardt minimization
    # Under windows, use Makefile.vc for MSVC
    #
    
    CC=gcc
    CONFIGFLAGS=#-ULINSOLVERS_RETAIN_MEMORY
    #ARCHFLAGS=-march=pentium4 # YOU MIGHT WANT TO UNCOMMENT THIS FOR P4
    CFLAGS=$(CONFIGFLAGS) $(ARCHFLAGS) -O3 -funroll-loops -Wall #-ffast-math #-pg
    #LAPACKLIBS_PATH=/usr/local/lib # WHEN USING LAPACK, CHANGE THIS TO WHERE YOUR COMPILED LIBS ARE!
    LDFLAGS=-L. # for non-OSX, add: -L$(LAPACKLIBS)
    LIBOBJS=lm.o Axb.o misc.o lmlec.o lmbc.o lmblec.o lmbleic.o
    LIBSRCS=lm.c Axb.c misc.c lmlec.c lmbc.c lmblec.c lmbleic.c
    DEMOBJS=lmdemo.o
    DEMOSRCS=lmdemo.c
    AR=ar
    RANLIB=ranlib
    
    LAPACKLIBS=-framework Accelerate #This works for OSX where the SDK is installed.
    
    LIBS=$(LAPACKLIBS)
    
    all: liblevmar.a lmdemo
    
    liblevmar.a: $(LIBOBJS)
        $(AR) crv liblevmar.a $(LIBOBJS)
        $(RANLIB) liblevmar.a
    
    lmdemo: $(DEMOBJS) liblevmar.a
        $(CC) $(LDFLAGS) $(DEMOBJS) -o lmdemo -llevmar $(LIBS) -lm
    
    lm.o: lm.c lm_core.c levmar.h misc.h compiler.h
    Axb.o: Axb.c Axb_core.c levmar.h misc.h
    misc.o: misc.c misc_core.c levmar.h misc.h
    lmlec.o: lmlec.c lmlec_core.c levmar.h misc.h
    lmbc.o: lmbc.c lmbc_core.c levmar.h misc.h compiler.h
    lmblec.o: lmblec.c lmblec_core.c levmar.h misc.h
    lmbleic.o: lmbleic.c lmbleic_core.c levmar.h misc.h
    
    lmdemo.o: levmar.h
    
    clean:
        @rm -f $(LIBOBJS) $(DEMOBJS)
    
    cleanall: clean
        @rm -f lmdemo
        @rm -f liblevmar.a
    
    depend:
        makedepend -f Makefile $(LIBSRCS) $(DEMOSRCS)
    
    # DO NOT DELETE THIS LINE -- make depend depends on it.
    
    0 讨论(0)
  • 2021-01-15 22:54

    You need to pass -framework Accelerate to gcc. You also need to#include <Accelerate/Accelerate.h>. Details are here.

    0 讨论(0)
提交回复
热议问题