大家好,
我在尝试使用SFML库时遇到了一些麻烦。我尝试过不同的方法让它工作但总是失败。
/ usr / bin / ld:test:隐藏符号«__cpu_model»in /usr/lib/gcc/x86_64-redhat-linux/6.2.1/libgcc.a(cpuinfo.o)是 由DSO引用 / usr / bin / ld:最终链接编辑失败:错误的值 collect2:错误:ld已返回1个执行状态代码
有谁知道什么是错的?
答案 0 :(得分:0)
SFML存在gcc 5.3及更新版本的问题。目前,GCC是Fedora 25存储库中的6.3.1版本。您应该应用this patch:
diff --git a/src/SFML/Graphics/CMakeLists.txt b/src/SFML/Graphics/CMakeLists.txt
index 6f02fb6..bdc84e7 100644
--- a/src/SFML/Graphics/CMakeLists.txt
+++ b/src/SFML/Graphics/CMakeLists.txt
@@ -148,6 +148,13 @@ add_definitions(-DSTBI_FAILURE_USERMSG)
# when gcc is used; otherwise saving PNGs may crash in stb_image_write
if(SFML_COMPILER_GCC)
set_source_files_properties(${SRCROOT}/ImageLoader.cpp PROPERTIES COMPILE_FLAGS -fno-strict-aliasing)
+
+endif()
+
+# see https://bugs.launchpad.net/ubuntu/+source/gcc-5/+bug/1568899
+if(SFML_COMPILER_GCC AND BUILD_SHARED_LIBS)
+ message(WARNING "Applying workaround for https://bugs.launchpad.net/ubuntu/+source/gcc-5/+bug/1568899")
+ list(APPEND GRAPHICS_EXT_LIBS "-lgcc_s -lgcc")
endif()
# define the sfml-graphics target
如果您不想下载SFML git存储库,只需打开src/SFML/Graphics/CMakeLists.txt
,找到带有ImageLoader.cpp注释的if条件语句(第150行),并附加补丁添加的行。最终结果应如下所示:
# ImageLoader.cpp must be compiled with the -fno-strict-aliasing
# when gcc is used; otherwise saving PNGs may crash in stb_image_write
if(SFML_COMPILER_GCC)
set_source_files_properties(${SRCROOT}/ImageLoader.cpp PROPERTIES COMPILE_FLAGS -fno-strict-aliasing)
endif()
# see https://bugs.launchpad.net/ubuntu/+source/gcc-5/+bug/1568899
if(SFML_COMPILER_GCC AND BUILD_SHARED_LIBS)
message(WARNING "Applying workaround for https://bugs.launchpad.net/ubuntu/+source/gcc-5/+bug/1568899")
list(APPEND GRAPHICS_EXT_LIBS "-lgcc_s -lgcc")
endif()