在 Xcode 项目中使用动态库 (DevIL/OpenIL)

发布于 2024-09-29 22:11:54 字数 5508 浏览 5 评论 0原文

我正在尝试编译使用 OpenGL、SDL 和 IL(又名 DevIL,又名 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

内容,这为我提供了 /usr/local/include/ 中的 DevIL 标头和 中的动态库/usr/local/lib/。接下来,我通过以下步骤将库添加到我的项目中:

  • 右键单击我唯一的目标
  • 单击“添加>现有框架”
  • 选择“Dylibs”
  • 添加libIL.dyliblibILU。 dyliblibILUT.dylib

(还有 libIL.1.dyliblibILU.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 文件未正确构建,因此未找到符号,但我该如何使其工作?我犯了什么错误吗?有没有办法以不同的方式构建库,以便它们与我的项目一起使用,或者我可以以某种方式更改我的项目的构建架构吗?

非常感谢您的帮助!

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", "--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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

何其悲哀 2024-10-06 22:11:54

我通过将酿造公式编辑为以下内容解决了该问题:

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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文