gpt4 book ai didi

c++ - 在 ubuntu 上编译 lsnes 模拟器时出错

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:46:26 31 4
gpt4 key购买 nike

我目前正在尝试从 https://github.com/aleju/mario-ai 获取 Mario 项目在我的 ubuntu (16.04) 系统上工作。我按照教程已经解决了一些错误,但现在我在 lsnes 模拟器上得到了一些看起来像编译错误的东西,这对我来说没有意义。

我的命令是 LDFLAGS="-L/usr/lib -L/usr/local/lib -L/usr/lib/x86_64-linux-gnu"CFLAGS="-I/usr/include -I/usr/local/include -I/usr/include/lua5.1"make.我添加了试图解决我最后一个错误的标志。

这是我得到的错误:

...
g++ -c -o core.o core.cpp -I../../../include -I../../../bsnes -I/usr/include -I/usr/local/include -I/usr/include/lua5.1 -std=gnu++0x -pthread -g -DNATIVE_THREADS -DUSE_LIBGCRYPT_SHA256 -I/usr/include/lua5.1 -DBSNES_IS_COMPAT -DBSNES_HAS_DEBUGGER -DBSNES_VERSION=\"085\" -DLIBSNES_INCLUDE_FILE=\"ui-libsnes/libsnes.hpp\" -Wreturn-type
In file included from ../../../bsnes/nall/array.hpp:10:0,
from ../../../bsnes/snes/snes.hpp:28,
from core.cpp:49:
../../../bsnes/nall/bit.hpp: In instantiation of ‘constexpr unsigned int nall::uclip(unsigned int) [with int bits = 24]’:
../../../bsnes/snes/cpu/core/registers.hpp:52:69: required from here
../../../bsnes/nall/bit.hpp:13:3: error: body of constexpr function ‘constexpr unsigned int nall::uclip(unsigned int) [with int bits = 24]’ not a return-statement
}
^
../../../bsnes/nall/bit.hpp: In instantiation of ‘constexpr unsigned int nall::uclip(unsigned int) [with int bits = 2]’:
../../../bsnes/nall/varint.hpp:32:55: required from ‘nall::uint_t<bits>::uint_t(unsigned int) [with unsigned int bits = 2u]’
../../../bsnes/snes/controller/controller.hpp:27:33: required from here
../../../bsnes/nall/bit.hpp:13:3: error: body of constexpr function ‘constexpr unsigned int nall::uclip(unsigned int) [with int bits = 2]’ not a return-statement
Makefile:44: die Regel für Ziel „core.o“ scheiterte
make[3]: *** [core.o] Fehler 1
...

比特.hpp:

#ifndef NALL_BIT_HPP
#define NALL_BIT_HPP

namespace nall {
template<int bits> constexpr inline unsigned uclamp(const unsigned x) {
enum { y = (1U << (bits - 1)) + ((1U << (bits - 1)) - 1) };
return y + ((x - y) & -(x < y)); //min(x, y);
}

template<int bits> constexpr inline unsigned uclip(const unsigned x) {
enum { m = (1U << (bits - 1)) + ((1U << (bits - 1)) - 1) };
return (x & m);
}

template<int bits> constexpr inline signed sclamp(const signed x) {
enum { b = 1U << (bits - 1), m = (1U << (bits - 1)) - 1 };
return (x > m) ? m : (x < -b) ? -b : x;
}

template<int bits> constexpr inline signed sclip(const signed x) {
enum { b = 1U << (bits - 1), m = (1U << bits) - 1 };
return ((x & m) ^ b) - b;
}

namespace bit {
//lowest(0b1110) == 0b0010
template<typename T> constexpr inline T lowest(const T x) {
return x & -x;
}

//clear_lowest(0b1110) == 0b1100
template<typename T> constexpr inline T clear_lowest(const T x) {
return x & (x - 1);
}

//set_lowest(0b0101) == 0b0111
template<typename T> constexpr inline T set_lowest(const T x) {
return x | (x + 1);
}

//round up to next highest single bit:
//round(15) == 16, round(16) == 16, round(17) == 32
inline unsigned round(unsigned x) {
if((x & (x - 1)) == 0) return x;
while(x & (x - 1)) x &= x - 1;
return x << 1;
}
}
}

#endif

我不太熟悉 C++,但文件对我来说看起来不错。

您知道可能是什么问题吗?我已经尝试了我在此处找到的关于 lsnes 的唯一其他问题中建议的解决方案 ( link error with "undefined lua_xxxxx" when building lsnes ),但它没有帮助。

最佳答案

我刚刚仔细查看了您对 g++ 的调用,您正在使用选项 -std=c++0x。这告诉编译器使用 C++11 标准。但是,正如我在评论中所述,您发布的代码至少需要 C++14 才能工作。因此,请改用选项 -std=c++14,它应该可以工作。

关于c++ - 在 ubuntu 上编译 lsnes 模拟器时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43889403/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com