B-r*_*rad 3 c++ gcc github cmake mingw-w64
相关源代码的 Github 存储库位于: https: //github.com/arishackstv/cubemod
作为参考,这是游戏 Cubeworld 的一个模组,我正在尝试根据自己的口味进行修改。
该存储库有一个 CMakeLists.txt,我用它来生成 MinGW makefile,因为创建者说该 mod 是使用 MinGW 在发布模式下构建的。这是我使用他的 CMakeLists.txt 进行的 CMake 配置:CMake 配置
它似乎生成了 makefile,没有任何问题,所以我尝试 make。我遇到了以下错误:错误
绝大多数错误都遵循以下原则:
In file included from C:\Users\[username]\Desktop\cubemod-master\src\core\main.cpp:18:0:C:/Users/[username]/Desktop/CUBEMO~1/src/core/hook/hooks/artifact/display/hook_artifact_display_roundf.h:9:22: error: 'hook' declared as an 'inline' field static inline Hook* hook;
Run Code Online (Sandbox Code Playgroud)
这些内联字段错误非常多。生成上述特定错误的具体代码是这样的:
#pragma once
#include <hook/hook.h>
#include <game_structures.h>
#include "hook_concat_artifact_suffix.h"
class Hookroundf : public Hook
{
static inline Hook* hook;
//This is literally only called from the artifact display thing so it's fine
static float HOOK cube_roundf(float f)
{
//Get actual artifact stats
return Main::GetInstance().GetLocalPlayer()->GetIncreasedArtifactStats((ArtifactType)HookConcatArtifactSuffix::artifact_index, true);
}
public:
Hookroundf() : Hook(MemoryHelper::GetCubeBase() + 0x275760, (void*)cube_roundf, hook)
{}
};
Run Code Online (Sandbox Code Playgroud)
这个家伙的 Github 上实际编译的版本确实有效,我已经尝试过了,所以我觉得他的源代码遇到编译错误很奇怪。我想知道这是否归结为我的构建环境设置不正确?如果有人能够成功编译此代码,我很想听听您的步骤,看看我出了什么问题。如果这个源代码确实有错误,我很想知道可以采取哪些措施来修复它。静态内联字段不是 C++ 17 的东西吗?也许就是这样?虽然我尝试在 CMAKE_CXX_FLAGS 中指定 -std=C++17 但似乎没有做到这一点。
编辑:升级我的 gcc 版本的建议非常有帮助。将 gcc 更新到最新可用版本 (9.20) 后,与不可用的 C++ 功能(如内联变量)相关的错误已修复!现在错误又多了一些,但数量少了很多。这是我们尝试 make 的新输出:
C:\Users\[username]\Desktop\cubemod-master\BUILD_>make
Scanning dependencies of target cubemod
[ 33%] Building CXX object CMakeFiles/cubemod.dir/src/dllmain.cpp.obj
[ 66%] Building CXX object CMakeFiles/cubemod.dir/src/core/main.cpp.obj
[100%] Linking CXX shared library ..\bin\cubemod.cwmod
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: CMakeFiles\cubemod.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x2f): undefined reference to `xed_operand_values_set_mode'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: CMakeFiles\cubemod.dir/objects.a(main.cpp.obj):main.cpp:(.text$_ZN4Hook11InstallHookEv[__ZN4Hook11InstallHookEv]+0x11): undefined reference to `xed_tables_init'
c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../mingw32/bin/ld.exe: CMakeFiles\cubemod.dir/objects.a(main.cpp.obj):main.cpp:(.text$_ZN4Hook11InstallHookEv[__ZN4Hook11InstallHookEv]+0x89): undefined reference to `xed_decode'
collect2.exe: error: ld returned 1 exit status
make[2]: *** [../bin/cubemod.cwmod] Error 1
make[1]: *** [CMakeFiles/cubemod.dir/all] Error 2
make: *** [all] Error 2
Run Code Online (Sandbox Code Playgroud)
我将开始研究这些新错误,我将不胜感激任何帮助。但我认为这篇文章的标题提出的特定问题可以被视为“已解决”。
| 归档时间: |
|
| 查看次数: |
2934 次 |
| 最近记录: |