2014-04-07 82 views
1

我修改了FreeImage 3.16.0隨附的Makefile.osx文件,使用Clang進行編譯並使用最新的10.8 Mac OS X SDK,它已經擺脫了大部分的問題,但是我完全停留在一些我無法找到任何信息的鏈接器錯誤上。在Mac OS X上使用make和Clang連接FreeImage 3.16.0的問題10.8

我改性過的計算器上這個其他職位的建議生成文件:How to compile FreeImage on Mac OS X 10.8?

而這正是它目前的樣子:

# -*- Makefile -*- 
# Mac OSX makefile for FreeImage 

# This file can be generated by ./gensrclist.sh 
include Makefile.srcs 

# General configuration variables: 
CC_I386 = Clang 
CC_X86_64 = Clang 
CPP_I386 = Clang++ 
CPP_X86_64 = Clang++ 
COMPILERFLAGS = -Os -fexceptions -fvisibility=hidden -DNO_LCMS -D__ANSI__ 
COMPILERFLAGS_I386 = -arch i386 
COMPILERFLAGS_X86_64 = -arch x86_64 
COMPILERPPFLAGS = -Wno-ctor-dtor-privacy -D__ANSI__ -stdlib=libc++ 
INCLUDE += 
INCLUDE_I386 = -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk 
INCLUDE_X86_64 = -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk 
CFLAGS_I386 = $(COMPILERFLAGS) $(COMPILERFLAGS_I386) $(INCLUDE) $(INCLUDE_I386) 
CFLAGS_X86_64 = $(COMPILERFLAGS) $(COMPILERFLAGS_X86_64) $(INCLUDE) $(INCLUDE_X86_64) 
CPPFLAGS_I386 = $(COMPILERPPFLAGS) $(CFLAGS_I386) 
CPPFLAGS_X86_64 = $(COMPILERPPFLAGS) $(CFLAGS_X86_64) 
LIBRARIES_I386 = -Wl,-syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk 
LIBRARIES_X86_64 = -Wl,-syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk 
LIBTOOL = libtool 
LIPO = lipo 

TARGET = freeimage 
STATICLIB = lib$(TARGET).a 
SHAREDLIB = lib$(TARGET)-$(VER_MAJOR).$(VER_MINOR).dylib 
LIBNAME = lib$(TARGET).$(VER_MAJOR).dylib 
HEADER = Source/FreeImage.h 

.SUFFIXES: .o-i386 .o-x86_64 
MODULES_I386 = $(SRCS:.c=.o-i386) 
MODULES_X86_64 = $(SRCS:.c=.o-x86_64) 
MODULES_I386 := $(MODULES_I386:.cpp=.o-i386) 
MODULES_X86_64 := $(MODULES_X86_64:.cpp=.o-x86_64) 

PREFIX = /usr/local 
INSTALLDIR = $(PREFIX)/lib 
INCDIR = $(PREFIX)/include 

default: all 

all: dist 

dist: FreeImage 
    cp *.a Dist 
    cp *.dylib Dist 
    cp Source/FreeImage.h Dist 

FreeImage: $(STATICLIB) $(SHAREDLIB) 

$(STATICLIB): $(STATICLIB)-i386 $(STATICLIB)-x86_64 
    $(LIPO) -create $(STATICLIB)-i386 $(STATICLIB)-x86_64 -output $(STATICLIB) 

$(STATICLIB)-i386: $(MODULES_I386) 
    $(LIBTOOL) -arch_only i386 -o [email protected] $(MODULES_I386) 

$(STATICLIB)-x86_64: $(MODULES_X86_64) 
    $(LIBTOOL) -arch_only x86_64 -o [email protected] $(MODULES_X86_64) 

$(SHAREDLIB): $(SHAREDLIB)-i386 $(SHAREDLIB)-x86_64 
    $(LIPO) -create $(SHAREDLIB)-i386 $(SHAREDLIB)-x86_64 -output $(SHAREDLIB) 

