我已经修改了FreeImage 3.16.0附带的Makefile.osx文件,使用Clang进行编译,并使用最新的10.8 Mac OS X SDK,它已经摆脱了大部分问题,但我和#39 ; m完全停留在一小部分链接器错误上,我无法找到任何信息。
我根据stackoverflow上其他帖子的建议修改了makefile: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 $@ $(MODULES_I386)
$(STATICLIB)-x86_64: $(MODULES_X86_64)
$(LIBTOOL) -arch_only x86_64 -o $@ $(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 $@ $(MODULES_I386)
$(SHAREDLIB)-x86_64: $(MODULES_X86_64)
$(CPP_X86_64) -arch x86_64 -dynamiclib $(LIBRARIES_X86_64) -o $@ $(MODULES_X86_64)
.c.o-i386:
$(CC_I386) $(CFLAGS_I386) -c $< -o $@
.c.o-x86_64:
$(CC_X86_64) $(CFLAGS_X86_64) -c $< -o $@
.cpp.o-i386:
$(CPP_I386) $(CPPFLAGS_I386) -c $< -o $@
.cpp.o-x86_64:
$(CPP_X86_64) $(CPPFLAGS_X86_64) -c $< -o $@
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配置似乎连接得很好。
答案 0 :(得分:3)
如果您不需要LibJXR性能计时器,则可以禁用它们。在makefile中更改此行:
COMPILERFLAGS = -Os -fexceptions -fvisibility=hidden -DNO_LCMS -D__ANSI__
为:
COMPILERFLAGS = -Os -fexceptions -fvisibility=hidden -DNO_LCMS -D__ANSI__ -DDISABLE_PERF_MEASUREMENT
答案 1 :(得分:3)
我还可以通过将文件“Source / LibJXR / image / sys / perfTimerANSI.c”添加到Makefile.srcs的SRCS部分来克服这些错误。这是实现了列为缺失的符号的文件。