OneLoneCoder/Javidx9

ConsoleGameEngine with NetBeans = Several errors

gurkanctn opened this issue · 4 comments

I'm trying to use the ConsoleGameEngine with NetBeans (on Windows 10).

For those who wonder why:

  1. I gave up VS 2017 Community edition, I don't want to sign up anywhere.
  2. I also gave up using VS Code, it doesn't properly give me a debug environment (even the console doesn't show).

First problem, as expected, was to set UNICODE (UTF-8), and I couldn't do it properly, although I tried a few solutions that I came across on the Web.

I guess that:

  1. my include files (related to windows) are problematic,
  2. I couldn't set Unicode properly.

Here's the console error logs:

g++ -std=gnu++11 -c -g -MMD -MP -MF "build/Debug/Cygwin-Windows/ConsoleApplication1.o.d" -o build/Debug/Cygwin-Windows/ConsoleApplication1.o ConsoleApplication1.cpp
In file included from ConsoleApplication1.cpp:5:0:
olcConsoleGameEngine.h:127:2: error: #error Please enable UNICODE for your compiler! VS: Project Properties -> General -> Character Set -> Use Unicode. Thanks! - Javidx9
#error Please enable UNICODE for your compiler! VS: Project Properties -> General ->
^
In file included from ConsoleApplication1.cpp:5:0:
olcConsoleGameEngine.h: In member function 'bool olcSprite::Save(std::wstring)':
olcConsoleGameEngine.h:280:37: error: '_wfopen_s' was not declared in this scope
_wfopen_s(&f, sFile.c_str(), L"wb");
^
olcConsoleGameEngine.h: In member function 'bool olcSprite::Load(std::wstring)':
olcConsoleGameEngine.h:302:37: error: '_wfopen_s' was not declared in this scope
_wfopen_s(&f, sFile.c_str(), L"rb");
^
In file included from ConsoleApplication1.cpp:5:0:
olcConsoleGameEngine.h: At global scope:
olcConsoleGameEngine.h:1329:43: error: use of deleted function 'std::atomic::atomic(const std::atomic&)'
std::atomic m_bAudioThreadActive = false;
^
In file included from olcConsoleGameEngine.h:138:0,
from ConsoleApplication1.cpp:5:
/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/include/c++/atomic:66:5: note: declared here
atomic(const atomic&) = delete;
^
/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/include/c++/atomic:70:15: note: after user-defined conversion: constexpr std::atomic::atomic(bool)
constexpr atomic(bool __i) noexcept : _M_base(__i) { }
^
In file included from ConsoleApplication1.cpp:5:0:
olcConsoleGameEngine.h:1330:43: error: use of deleted function 'std::atomic::atomic(const std::atomic&)'
std::atomic m_nBlockFree = 0;
^
In file included from olcConsoleGameEngine.h:138:0,
from ConsoleApplication1.cpp:5:
/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/include/c++/atomic:631:7: note: declared here
atomic(const atomic&) = delete;
^
/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/include/c++/atomic:635:17: note: after user-defined conversion: constexpr std::atomic::atomic(std::atomic::__integral_type)
constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
^
In file included from ConsoleApplication1.cpp:5:0:
olcConsoleGameEngine.h:1333:37: error: use of deleted function 'std::atomic<_Tp>::atomic(const std::atomic<_Tp>&) [with _Tp = float]'
std::atomic m_fGlobalTime = 0.0f;
^
In file included from olcConsoleGameEngine.h:138:0,
from ConsoleApplication1.cpp:5:
/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/include/c++/atomic:187:7: note: declared here
atomic(const atomic&) = delete;
^
/usr/lib/gcc/x86_64-pc-cygwin/5.4.0/include/c++/atomic:191:17: note: after user-defined conversion: constexpr std::atomic<_Tp>::atomic(_Tp) [with _Tp = float]
constexpr atomic(_Tp __i) noexcept : _M_i(__i) { }
^
In file included from ConsoleApplication1.cpp:5:0:
olcConsoleGameEngine.h: In member function 'int olcConsoleGameEngine::ConstructConsole(int, int, int, int)':
olcConsoleGameEngine.h:399:37: error: 'wcscpy_s' was not declared in this scope
wcscpy_s(cfi.FaceName, L"Consolas");
^
olcConsoleGameEngine.h:414:48: warning: narrowing conversion of '(((int)((short int)((olcConsoleGameEngine*)this)->olcConsoleGameEngine::m_nScreenWidth)) + -1)' from 'int' to 'SHORT {aka short int}' inside { } [-Wnarrowing]
m_rectWindow = { 0, 0, (short)m_nScreenWidth - 1, (short)m_nScreenHeight - 1 };
^
olcConsoleGameEngine.h:414:76: warning: narrowing conversion of '(((int)((short int)((olcConsoleGameEngine*)this)->olcConsoleGameEngine::m_nScreenHeight)) + -1)' from 'int' to 'SHORT {aka short int}' inside { } [-Wnarrowing]
m_rectWindow = { 0, 0, (short)m_nScreenWidth - 1, (short)m_nScreenHeight - 1 };
^
In file included from ConsoleApplication1.cpp:5:0:
olcConsoleGameEngine.h: In member function 'void olcConsoleGameEngine::DrawWireFrameModel(const std::vector<std::pair<float, float> >&, float, float, float, float, short int, short int)':
olcConsoleGameEngine.h:765:78: error: 'cosf' was not declared in this scope
vecTransformedCoordinates[i].first = vecModelCoordinates[i].first * cosf(r) - vecModelCoordinates[i].second * sinf(r);
^
olcConsoleGameEngine.h:765:120: error: 'sinf' was not declared in this scope
vecTransformedCoordinates[i].first = vecModelCoordinates[i].first * cosf(r) - vecModelCoordinates[i].second * sinf(r);
^
olcConsoleGameEngine.h: In member function 'void olcConsoleGameEngine::GameThread()':
olcConsoleGameEngine.h:954:124: error: 'swprintf_s' was not declared in this scope
swprintf_s(s, 256, L"OneLoneCoder.com - Console Game Engine - %s - FPS: %3.2f", m_sAppName.c_str(), 1.0f / fElapsedTime);
^
olcConsoleGameEngine.h:955:22: error: cannot convert 'wchar_t*' to 'LPCSTR {aka const char*}' for argument '1' to 'WINBOOL SetConsoleTitleA(LPCSTR)'
SetConsoleTitle(s);
^
olcConsoleGameEngine.h: In constructor 'olcConsoleGameEngine::olcAudioSample::olcAudioSample(std::wstring)':
olcConsoleGameEngine.h:1004:41: error: '_wfopen_s' was not declared in this scope
_wfopen_s(&f, sWavFile.c_str(), L"rb");
^
olcConsoleGameEngine.h: In static member function 'static void olcConsoleGameEngine::waveOutProcWrap(HWAVEOUT, UINT, DWORD, DWORD, DWORD)':
olcConsoleGameEngine.h:1196:27: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
((olcConsoleGameEngine*)dwInstance)->waveOutProc(hWaveOut, uMsg, dwParam1, dwParam2);
^
olcConsoleGameEngine.h: In member function 'void olcConsoleGameEngine::AudioThread()':
olcConsoleGameEngine.h:1209:59: error: 'pow' was not declared in this scope
short nMaxSample = (short)pow(2, (sizeof(short) * 8) - 1) - 1;
^
olcConsoleGameEngine.h: In lambda function:
olcConsoleGameEngine.h:1236:31: error: 'fmin' was not declared in this scope
return fmin(fSample, fMax);
^
olcConsoleGameEngine.h:1238:32: error: 'fmax' was not declared in this scope
return fmax(fSample, -fMax);
^
olcConsoleGameEngine.h: In member function 'void olcConsoleGameEngine::AudioThread()':
olcConsoleGameEngine.h:1246:84: error: invalid operands of types 'void' and 'float' to binary 'operator*'
nNewSample = (short)(clip(GetMixerOutput(c, m_fGlobalTime, fTimeStep), 1.0) * fMaxSample);
^
olcConsoleGameEngine.h: In member function 'int olcConsoleGameEngine::Error(const wchar_t*)':
olcConsoleGameEngine.h:1362:124: error: cannot convert 'wchar_t*' to 'LPSTR {aka char*}' for argument '5' to 'DWORD FormatMessageA(DWORD, LPCVOID, DWORD, DWORD, LPSTR, DWORD, char**)'
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf, 256, NULL);
^
make[2]: *** [nbproject/Makefile-Debug.mk:68: build/Debug/Cygwin-Windows/ConsoleApplication1.o] Error 1
make[2]: Leaving directory '/cygdrive/c/Projects/ConsoleGameEngine'
make[1]: *** [nbproject/Makefile-Debug.mk:59: .build-conf] Error 2
make[1]: Leaving directory '/cygdrive/c/Projects/ConsoleGameEngine'
make: *** [nbproject/Makefile-impl.mk:40: .build-impl] Error 2

BUİLD FAILED (exit value 2, total time: 3s)

were you able to fix?

Hi Imran,

The recommended approach is to use the newer olcPixelGameEngine - its almost identical but works cross platform and is generally better, has documentation and is maintained.

That said, you might still not have any luck with netbeans unless your compiler is really up to date, supporting C++17 at least.

dear @OneLoneCoder , thanks for the reply, actually I am attempting to setup things on CodeBlocks using MinGW GNU GCC on Windows 10, as VS 2019 is 4G+.

That said, I am actually more interested in the Video series related to Mathematics behind 3D rendering where ConsoleGameEngine is used to draw. I also searched around the blog but could not find my way through. Anyway a big thumbs up for the fabulous content.