$(SHAREDLIB)-i386: $(MODULES_I386) 
    $(CPP_I386) -arch i386 -dynamiclib $(LIBRARIES_I386) -o [email protected] $(MODULES_I386) 

$(SHAREDLIB)-x86_64: $(MODULES_X86_64) 
    $(CPP_X86_64) -arch x86_64 -dynamiclib $(LIBRARIES_X86_64) -o [email protected] $(MODULES_X86_64) 

.c.o-i386: 
    $(CC_I386) $(CFLAGS_I386) -c $< -o [email protected] 

.c.o-x86_64: 
    $(CC_X86_64) $(CFLAGS_X86_64) -c $< -o [email protected] 

.cpp.o-i386: 
    $(CPP_I386) $(CPPFLAGS_I386) -c $< -o [email protected] 

.cpp.o-x86_64: 
    $(CPP_X86_64) $(CPPFLAGS_X86_64) -c $< -o [email protected] 

install: 
    install -d -m 755 -o root -g wheel $(INCDIR) $(INSTALLDIR) 
    install -m 644 -o root -g wheel $(HEADER) $(INCDIR) 
    install -m 644 -o root -g wheel $(SHAREDLIB) $(STATICLIB) $(INSTALLDIR) 
    ranlib -sf $(INSTALLDIR)/$(STATICLIB) 
    ln -sf $(SHAREDLIB) $(INSTALLDIR)/$(LIBNAME) 

clean: 
    rm -f core Dist/*.* u2dtmp* $(MODULES_I386) $(MODULES_X86_64) $(STATICLIB) $(STATICLIB)-i386 $(SHAREDLIB) $(SHAREDLIB)-i386 $(SHAREDLIB)-x86_64 

我得到的鏈接錯誤是什麼在LibJXR據我可以告訴:

Undefined symbols for architecture i386: 
    "_PerfTimerCopyStartTime", referenced from: 
     _ImageStrDecInit in strdec.o-i386 
     _ImageStrEncInit in strenc.o-i386 
    "_PerfTimerDelete", referenced from: 
     _ImageStrDecTerm in strdec.o-i386 
     _ImageStrEncTerm in strenc.o-i386 
    "_PerfTimerGetResults", referenced from: 
     _OutputIndivPerfTimer in strcodec.o-i386 
    "_PerfTimerNew", referenced from: 
     _ImageStrDecInit in strdec.o-i386 
     _ImageStrEncInit in strenc.o-i386 
    "_PerfTimerStart", referenced from: 
     _ImageStrDecInit in strdec.o-i386 
     _ImageStrDecDecode in strdec.o-i386 
     _ImageStrDecTerm in strdec.o-i386 
     _ImageStrEncInit in strenc.o-i386 
     _ImageStrEncEncode in strenc.o-i386 
     _ImageStrEncTerm in strenc.o-i386 
     _readIS in strcodec.o-i386 
     ... 
    "_PerfTimerStop", referenced from: 
     _ImageStrDecInit in strdec.o-i386 
     _ImageStrDecDecode in strdec.o-i386 
     _ImageStrDecTerm in strdec.o-i386 
     _ImageStrEncInit in strenc.o-i386 
     _ImageStrEncEncode in strenc.o-i386 
     _ImageStrEncTerm in strenc.o-i386 
     _readIS in strcodec.o-i386 

我真的不知道該怎麼來嘗試解決這個問題,特別是因爲它只是發生對於i386配置,x86_64配置似乎很好。

回答

3

如果您不需要LibJXR性能計時器,您可以禁用它們。在你的makefile改變這一行:

COMPILERFLAGS = -Os -fexceptions -fvisibility=hidden -DNO_LCMS -D__ANSI__ 

到:

COMPILERFLAGS = -Os -fexceptions -fvisibility=hidden -DNO_LCMS -D__ANSI__ -DDISABLE_PERF_MEASUREMENT 
2

我也可以通過添加文件 「源/ LibJXR /圖像/ SYS/perfTimerANSI.c」 在克服這些錯誤Makefile.srcs的SRCS部分。這是列出的丟失符號被執行的文件。