我正在尝试编译使用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/
中的动态库。接下来,我使用以下步骤将库添加到我的项目中:
libIL.dylib
,libILU.dylib
和libILUT.dylib
(列表中还有libIL.1.dylib
,libILU.1.dylib
和libILUT.1.dylib
,这是正常的吗?)
然后我在“Project> Edit Project Settings> Build> Other Linker Flags”中添加了以下标志:
-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
文件没有正确构建,因此找不到符号,但我怎样才能使这个工作?我犯了什么错误吗?有没有办法以不同的方式构建库,以便它们可以与我的项目一起使用,或者我可以以某种方式更改项目的构建体系结构?
非常感谢你的帮助!
答案 0 :(得分: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