首页 > 解决方案 > 静态链接 sfml 错误

问题描述

我一直在尝试将 sfml 静态链接到 C++ 项目,但它总是给我编译器错误,有谁知道这里发生了什么以及如何修复它;

编译器错误

编辑:

这是产生错误的代码:

在此处输入图像描述

这就是我放入 Linker/include/additional dependencies 部分的内容:

在此处输入图像描述

我希望这就是您所需要的,但如果还有其他问题,请具体说明(我是新手)

编辑2: 这是所有错误:

严重性代码 描述 项目文件行抑制状态错误 LNK2019 未解析的外部符号 _jpeg_std_error 在函数“private: bool __thiscall sf::priv::ImageLoader::writeJpg(class std::basic_string,class std::allocator > const &,class std ::vector > const &,unsigned int,unsigned int)" (?writeJpg@ImageLoader@priv@sf@@AAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@ std@@ABV?$vector@EV?$allocator@E@std@@@5@II@Z) Dungeon3.0 C:\Users\hhgra\source\repos\Dungeon3.0\Dungeon3.0\sfml-graphics -sd.lib(ImageLoader.cpp.obj) 1

严重性代码 描述 项目文件行抑制状态错误 LNK2019 无法解析的外部符号 _jpeg_CreateCompress 在函数“private: bool __thiscall sf::priv::ImageLoader::writeJpg(class std::basic_string,class std::allocator > const &,class std ::vector > const &,unsigned int,unsigned int)" (?writeJpg@ImageLoader@priv@sf@@AAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@ std@@ABV?$vector@EV?$allocator@E@std@@@5@II@Z) Dungeon3.0 C:\Users\hhgra\source\repos\Dungeon3.0\Dungeon3.0\sfml-graphics -sd.lib(ImageLoader.cpp.obj) 1

严重性代码 描述 项目文件行抑制状态错误 LNK2019 无法解析的外部符号 _jpeg_destroy_compress 在函数“private: bool __thiscall sf::priv::ImageLoader::writeJpg(class std::basic_string,class std::allocator > const &,class std ::vector > const &,unsigned int,unsigned int)" (?writeJpg@ImageLoader@priv@sf@@AAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@ std@@ABV?$vector@EV?$allocator@E@std@@@5@II@Z) Dungeon3.0 C:\Users\hhgra\source\repos\Dungeon3.0\Dungeon3.0\sfml-graphics -sd.lib(ImageLoader.cpp.obj) 1

严重性代码描述项目文件行抑制状态错误 LNK2019 未解析的外部符号 _jpeg_stdio_dest 在函数“private: bool __thiscall sf::priv::ImageLoader::writeJpg(class std::basic_string,class std::allocator > const &,class std ::vector > const &,unsigned int,unsigned int)" (?writeJpg@ImageLoader@priv@sf@@AAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@ std@@ABV?$vector@EV?$allocator@E@std@@@5@II@Z) Dungeon3.0 C:\Users\hhgra\source\repos\Dungeon3.0\Dungeon3.0\sfml-graphics -sd.lib(ImageLoader.cpp.obj) 1

严重性代码 描述 项目文件行抑制状态错误 LNK2019 未解析的外部符号 _jpeg_set_defaults 在函数“private: bool __thiscall sf::priv::ImageLoader::writeJpg(class std::basic_string,class std::allocator > const &,class std ::vector > const &,unsigned int,unsigned int)" (?writeJpg@ImageLoader@priv@sf@@AAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@ std@@ABV?$vector@EV?$allocator@E@std@@@5@II@Z) Dungeon3.0 C:\Users\hhgra\source\repos\Dungeon3.0\Dungeon3.0\sfml-graphics -sd.lib(ImageLoader.cpp.obj) 1

严重性代码描述项目文件行抑制状态错误 LNK2019 未解析的外部符号 _jpeg_set_quality 在函数“private: bool __thiscall sf::priv::ImageLoader::writeJpg(class std::basic_string,class std::allocator > const &,class std ::vector > const &,unsigned int,unsigned int)" (?writeJpg@ImageLoader@priv@sf@@AAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@ std@@ABV?$vector@EV?$allocator@E@std@@@5@II@Z) Dungeon3.0 C:\Users\hhgra\source\repos\Dungeon3.0\Dungeon3.0\sfml-graphics -sd.lib(ImageLoader.cpp.obj) 1

严重性代码 描述 项目文件行抑制状态错误 LNK2019 未解析的外部符号 _jpeg_start_compress 在函数“private: bool __thiscall sf::priv::ImageLoader::writeJpg(class std::basic_string,class std::allocator > const &,class std ::vector > const &,unsigned int,unsigned int)" (?writeJpg@ImageLoader@priv@sf@@AAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@ std@@ABV?$vector@EV?$allocator@E@std@@@5@II@Z) Dungeon3.0 C:\Users\hhgra\source\repos\Dungeon3.0\Dungeon3.0\sfml-graphics -sd.lib(ImageLoader.cpp.obj) 1

严重性代码描述项目文件行抑制状态错误 LNK2019 未解析的外部符号 _jpeg_write_scanlines 在函数“private: bool __thiscall sf::priv::ImageLoader::writeJpg(class std::basic_string,class std::allocator > const &,class std ::vector > const &,unsigned int,unsigned int)" (?writeJpg@ImageLoader@priv@sf@@AAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@ std@@ABV?$vector@EV?$allocator@E@std@@@5@II@Z) Dungeon3.0 C:\Users\hhgra\source\repos\Dungeon3.0\Dungeon3.0\sfml-graphics -sd.lib(ImageLoader.cpp.obj) 1

严重性代码 描述 项目文件行抑制状态错误 LNK2019 未解析的外部符号 _jpeg_finish_compress 在函数“private: bool __thiscall sf::priv::ImageLoader::writeJpg(class std::basic_string,class std::allocator > const &,class std ::vector > const &,unsigned int,unsigned int)" (?writeJpg@ImageLoader@priv@sf@@AAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@ std@@ABV?$vector@EV?$allocator@E@std@@@5@II@Z) Dungeon3.0 C:\Users\hhgra\source\repos\Dungeon3.0\Dungeon3.0\sfml-graphics -sd.lib(ImageLoader.cpp.obj) 1

严重性代码 描述 项目文件行抑制状态错误 LNK1120 9 unresolved externals Dungeon3.0 C:\Users\hhgra\source\repos\Dungeon3.0\Debug\Dungeon3.0.exe 1

标签: c++visual-c++sfmlstatic-linking

解决方案


似乎您正在使用仍然依赖于 libjpeg 的过时版本的 SFML,而您没有链接它(因为在较新的版本中不再需要它)。

理想情况下,从官方存储库下载最新源代码并使用 CMake 进行编译,这将为您提供兼容和最新的文件。


推荐阅读