【发布时间】:2022-09-28 03:05:10
【问题描述】:
我正在尝试使用 SCons 构建 Godot。一切正常,直到我在我的自定义模块使用的库中使用了std::atomic(该库与我为测试它而创建的 Qt 应用程序一起正常工作)。然后发生了这个错误:
[100%] Linking Program ==> bin/godot.x11.tools.64
/usr/bin/ld: /home/sms/Code/_BUILDS/build-PyWally-Desktop-Release/libPyWally.so: undefined reference to `__atomic_store_16\'
/usr/bin/ld: /home/sms/Code/_BUILDS/build-PyWally-Desktop-Release/libPyWally.so: undefined reference to `__atomic_load_16\'
collect2: error: ld returned 1 exit status
scons: *** [bin/godot.x11.tools.64] Error 1
scons: building terminated because of errors.
我在谷歌上搜索并发现了原子/架构问题,所以我添加了-march=native、-mtune=native 和-latomic,因为我有现代 x64 PC/系统,这不应该是一个问题......所以我的 SCsub 看起来像这样(wallycontroller 是我的自定义模块,pywally - 我的库):
Import(\'env\')
sources = [
\"wallycontroller.cpp\",
\"wallycontroller.cpp\",
\"register_types.cpp\"
]
env.Append(CPPPATH=[\"/usr/include/python3.10\"])
env.Append(LIBS=[\'python3.10\'])
env.Append(CCFLAGS=[\'-march=native\', \'-mtune=native\', \'-latomic\'])
env.Append(CPPPATH=[\"#bin/../../PyWallie\"])
env.Append(LIBPATH=[\"#bin/../../../_BUILDS/build-PyWally-Desktop-Release\"])
env.Append(LIBS=[\'PyWally\'])
envw = env.Clone()
envw.Append(CCFLAGS=[\'-O2\'])
if ARGUMENTS.get(\'wallycontroller_shared\', \'no\') == \'yes\':
envw.Append(CCFLAGS=[\'-fPIC\'])
envw[\'LIBS\'] = []
envw.Append(LIBS=[\'python3.10\'])
envw.Append(LIBS=[\'PyWally\'])
shared_lib = envw.SharedLibrary(target=\'#bin/../../godot_modules/wallycontroller\', source=sources)
shared_lib_shim = shared_lib[0].name.rsplit(\'.\', 1)[0]
env.Append(LIBS=[shared_lib_shim])
env.Append(LIBPATH=[\'#bin\'])
else:
envw.add_source_files(env.modules_sources, sources)
这些是我关于构建的 SCons 论点:
platform = \"x11\"
tools = \"yes\"
target = \"debug\"
bits = 64
custom_modules = \"../godot_modules\"
use_lto = \"yes\"
walliecontroller_shared = \"yes\"
udev = \"no\"
在我添加 std::atomic 之前,此配置不会发生任何问题,但它真的很方便,我不想删除它......任何帮助将不胜感激。
-
哪个平台?哪个编译器(gcc、clang、other)?哪个编译器版本?您是否尝试将“原子”添加到您链接的库列表中? (或用谷歌搜索丢失的符号 __atomic_store_16?)
-
@bdbaddog Fedora x86_64,GCC 11.3.1。关于提议的解决方案,就像我在帖子中所说的那样,正如您在我的 SCsub 中看到的那样,我正在添加 -latomic、-march=native 和 -mtune=native,这些是我为 __atomic_store_16 搜索的解决方案:( libatomic.so 在我的 /usr/lib 中
-
将“原子”添加到 LIBS,而不是 CCFLAGS
标签: c++ g++ scons godot stdatomic