Hordeking / sfxObjectDump

Parses 3d mesh data from Starfox rom
GNU General Public License v3.0
16 stars 0 forks source link

Problem opening executables and building from source #3

Open Luigi86101 opened 3 years ago

Luigi86101 commented 3 years ago

Trying to launch the unix executable on a Mac gives me this error:

zsh: exec format error: /Users/Desktop/sfxobjdump/sfxobjdump

Trying to build from source with the

g++ main.cpp

or

gcc main.cpp

command gives me this error:

main.cpp:27:10: fatal error: 'SFXObject.h' file not found
#include "SFXObject.h"
         ^~~~~~~~~~~~~
1 error generated.

(the SFXObject.h file is there and redownloading the folder didn't do anything)

Listing all of the .cpp files after main.cpp gave me a similar error except it said all of the respective .h files were not found (they were also there).

I'm not completely sure if I was building it right because I don't do that often.

Trying to launch the .exe file on a Windows computer gives me these errors

The code execution cannot proceed because libgcc_s_seh-1.dll was not found. Reinstalling the program may fix the problem.

The code execution cannot proceed because libstdc++-6.dll was not found. Reinstalling the program may fix the problem.

(reinstalling the program did not fix the problem)

Hordeking commented 3 years ago

Did you try "make debug" or "make release"? One of those would be the easiest way. Then you should find the executables in bin/Debug and/or bin/Release. They're command-line utils, by the way.

You can also open the cbp file in code++blocks, which was the orig IDE I used before converting it to a makefile.

If you're building by hand with g++, don't forget to use -Iinclude, because the .h files are all sitting in include/, not in the same directory with main.cpp (which is actually just a simple wrapper around the class that handles the file input and output).

I don't know why you're having trouble with the .dll files, that might be an issue with your MinGW or Cygwin install that they need to be reinstalled or have the dll file in there with the exec. It should build without any trouble on pretty much any system, since it doesn't use any special operating system stuff.

Hordeking commented 3 years ago

If you are able to get it built, go ahead and post what you did to fix it and close it. If it's significantly different from the basic "make x" recipe, I'll add something regarding build instructions. I'm definitely interested in the case of the macintosh build process if it differs much.

Luigi86101 commented 3 years ago

I'm having the same problems with the make debug and make release commands, and nothing appears in those respective folders.

/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/iomanip: note: 
  candidate function template not viable: requires 2 arguments, but 1 was
  provided
basic_ostream<_CharT, _Traits>& operator<<(
                            ^
In file included from main.cpp:27:
include/SFXObject.h:76:21: error: implicit instantiation of undefined template
  'std::__1::basic_stringstream<char, std::__1::char_traits<char>,
  std::__1::allocator<char> >'
            std::stringstream rawObject_Final;
                              ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/iosfwd: note: 
  template is declared here
class _LIBCPP_TEMPLATE_VIS basic_stringstream;
                           ^
3 errors generated.
make: *** [obj/Debug/main.o] Error 1

I didn't know it was a command line tool, but trying that now gives me the same errors as when I tried to launch those files.

Hordeking commented 3 years ago

Yeah, sfxObjDump is just a command-line tool. You basically give it the rom file, the address of the vertex data, and the address of the face data, and it parses it out. Some objects reuse vertex data but different face data (different paintjobs on the same sort of object, or different sizes, etc). I really should include a list of the valid ones, but I don't have any for Starfox 2 or the rest of the SuperFX games.

If you wanted to create a graphical frontend and help get it working for general systems, you could easily do that without messing with the underlying export code. You would just need to create another frontend in the same vein as main.cpp, but instead of using basic console IO, you would have to do it with windowing code.

  1. Try make clean && make debug
  2. Post the entire output, including command line (starting at the $ prompt or whatever your system uses)
  3. Run g++ -V and tell me what version you've got. If it isn't g++, please provide your compiler and version and all that.
  4. What system are you building it on? You've mentioned both Mac and Windows.

I suspect your issue might be related to your compiler libs. This software should build on pretty much any system with c++ and the standard template libraries. Can you build it on a bog standard linux live with g++ installed? You can do that using a live usb or virtual machine. What I'm trying to do is narrow it down to a compiler/linker issue or some incompatibility in the code.

I was able to build it on Windows 10 with MinGW with no trouble. So if you're building it on a Mac, we might have to work a bit through it, but it does seem to build fine on a standard Windows installation.

Luigi86101 commented 3 years ago

Here's the entire output with the command line for make clean && make debug

[user]@[users]-MacBook-Pro sfxObjectDump-master % make clean && make debug
rm -f obj/Debug/main.o obj/Debug/src/BSPTree.o obj/Debug/src/BufferReader.o obj/Debug/src/Face.o obj/Debug/src/Normal.o obj/Debug/src/SFXObject.o obj/Debug/src/Triangle.o obj/Debug/src/Vertex.o bin/Debug/sfxobjdump
rm -rf bin/Debug
rm -rf obj/Debug
rm -rf obj/Debug/src
rm -f obj/Release/main.o obj/Release/src/BSPTree.o obj/Release/src/BufferReader.o obj/Release/src/Face.o obj/Release/src/Normal.o obj/Release/src/SFXObject.o obj/Release/src/Triangle.o obj/Release/src/Vertex.o bin/Release/sfxobjdump
rm -rf bin/Release
rm -rf obj/Release
rm -rf obj/Release/src
test -d bin/Debug || mkdir -p bin/Debug
test -d obj/Debug || mkdir -p obj/Debug
test -d obj/Debug/src || mkdir -p obj/Debug/src
g++ -Wall -fexceptions -std=c++17 -g  -Iinclude -c main.cpp -o obj/Debug/main.o
In file included from main.cpp:27:
In file included from include/SFXObject.h:25:
include/BufferReader.h:26:29: error: implicit instantiation of undefined template
      'std::__1::basic_stringstream<char, std::__1::char_traits<char>,
      std::__1::allocator<char> >'
class BufferReader : public std::stringstream {
                            ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/iosfwd:139:32: note: 
      template is declared here
    class _LIBCPP_TEMPLATE_VIS basic_stringstream;
                               ^
In file included from main.cpp:27:
In file included from include/SFXObject.h:25:
include/BufferReader.h:28:47: error: no matching function for call to 'operator<<'
        public: BufferReader(std::ifstream & input){    operator<<(input.rdb...
                                                        ^~~~~~~~~~
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/type_traits:4056:3: note: 
      candidate function template not viable: requires 2 arguments, but 1 was
      provided
  operator<< (byte  __lhs, _Integer __shift) noexcept
  ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/ostream:753:1: note: 
      candidate function template not viable: requires 2 arguments, but 1 was
      provided
operator<<(basic_ostream<_CharT, _Traits>& __os, _CharT __c)
^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/ostream:760:1: note: 
      candidate function template not viable: requires 2 arguments, but 1 was
      provided
operator<<(basic_ostream<_CharT, _Traits>& __os, char __cn)
^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/ostream:793:1: note: 
      candidate function template not viable: requires 2 arguments, but 1 was
      provided
operator<<(basic_ostream<char, _Traits>& __os, char __c)
^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/ostream:800:1: note: 
      candidate function template not viable: requires 2 arguments, but 1 was
      provided
operator<<(basic_ostream<char, _Traits>& __os, signed char __c)
^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/ostream:807:1: note: 
      candidate function template not viable: requires 2 arguments, but 1 was
      provided
operator<<(basic_ostream<char, _Traits>& __os, unsigned char __c)
^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/ostream:814:1: note: 
      candidate function template not viable: requires 2 arguments, but 1 was
      provided
operator<<(basic_ostream<_CharT, _Traits>& __os, const _CharT* __str)
^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/ostream:821:1: note: 
      candidate function template not viable: requires 2 arguments, but 1 was
      provided
operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn)
^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/ostream:867:1: note: 
      candidate function template not viable: requires 2 arguments, but 1 was
      provided
operator<<(basic_ostream<char, _Traits>& __os, const char* __str)
^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/ostream:874:1: note: 
      candidate function template not viable: requires 2 arguments, but 1 was
      provided
operator<<(basic_ostream<char, _Traits>& __os, const signed char* __str)
^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/ostream:882:1: note: 
      candidate function template not viable: requires 2 arguments, but 1 was
      provided
operator<<(basic_ostream<char, _Traits>& __os, const unsigned char* __str)
^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/ostream:1039:1: note: 
      candidate function template not viable: requires 2 arguments, but 1 was
      provided
operator<<(_Stream&& __os, const _Tp& __x)
^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/ostream:1049:1: note: 
      candidate function template not viable: requires 2 arguments, but 1 was
      provided
operator<<(basic_ostream<_CharT, _Traits>& __os,
^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/ostream:1057:1: note: 
      candidate function template not viable: requires 2 arguments, but 1 was
      provided
operator<<(basic_ostream<_CharT, _Traits>& __os,
^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/ostream:1066:1: note: 
      candidate function template not viable: requires 2 arguments, but 1 was
      provided
operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __ec)
^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/ostream:1074:1: note: 
      candidate function template not viable: requires 2 arguments, but 1 was
      provided
operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p)
^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/ostream:1086:1: note: 
      candidate function template not viable: requires 2 arguments, but 1 was
      provided
operator<<(basic_ostream<_CharT, _Traits>& __os, unique_ptr<_Yp, _Dp> const& __p)
^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/ostream:1093:1: note: 
      candidate function template not viable: requires 2 arguments, but 1 was
      provided
operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x)
^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/iomanip:362:1: note: 
      candidate function template not viable: requires 2 arguments, but 1 was
      provided
operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x)
^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/iomanip:482:1: note: 
      candidate function template not viable: requires 2 arguments, but 1 was
      provided
operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x)
^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/iomanip:572:33: note: 
      candidate function template not viable: requires 2 arguments, but 1 was
      provided
basic_ostream<_CharT, _Traits>& operator<<(
                                ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/iomanip:592:33: note: 
      candidate function template not viable: requires 2 arguments, but 1 was
      provided
basic_ostream<_CharT, _Traits>& operator<<(
                                ^
In file included from main.cpp:27:
include/SFXObject.h:76:21: error: implicit instantiation of undefined template
      'std::__1::basic_stringstream<char, std::__1::char_traits<char>,
      std::__1::allocator<char> >'
                std::stringstream rawObject_Final;
                                  ^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/iosfwd:139:32: note: 
      template is declared here
    class _LIBCPP_TEMPLATE_VIS basic_stringstream;
                               ^
3 errors generated.
make: *** [obj/Debug/main.o] Error 1
[user]@[users]-MacBook-Pro sfxObjectDump-master % 

This is what I get with g++ -V

[user]@[users]-MacBook-Pro sfxObjectDump-master % g++ -v
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
[user]@[users]-MacBook-Pro sfxObjectDump-master % 

I'm compiling this on a Mac and I previously tested the .exe on Windows with a virtual machine. I believe these are the XCode developer tools which should be able to compile C++.

Hordeking commented 3 years ago

I have absolutely no clue what's causing it. Some searching seems to indicate that it might be a difference in how the compilers handle iffy code, or it might be differences in how the standard classes are defined. Clearly it's not liking something about the stringstream, but I wish I could tell you what that was. As I said, I didn't try to do anything particularly cutting edge and generally went out of my way to make sure it didn't have any actual compiler warnings. One of the things I saw seemed to indicate that using a static cast to a const ostream might be the fix (https://developer.apple.com/forums/thread/671896), but I have never used the *_cast<...> operators in c++, so if that's the fix, I don't even know how to implement it.

Another possibility is that it's related to forward declarations. More info: https://stackoverflow.com/questions/15583604/implicit-instantiation-of-undefined-template I would try to implement these myself, but I can't even replicate the issue at my end.

I could well have done something that's actually verboten, but that g++ is lenient about, where your compiler on the Mac is more strict about it. If you're able to get somewhere with it, please let me know how you fixed it so I can either implement it in my own codebase, or you can implement it and make a pull request.

Hordeking commented 2 years ago

@Luigi86101 Did you ever figure this one out? I just got to reading this again. Is the issue possibly because you are using the clang compiler and you're encountering some incompatibility in compiler specific code?

You might try changing the -std=c++17 to -std=c++2a or -std=c++2b and see if that helps. I tested my own with -std=c++14 and it worked.

It looks like clang does support c++17 for the most part, so it seems like that in particular isn't causing the trouble. According to your error, it looks like it happens when the code calls operator<<(...). I always thought this was a builtin, but perhaps clang does it differently. You might need to find a different way to dump that buffer to the stream.

This is the issue, but I really don't know why. I'm using the standard libs documented here https://www.cplusplus.com/reference/ostream/ostream/operator%3C%3C/

include/BufferReader.h:28:47: error: no matching function for call to 'operator<<'
        public: BufferReader(std::ifstream & input){    operator<<(input.rdb...
                                                        ^~~~~~~~~~
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/type_traits:4056:3: note: 
      candidate function template not viable: requires 2 arguments, but 1 was
      provided
  operator<< (byte  __lhs, _Integer __shift) noexcept

As you can see, all it does is takes a file and dumps it into the buffer specifically using the ostream& operator<< (streambuf* sb ); prototype on that page. But your libs seem to be looking for some other signature that involves two parameters, one being the implied lefthand side and the second being some kind of offset or shift.

You can try getting it to work by prepending this-> onto the front of the operator in the case that it's trying to use the wrong prototype, but I suspect that isn't the problem either (it builds for me and seems to work).