1

我正在尝试编译使用 OpenGL、SDL 和 IL aka DevIL aka OpenIL 库的示例源代码。OpenGL 和 SDL 可用作本机框架,但 DevIL 不是。所以这就是我所做的:

我通过自制软件安装了 DevIL。首先我改变了公式,因为我需要 ILUT:

brew edit devil

然后编辑了这些行

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

像这样

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

并安装了所有东西

[sudo] brew install devil

这给了我 DevIL 头文件/usr/local/include//usr/local/lib/. 接下来,我通过以下步骤将库添加到我的项目中:

  • 右键单击我唯一的目标
  • 单击“添加 > 现有框架”
  • 选择“动态库”
  • 添加libIL.dylib,libILU.dyliblibILUT.dylib

(列表中还有libIL.1.dylib,libILU.1.dyliblibILUT.1.dylib可用的,这正常吗?)

然后我在“项目>编辑项目设置>构建>其他链接器标志”中添加了以下标志:

-lil -lilu -lilut

当我尝试编译和链接项目时,出现以下错误:

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

显然,.dylib文件没有正确构建,因此没有找到符号,但我怎样才能使它工作?我犯了什么错误吗?有没有办法以不同的方式构建库以便它们与我的项目一起使用,或者我可以以某种方式更改我的项目的构建架构?

非常感谢你的帮助!

4

1 回答 1

1

我通过将 brew 公式编辑为:

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
于 2010-10-27T14:31:18.200 回答