eezstreet / OpenD2

A project to open source Diablo 2.
GNU General Public License v3.0
572 stars 76 forks source link

building on linux #44

Open gucio321 opened 3 years ago

gucio321 commented 3 years ago

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.

eezstreet commented 3 years ago

snprintf should not be used, the D2Lib version of snprintf should be used instead.

gucio321 commented 3 years ago

Yeah, but what does this error mean? What should I do to fix it?

nunotexbsd commented 3 years ago

Same error in FreeBSD: clang 10.0.1 and g++ 10.2.0

kermitdafrog8 commented 3 years ago

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 is missing for Bitmap.cpp.

gucio321 commented 3 years ago

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?

kermitdafrog8 commented 3 years ago

Are we missing a library flag or need to specify a different library file to use the right function call?

kermitdafrog8 commented 3 years ago

@gucio321 did you find a solution?

gucio321 commented 3 years ago

@kermitdafrog8 not yet