msokalski / ascii-patrol

Ascii Patrol is an ASCII game project. It was mainly inspired by "Moon Patrol", my favourite arcade game at the times I was a child.
GNU General Public License v3.0
221 stars 20 forks source link

Problem building in Ubuntu #26

Closed d-tork closed 1 year ago

d-tork commented 1 year ago

At the step cmake --build build I encountered the following output, which looks like traceback for an error but I can't pinpoint it. There are references to the high score functions, but I have curl installed and it is up-to-date.

[ 92%] Building CXX object CMakeFiles/asciipat.dir/spec_nix.cpp.o
In file included from /home/dtork/repos/ascii-patrol/spec_nix.cpp:58:
/home/dtork/repos/ascii-patrol/spec_nix.cpp: In function ‘void get_hiscore(int, const char*)’:
/home/dtork/repos/ascii-patrol/spec_nix.cpp:1334:25: warning: ‘%s’ directive writing up to 1023 bytes into a region of size 1006 [-Wformat-overflow=]
 1334 |                         "curl --silent -o \"%s\" \"http://ascii-patrol.com/rank.php?rank=%d&id=%s\" 2>/dev/null"
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1335 |                         ,path,ofs+1,id);
      |                          ~~~~
/home/dtork/repos/ascii-patrol/spec.h:94:45: note: in definition of macro ‘sprintf_s’
   94 | #define sprintf_s(dst,size,...) sprintf(dst,__VA_ARGS__)
      |                                             ^~~~~~~~~~~
/home/dtork/repos/ascii-patrol/spec_nix.cpp:1334:45: note: format string is defined here
 1334 |                         "curl --silent -o \"%s\" \"http://ascii-patrol.com/rank.php?rank=%d&id=%s\" 2>/dev/null"
      |                                             ^~
In file included from /home/dtork/repos/ascii-patrol/spec_nix.cpp:58:
/home/dtork/repos/ascii-patrol/spec.h:94:40: note: ‘sprintf’ output 78 or more bytes (assuming 1101) into a destination of size 1024
   94 | #define sprintf_s(dst,size,...) sprintf(dst,__VA_ARGS__)
      |                                 ~~~~~~~^~~~~~~~~~~~~~~~~
/home/dtork/repos/ascii-patrol/spec_nix.cpp:1333:17: note: in expansion of macro ‘sprintf_s’
 1333 |                 sprintf_s(cmd,1024,
      |                 ^~~~~~~~~
/home/dtork/repos/ascii-patrol/spec_nix.cpp:1340:25: warning: ‘%s’ directive writing up to 1023 bytes into a region of size 1006 [-Wformat-overflow=]
 1340 |                         "curl --silent -o \"%s\" \"http://ascii-patrol.com/rank.php?rank=%d\" 2>/dev/null"
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1341 |                         ,path,ofs+1);
      |                          ~~~~
/home/dtork/repos/ascii-patrol/spec.h:94:45: note: in definition of macro ‘sprintf_s’
   94 | #define sprintf_s(dst,size,...) sprintf(dst,__VA_ARGS__)
      |                                             ^~~~~~~~~~~
/home/dtork/repos/ascii-patrol/spec_nix.cpp:1340:45: note: format string is defined here
 1340 |                         "curl --silent -o \"%s\" \"http://ascii-patrol.com/rank.php?rank=%d\" 2>/dev/null"
      |                                             ^~
In file included from /home/dtork/repos/ascii-patrol/spec_nix.cpp:58:
/home/dtork/repos/ascii-patrol/spec.h:94:40: note: ‘sprintf’ output between 74 and 1107 bytes into a destination of size 1024
   94 | #define sprintf_s(dst,size,...) sprintf(dst,__VA_ARGS__)
      |                                 ~~~~~~~^~~~~~~~~~~~~~~~~
