Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ajm113

macrumors newbie
Original poster
Jan 16, 2011
13
0
Hello everyone I'm new to Macs and my girlfriend got me hooked on using my Macbook and I'm converting a wxWidgets project to wxMac application and everything is going smoothly except I'm my project is using FreeImage library and I'm getting this error when I start my software.

Code:
dyld: Library not loaded: Libfreeimage-3.14.1.dylib-i386
    Referenced from: (Path to project)/build/Debug/(Project Name)
  Reason: image not found

I edited the path so it was shorter and understandable and this appears before anything in my software even does anything.

I'm very new to using xCode with C++ and I don't know why this error appears if my application compiles with no errors. Is this error the same just like how Windows would complain about not finding a .dll? But in this case it's just not finding a framework file? How do I fix it? What file am I forgetting?

I would appreciate any help since I want to have my Mac as my main development platform for cross development when I'm away from the house.
 
Last edited:
My guess is that you are compiled your application as a 32 bit executable and the library 64 bit. You can check that by using the file command in the terminal for the library and check the build settings in Xcode.
To build the wxMac as universal binary, read this.
Edit: I didn't build wxMac and I don't have it insalled, so this is just a guess.
 
My guess is that you are compiled your application as a 32 bit executable and the library 64 bit. You can check that by using the file command in the terminal for the library and check the build settings in Xcode.
To build the wxMac as universal binary, read this.
Edit: I didn't build wxMac and I don't have it insalled, so this is just a guess.

Thanks for the reply, but I built that library called "freeimage" under the make function and I read through the instructions and it didn't mention anything about setting up freeimage as a 32bit or 64bit, but the project that the library is using is already set for 32bit and it's set for "my current Mac", but I'll snoop around with FreeImage and that link more to see if those solve my problem.
 
I fixed the issue, sorta.... All I did was rename the freeimage dylib to ".dylib-i386" and it worked! But... When I tried running the software in the Debug folder or Release folder I get the same all over again and the path to the framework freeimage file is all messed up to the freeimage framework.

Example How it loads the framework when I run my software from xcode:
Code:
/Users/andrewmcrobb/Documents/Digital Symbol Studio (wxMac)/build/Debug/libfreeimage-3.14.1.dylib-i386

Runtime Error I get if I run the program directly:
Code:
Last login: Tue Jan 18 17:30:13 on ttys001
/Users/andrewmcrobb/Documents/Digital\ Symbol\ Studio\ \(wxMac\)/build/Debug/Digital\ Symbol\ Studio ; exit;
Andrew-McRobbs-MacBook:~ andrewmcrobb$ /Users/andrewmcrobb/Documents/Digital\ Symbol\ Studio\ \(wxMac\)/build/Debug/Digital\ Symbol\ Studio ; exit;
dyld: Library not loaded: libfreeimage-3.14.1.dylib-i386
  Referenced from: /Users/andrewmcrobb/Documents/Digital Symbol Studio (wxMac)/build/Debug/Digital Symbol Studio
  Reason: image not found
Trace/BPT trap
logout

Are you sure I don't have to set anything up with the FreeImage framework with my project or any tutorials I should read on setting up frameworks 'you' built and can this simple path error be fixed?

Thanks, Ajm
 
Last edited:
Are you sure I don't have to set anything up with the FreeImage framework with my project or any tutorials I should read on setting up frameworks 'you' built and can this simple path error be fixed?

You'll need to get the exact details from www.developer.com.

If you use a framework that isn't one of the system frameworks, then it will obviously not be on any other machine than your own, so you have to do something. The steps you need to do:

1. Add the framework to your project
2. Make sure it is added in your target settings to the "Link" build phase.
3. You need in your target settings a build phase that will copy the framework into the application bundle. Add a new "Copy files" build phase, change it to copy frameworks (Get Info + General), add the framework to that build phase.
4. I think you have to set a path where the application will be looking for frameworks; the details will be at www.developer.com.
 
I fallowed what you said and I can't get anything, believe me I tried everything from even changing the Path Type in I placed the dylib in that "copy folder" to looking around in the Build settings to look for anything and I can't find where to go and that website doesn't help at all, I tried searching around, but I cant find what I want...

(Google's Website Based Search Engine isn't the best... Would it be too hard to write their own?!? I type just "xcode" any only 2 results show and they don't help...)

May I ask why Xcode wouldn't look for the freeimage dylib I added to the project then "freeimage.dylib-(Project Active Architecture)" ? Doesn't kinda make sense if it loads other frameworks perfectly such as wxMac that I built myself, but for some odd reason it want's freeimage's dynamic link library to have the architecture included in the file extension.

I will post the instructions and make file of FreeImage if that helps.

Release Notes
--------------
This version of the library has been tested under OSX 10.3.9 PPC and OSX 10.4.8 Intel.

While the makefiles will make a .dylib and a .a, it is recommended to simply staticly link with the .a file.

FreeImage is now built as a Universal Binary and targets the 10.3.9 SDK for PPC and the 10.4u SDK for i386.
This means that you must have both of these SDKs installed and that you must be running on OSX 10.4+ to build FreeImage.
The library will run on 10.3 PPC, but probably not 10.2 or below anymore. wchar.h did not exist on 10.2.

FreeImage is now built with gcc 4.0 and will thus only run on 10.3.9 or above (some libraries may not exist on 10.3.8 and below).

The FreeImage makefile makes use of the gcc "-fvisibility=hidden" in order to avoid incompatibilities between
internal third party libraries and the OS libraries. This feature is available with gcc 4 or greater.


Ryan Rubley

Building the Library
--------------------
Makefile detects the environment by calling 'uname'. Assuming this reports 'Darwin' on your system, Makefile will automatically
defer commands to Makefile.osx. If this doesn't work, type 'make -f Makefile.osx' in place of just 'make'

The build process is as simple as this:
1) Enter the FreeImage directory
2) Build the distribution:
make
3) The libraries and header will be in the Dist directory when the build is finished

