I’m currently trying to get the Mario project from https://github.com/aleju/mario-ai to work on my ubuntu (16.04) system. I followed the tutorial and already solved some errors, but now I get something that looks like a compile error on the lsnes emulator and that doesn’t make sense to me.
My command is 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
. I added the flags trying to solve my last error.
This is the error that I get:
... 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
I’m not really familiar with C++, but the file looks fine to me.
Do you have any idea what could be the problem? I already tried the solution suggested at the only other question regarding lsnes that I found here (link error with “undefined lua_xxxxx” when building lsnes), but it didn’t help.
Advertisement
Answer
I just looked closer at your call to g++
and you are using the option -std=c++0x
. That tells the compiler to use the C++11 standard. However, as stated in my comment, the code you posted requires at least C++14 to work. So use the option -std=c++14
instead and it should work.