开发者

Using a dynamic library (DevIL/OpenIL) in a Xcode project

开发者 https://www.devze.com 2023-01-22 00:50 出处:网络
i am trying to compile example source code which is using the OpenGL, SDL and IL aka DevIL aka OpenIL libraries. OpenGL and SDL are available as native frameworks, but DevIL isn\'t. So here is what i

i am trying to compile example source code which is using the OpenGL, SDL and IL aka DevIL aka OpenIL libraries. OpenGL and SDL are available as native frameworks, but DevIL isn't. So here is what i did:

I installed DevIL via homebrew. First i changed the Formula, because i need ILUT:

brew edit devil

then edited these lines

def install
  system "./configure开发者_C百科", "--disable-debug", "--disable-dependency-tracking",
                        "--prefix=#{prefix}", "--enable-ILU"
  system "make install"
end

like so

def install
  system "./configure", "--disable-debug", "--disable-dependency-tracking",
                        "--prefix=#{prefix}", "--enable-ILU", "--enable-ILUT"
  system "make install"
end

and installed everything with

[sudo] brew install devil

which gives me the DevIL headers in /usr/local/include/ and the dynamic libraries in /usr/local/lib/. Next, i added the libraries to my project with the following steps:

  • Right-click on my only Target
  • Click "Add > Existing Frameworks"
  • Select "Dylibs"
  • Add libIL.dylib, libILU.dylib and libILUT.dylib

(there are also libIL.1.dylib, libILU.1.dylib and libILUT.1.dylib available in the list, is that normal?)

Then i added the following flags in "Project > Edit Project Settings > Build > Other Linker Flags":

-lil -lilu -lilut

When i try to compile and link the project i get the following errors:

Ld "build/Debug/XCode OpenGL OOP Framework.app/Contents/MacOS/XCode OpenGL OOP Framework" normal i386
cd "/Users/padde/Documents/Studium/sem5/computergrafik/opengl intro/xcode projects/XCode OpenGL OOP Framework"
/Developer/usr/bin/g++-4.2 -arch i386 "-L/Users/padde/Documents/Studium/sem5/computergrafik/opengl intro/xcode projects/XCode OpenGL OOP Framework/build/Debug" "-F/Users/padde/Documents/Studium/sem5/computergrafik/opengl intro/xcode projects/XCode OpenGL OOP Framework/build/Debug" -filelist "/Users/padde/Documents/Studium/sem5/computergrafik/opengl intro/xcode projects/XCode OpenGL OOP Framework/build/XCode OpenGL OOP Framework.build/Debug/XCode OpenGL OOP Framework.build/Objects-normal/i386/XCode OpenGL OOP Framework.LinkFileList" -framework Foundation -framework AppKit -framework GLUT -framework OpenGL -framework SDL -lIL -lILU -lILUT -o "/Users/padde/Documents/Studium/sem5/computergrafik/opengl intro/xcode projects/XCode OpenGL OOP Framework/build/Debug/XCode OpenGL OOP Framework.app/Contents/MacOS/XCode OpenGL OOP Framework"

ld: warning: in /usr/local/lib/libIL.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
ld: warning: in /usr/local/lib/libILU.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
ld: warning: in /usr/local/lib/libILUT.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
Undefined symbols:
  "_ilInit", referenced from:
      RenderEngine::initManagers()       in RenderEngine.o
  "_ilGetData", referenced from:
      TextureManager::loadTexture(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, unsigned int, unsigned int, unsigned int, bool, bool)in TextureManager.o
  "_ilBindImage", referenced from:
      TextureManager::loadTexture(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, unsigned int, unsigned int, unsigned int, bool, bool)in TextureManager.o
  "_ilLoadImage", referenced from:
      TextureManager::loadTexture(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, unsigned int, unsigned int, unsigned int, bool, bool)in TextureManager.o
  "_ilGenImages", referenced from:
      TextureManager::loadTexture(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, unsigned int, unsigned int, unsigned int, bool, bool)in TextureManager.o
  "_ilGetInteger", referenced from:
      TextureManager::loadTexture(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, unsigned int, unsigned int, unsigned int, bool, bool)in TextureManager.o
      TextureManager::loadTexture(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, unsigned int, unsigned int, unsigned int, bool, bool)in TextureManager.o
      TextureManager::loadTexture(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, unsigned int, unsigned int, unsigned int, bool, bool)in TextureManager.o
      TextureManager::loadTexture(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, unsigned int, unsigned int, unsigned int, bool, bool)in TextureManager.o
  "_ilDeleteImages", referenced from:
      TextureManager::loadTexture(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, unsigned int, unsigned int, unsigned int, bool, bool)in TextureManager.o
      TextureManager::loadTexture(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, unsigned int, unsigned int, unsigned int, bool, bool)in TextureManager.o
      TextureManager::loadTexture(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, unsigned int, unsigned int, unsigned int, bool, bool)in TextureManager.o
  "_main", referenced from:
      start in crt1.10.6.o
     (maybe you meant: _SDL_main)
ld: symbol(s) not found
collect2: ld returned 1 exit status

apparently, the .dylib files aren't being built correctly and as a result the symbols are not being found, but how can i make this work? Did i make any mistakes? Is there a way to build the libraries differently so they work with my Project, or can i change the build architecture of my project somehow?

Thank you so much for your help!


I solved the problem by editing the brew formula to:

def install
  system "./configure", "--disable-debug", "--disable-dependency-tracking",
                        "--prefix=#{prefix}", "--enable-ILU", "--enable-ILUT",
                        "CFLAGS=-arch i386", "CXXFLAGS=-arch i386"
  system "make install"
end
0

精彩评论

暂无评论...
验证码 换一张
取 消