Pergunta

I've modified the Makefile.osx file that comes with FreeImage 3.16.0 to compile using Clang and to use the latest 10.8 Mac OS X SDK, which has gotten rid of most of the problems, but I'm completely stuck on a small set of linker errors that I can't find any information on.

I modified the makefile based off of the recommendations of this other post on stackoverflow: How to compile FreeImage on Mac OS X 10.8?

And this is what it currently looks like:

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

The linker errors I'm getting are something in LibJXR as far as I can tell:

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

I really have no idea what to try to fix this, especially since it's only happening for the i386 configuration, the x86_64 configuration seems to be linking just fine.

Foi útil?

Solução

If you don't need the LibJXR performance timers, you can just disable them. Change this line in your makefile:

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

to:

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

Outras dicas

I was also able to overcome these errors by adding the file "Source/LibJXR/image/sys/perfTimerANSI.c" to the SRCS section of Makefile.srcs. That's the file where the symbols listed as missing are implemented.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top