gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 12:22:51 24 4
gpt4 key购买 nike

我正在尝试编译使用 OpenGL、SDL 和 IL aka DevIL aka OpenIL 库的示例源代码。 OpenGL 和 SDL 可用作 native 框架,但 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 header 和 /usr/local/lib/ 中的动态库。接下来,我通过以下步骤将这些库添加到我的项目中:

  • 右键单击我唯一的目标
  • 点击“添加 > 现有框架”
  • 选择“动态库”
  • 添加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 文件未正确构建,因此未找到符号,但我怎样才能使它工作?我犯了什么错误吗?有没有办法以不同的方式构建库以便它们与我的项目一起工作,或者我可以以某种方式更改我的项目的构建架构?

非常感谢您的帮助!

最佳答案

我通过将 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

关于c++ - 在 Xcode 项目中使用动态库 (DevIL/OpenIL),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4033810/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com