/home/dtork/repos/ascii-patrol/spec_nix.cpp:1339:17: note: in expansion of macro ‘sprintf_s’
 1339 |                 sprintf_s(cmd,1024,
      |                 ^~~~~~~~~
/home/dtork/repos/ascii-patrol/spec_nix.cpp: In function ‘void post_hiscore()’:
/home/dtork/repos/ascii-patrol/spec_nix.cpp:1357:17: warning: ‘%s’ directive writing up to 1023 bytes into a region of size 1006 [-Wformat-overflow=]
 1357 |                 "curl --silent -o \"%s\" -F \"rec=@%s\" \"http://ascii-patrol.com/rank.php\" 2>/dev/null"
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1358 |                 ,path,
      |                  ~~~~
/home/dtork/repos/ascii-patrol/spec.h:94:45: note: in definition of macro ‘sprintf_s’
   94 | #define sprintf_s(dst,size,...) sprintf(dst,__VA_ARGS__)
      |                                             ^~~~~~~~~~~
/home/dtork/repos/ascii-patrol/spec_nix.cpp:1357:37: note: format string is defined here
 1357 |                 "curl --silent -o \"%s\" -F \"rec=@%s\" \"http://ascii-patrol.com/rank.php\" 2>/dev/null"
      |                                     ^~
In file included from /home/dtork/repos/ascii-patrol/spec_nix.cpp:58:
/home/dtork/repos/ascii-patrol/spec.h:94:40: note: ‘sprintf’ output 78 or more bytes (assuming 1101) into a destination of size 1024
   94 | #define sprintf_s(dst,size,...) sprintf(dst,__VA_ARGS__)
      |                                 ~~~~~~~^~~~~~~~~~~~~~~~~
/home/dtork/repos/ascii-patrol/spec_nix.cpp:1356:9: note: in expansion of macro ‘sprintf_s’
 1356 |         sprintf_s(cmd,1024,
      |         ^~~~~~~~~
[100%] Linking CXX executable asciipat
[100%] Built target asciipat

Platform: Ubuntu Desktop 22.04.2 LTS (Jammy Jellyfish)

msokalski commented 1 year ago

Hey, thaks for the info. Actually it doesn't look that bad, that's the warning only and the binary program was successfuly created (asciipat).

Warning is printed about string buffer theoretically could be too short for storing curl command line. Practically it won't be too short (1024 chars).

d-tork commented 1 year ago

Oh sorry! Forgot the most important part: I can't run it. There is no executable asciipat, and run.sh gives

dtork@elsie ~/repos/ascii-patrol (master) $ ./run.sh
Couldn't get a file descriptor referring to the console.
./run.sh: line 2: ./asciipat: No such file or directory
Couldn't get a file descriptor referring to the console.
msokalski commented 1 year ago

Ok, try a long shot with: sudo ./asciipat

Maybe your OS is a bit too defensive :)

d-tork commented 1 year ago

Still not the case, asciipat isn't a file. Here's me trying to rebuild to show that it completed without errors, and the attempts to run as sudo:

dtork@elsie ~/repos/ascii-patrol (master) $ cmake --build build
Consolidate compiler generated dependencies of target asciipat
[100%] Built target asciipat
dtork@elsie ~/repos/ascii-patrol (master) $ sudo ./asciipat
sudo: ./asciipat: command not found
dtork@elsie ~/repos/ascii-patrol (master) $ sudo ./run.sh
./run.sh: 2: ./asciipat: not found
dtork@elsie ~/repos/ascii-patrol (master) $
msokalski commented 1 year ago

Maybe you could try building it from the bash script? ./build.sh then ./asciipat

d-tork commented 1 year ago

That worked. Ultimately the cmake commands did not. Is it better to list that method of installation before CMake in the README? Does the other method have any advantages over a simple shell script?

msokalski commented 1 year ago

Cmake thing was a contribution from someone, my bad I haven't tested it 😅 before merging.

Anyway I'm glad I could help.