OpenD2
OpenD2 copied to clipboard
building on linux
Hi there, I've tried to build OpenD2 project on my Fedora, and reached this:
/home/username/git/d2/OpenD2/Modcode/Common/DataTables.cpp: In function ‘int DataTables_Load(const char*, void**, D2TxtLinkStrc**, size_t)’:
/home/username/git/d2/OpenD2/Modcode/Common/DataTables.cpp:65:3: error: ‘snprintf’ was not declared in this scope
65 | snprintf(szPath, MAX_D2PATH, "%s%s.bin", D2DATATABLES_DIR, szDataTableName);
| ^~~~~~~~
/home/username/git/d2/OpenD2/Modcode/Common/DataTables.cpp:2:1: note: ‘snprintf’ is defined in header ‘<cstdio>’; did you forget to ‘#include <cstdio>’?
1 | #include "D2Common.hpp"
+++ |+#include <cstdio>
2 |
/home/username/git/d2/OpenD2/Modcode/Common/DataTables.cpp:76:2: error: ‘snprintf’ was not declared in this scope
76 | snprintf(szPath, MAX_D2PATH, "%s%s.txt", D2DATATABLES_DIR, szDataTableName);
| ^~~~~~~~
/home/username/git/d2/OpenD2/Modcode/Common/DataTables.cpp:76:2: note: ‘snprintf’ is defined in header ‘<cstdio>’; did you forget to ‘#include <cstdio>’?
make[2]: *** [CMakeFiles/D2Common.dir/build.make:135: CMakeFiles/D2Common.dir/Modcode/Common/DataTables.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:147: CMakeFiles/D2Common.dir/all] Error 2
make: *** [Makefile:104: all] Error 2
-- Check for working C compiler: /usr/bin/cc
cc (GCC) 10.2.1 20201125 (Red Hat 10.2.1-9)
-- Check for working CXX compiler: /usr/bin/c++
c++ (GCC) 10.2.1 20201125 (Red Hat 10.2.1-9)
I've tried to include cstdio library, but had another errors.
snprintf should not be used, the D2Lib version of snprintf should be used instead.
Yeah, but what does this error mean? What should I do to fix it?
Same error in FreeBSD: clang 10.0.1 and g++ 10.2.0
Same missing cstdio in Slackware using gcc 10.3.0
When I added cstdio to /Modcode/Common/DataTables.cpp and remake I get the error <Windows.h> is missing for Bitmap.cpp.
snprintf should not be used, the D2Lib version of snprintf should be used instead.
@eezstreet so what should I do? should I change the code in order to run it? Or I'm doing something wrong?
Are we missing a library flag or need to specify a different library file to use the right function call?
@gucio321 did you find a solution?
@kermitdafrog8 not yet