2010-03-29 23 views
1

Je veux construire une bibliothèque mathématique levmar-2.5 sur un mac en utilisant le Makefile inclus. Il nécessite LAPACK,
une autre bibliothèque mathématique qui est incluse dans l'Accelerate Framework. Je ne sais pas comment modifier
le Makefile pour indiquer l'emplacement de la bibliothèque afin qu'il se construit correctement. Il y a un
libLAPACK.dylib dans le framework. En fin de compte, je vais vouloir utiliser cette bibliothèque pour construire une autre bibliothèque. Aussi je ne suis pas sûr s'il y aura un problème de mélange des bibliothèques dynamiques .so et .dylib.
Merci. Le projet est situé au levmar.Essayer de construire la bibliothèque mathématique LEVMAR sur un mac en utilisant le framework Accelerate

Voici le Makefile:

# 
# 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$(LAPACKLIBS_PATH) -L. 
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=-llapack -lblas -lf2C# comment this line if you are not using LAPACK. 
          # On systems with a FORTRAN (not f2c'ed) version of LAPACK, -lf2c is 
          # not necessary; on others, -lf2c is equivalent to -lF77 -lI77 

#LAPACKLIBS=-L/usr/local/atlas/lib -llapack -lcblas -lf77blas -latlas -lf2C# This works with the ATLAS updated lapack and Linux_P4SSE2 
            # from http://www.netlib.org/atlas/archives/linux/ 

#LAPACKLIBS=-llapack -lgoto2 -lpthread -lf2C# This works with GotoBLAS 
             # from http://www.tacc.utexas.edu/research-development /tacc-projects/ 

#LAPACKLIBS=-L/opt/intel/mkl/8.0.1/lib/32/ -lmkl_lapack -lmkl_ia32 -lguide -lf2C# This works with MKL 8.0.1 from 
        # http://www.intel.com/cd/software/products/asmo-na/eng/perflib/mkl/index.htm 

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. 

Répondre

4

Vous devez passer à gcc -framework Accelerate. Vous devez également #include <Accelerate/Accelerate.h>. Les détails sont here.

+1

Merci Paul. J'ai été capable de construire la bibliothèque ainsi que la bibliothèque qui dépend de levmar. –

1

Pour référence, voici le makefile qui fonctionnera:

# 
# 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

Merci Jonas. Cela fonctionne très bien sur OSX. Des indices sur la façon de le faire fonctionner sur iOS? –

+0

Avec "ARCHFLAGS = -arch armv6 -arch armv7", le processus make échoue avec "gcc-4.2: erreur essayant d'exec '/usr/bin/arm-apple-darwin10-gcc-4.2.1': execvp: No such fichier ou répertoire " –

+0

a commencé une toute nouvelle question sur le sujet: http://stackoverflow.com/questions/6074096/how-to-build-an-iphone-static-library-based-on-a-makefile –