To install FreeImage in the /usr/local/lib and /usr/local/include directories (not recommended):
make install

To clean all files produced during the build process:
make clean


Additional notes
----------------

Building on Mac OS X Leopard :

Install the xcode dev tools from the Leopard disk.
When installing the dev tools make sure to have installed 10.3.9 SDK (it's not selected by default).

The make file for FreeImage I used to build it with:
Code:
# -*- Makefile -*-
# Mac OSX makefile for FreeImage

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

# General configuration variables:
CC_PPC = gcc-4.0
CC_I386 = gcc-4.0
CC_X86_64 = gcc-4.0
CPP_PPC = g++-4.0
CPP_I386 = g++-4.0
CPP_X86_64 = g++-4.0
COMPILERFLAGS = -Os -fexceptions -fvisibility=hidden -DNO_LCMS
COMPILERFLAGS_PPC = -arch ppc
COMPILERFLAGS_I386 = -arch i386
COMPILERFLAGS_X86_64 = -arch x86_64
COMPILERPPFLAGS = -Wno-ctor-dtor-privacy
INCLUDE += 
INCLUDE_PPC = -isysroot /Developer/SDKs/MacOSX10.5.sdk
INCLUDE_I386 = -isysroot /Developer/SDKs/MacOSX10.5.sdk
INCLUDE_X86_64 = -isysroot /Developer/SDKs/MacOSX10.6.sdk
CFLAGS_PPC = $(COMPILERFLAGS) $(COMPILERFLAGS_PPC) $(INCLUDE) $(INCLUDE_PPC)
CFLAGS_I386 = $(COMPILERFLAGS) $(COMPILERFLAGS_I386) $(INCLUDE) $(INCLUDE_I386)
CFLAGS_X86_64 = $(COMPILERFLAGS) $(COMPILERFLAGS_X86_64) $(INCLUDE) $(INCLUDE_X86_64)
CPPFLAGS_PPC = $(COMPILERPPFLAGS) $(CFLAGS_PPC)
CPPFLAGS_I386 = $(COMPILERPPFLAGS) $(CFLAGS_I386)
CPPFLAGS_X86_64 = $(COMPILERPPFLAGS) $(CFLAGS_X86_64)
LIBRARIES_PPC = -Wl,-syslibroot /Developer/SDKs/MacOSX10.5.sdk
LIBRARIES_I386 = -Wl,-syslibroot /Developer/SDKs/MacOSX10.5.sdk
LIBRARIES_X86_64 = -Wl,-syslibroot /Developer/SDKs/MacOSX10.6.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-ppc .o-i386 .o-x86_64
MODULES_PPC = $(SRCS:.c=.o-ppc)
MODULES_I386 = $(SRCS:.c=.o-i386)
MODULES_X86_64 = $(SRCS:.c=.o-x86_64)
MODULES_PPC := $(MODULES_PPC:.cpp=.o-ppc)
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)-ppc $(STATICLIB)-i386 $(STATICLIB)-x86_64
	$(LIPO) -create $(STATICLIB)-ppc $(STATICLIB)-i386 $(STATICLIB)-x86_64 -output $(STATICLIB)

$(STATICLIB)-ppc: $(MODULES_PPC)
	$(LIBTOOL) -arch_only ppc -o $@ $(MODULES_PPC)

$(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)-ppc $(SHAREDLIB)-i386 $(SHAREDLIB)-x86_64
	$(LIPO) -create $(SHAREDLIB)-ppc $(SHAREDLIB)-i386 $(SHAREDLIB)-x86_64 -output $(SHAREDLIB)

$(SHAREDLIB)-ppc: $(MODULES_PPC)
	$(CPP_PPC) -arch ppc -dynamiclib $(LIBRARIES_PPC) -o $@ $(MODULES_PPC)

$(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-ppc:
	$(CC_PPC) $(CFLAGS_PPC) -c $< -o $@

.c.o-i386:
	$(CC_I386) $(CFLAGS_I386) -c $< -o $@

.c.o-x86_64:
	$(CC_X86_64) $(CFLAGS_X86_64) -c $< -o $@

.cpp.o-ppc:
	$(CPP_PPC) $(CPPFLAGS_PPC) -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_PPC) $(MODULES_I386) $(MODULES_X86_64) $(STATICLIB) $(STATICLIB)-ppc $(STATICLIB)-i386 $(SHAREDLIB) $(SHAREDLIB)-ppc $(SHAREDLIB)-i386 $(SHAREDLIB)-x86_64
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.