我目前正试图让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
...
bit.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),但它没有帮助。
答案 0 :(得分:3)
我只是仔细看了你对g++
的电话,你正在使用-std=c++0x
选项。这告诉编译器使用C ++ 11标准。但是,正如我的评论中所述,您发布的代码至少需要C ++ 14才能运行。因此,请使用选项-std=c++14
,它应该可以正常工作。