C++ 如何安装 SOIL(简单 OpenGL 图像加载器)?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18886598/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I install SOIL (Simple OpenGL Image Loader)?
提问by DanielLC
The SOIL websitedoesn't have any installation instructions. The file I downloaded has no readme. I failed to find anything with Google.
在土壤网站没有任何的安装说明。我下载的文件没有自述文件。我用谷歌找不到任何东西。
I doubt g++ is going to check every directory on my computer to see if it can find it. Is there a specific folder I'm supposed to put it in? Is there a script I'm supposed to run?
我怀疑 g++ 是否会检查我计算机上的每个目录以查看它是否可以找到它。我应该把它放在一个特定的文件夹中吗?有我应该运行的脚本吗?
I'm using Ubuntu.
我正在使用 Ubuntu。
采纳答案by cpp
Navigate to the projects/makefile folder and type:
导航到 projects/makefile 文件夹并键入:
$make
$make install
Then you can use this library simply including SOIL.h in your C++ file.
然后你可以使用这个库,只需在你的 C++ 文件中包含 SOIL.h。
回答by uutsav
As suggested on Compiling OpenGL SOIL on Ubuntu,
正如在 Ubuntu上编译 OpenGL SOIL所建议的,
First download the SOIL.h header file from its website http://www.lonesock.net/soil.html
首先从其网站http://www.lonesock.net/soil.html下载 SOIL.h 头文件
Place the header file in your project directory and include it in your project file.
将头文件放在您的项目目录中,并将其包含在您的项目文件中。
#include "SOIL.h"
After that you have to install the soil library to use -lSOIL. To install the library use the command
之后,您必须安装土壤库才能使用 -lSOIL。要安装库,请使用命令
sudo apt-get install libsoil-dev
Now compile the project using gcc along with -lSOIL
现在使用 gcc 和 -lSOIL 编译项目
And in case you face the error:
如果您遇到错误:
undefined reference to 'SOIL_load_OGL_texture'
对“SOIL_load_OGL_texture”的未定义引用
then link libSOIL before linking libopengl32 while compilation,for example:
然后在编译时链接 libopengl32 之前链接 libSOIL,例如:
g++ -g source.cpp -lglu32 -lSOIL -lopengl32 -lfreeglut
回答by rluks
Question is about Ubuntu. However I was looking for how to get it working in Windows. But in the end is was not so complicated.
问题是关于 Ubuntu 的。但是我一直在寻找如何让它在 Windows 中工作。但最终并没有那么复杂。
Download the soil.zip.
下载soil.zip。
Browse to "Simple OpenGL Image Library\projects\VC9".
浏览到“Simple OpenGL Image Library\projects\VC9”。
Open the SOIL.sln. I have VS15 so I had to upgrade the solution for it. It was automatic without any issues.
打开 SOIL.sln。我有 VS15,所以我不得不为它升级解决方案。它是自动的,没有任何问题。
Then I build the solution and SOIL.lib was created.
然后我构建了解决方案并创建了 SOIL.lib。
I took this .lib file and put it in my project folder.
我把这个 .lib 文件放在我的项目文件夹中。
Added dependency in my Project - Properties/Linker/Input/Additional Dependencies
在我的项目中添加了依赖项 - 属性/链接器/输入/附加依赖项
Took SOIL.h from "Simple OpenGL Image Library\src and put it in my project folder.
从“Simple OpenGL Image Library\src”中取出 SOIL.h 并将其放入我的项目文件夹中。
Then I had to include the header file
然后我不得不包含头文件
#include "SOIL.h"
and I can use it for loading image like this:
我可以用它来加载这样的图像:
GLuint tex_2d = SOIL_load_OGL_texture
(
"pic.png",
SOIL_LOAD_AUTO,
SOIL_CREATE_NEW_ID,
SOIL_FLAG_MIPMAPS | SOIL_FLAG_COMPRESS_TO_DXT
);
if (0 == tex_2d)
{
printf("SOIL loading error: '%s'\n", SOIL_last_result());
}