ohio813 / starcraft2replay

Automatically exported from code.google.com/p/starcraft2replay
0 stars 0 forks source link

Invalid conversion from sc2replay::off_t* to off_t* #2

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I've installed all of the dependencies so far without issue.  I'm using 
  libmpq-0.4.2
  cmake-2.8.1
  starcraft2replay commit 34

Running 'make -j' from the build directory I get this:

/tmp/starcraft2replay/src/mpqimpl.cpp: In member function âconst
sc2replay::MPQFile* sc2replay::MPQArchiveImpl::getFile(const
sc2replay::MPQArchive*, const std::string&) constâ:
/tmp/starcraft2replay/src/mpqimpl.cpp:65: error: invalid conversion from
âsc2replay::off_t*â to âoff_t*â
/tmp/starcraft2replay/src/mpqimpl.cpp:65: error:   initializing argument 3
of âint32_t libmpq__file_unpacked_size(mpq_archive_s*, uint32_t, off_t*)â
make[2]: *** [CMakeFiles/SC2Replay.dir/src/mpqimpl.cpp.o] Error 1
make[1]: *** [CMakeFiles/SC2Replay.dir/all] Error 2
make: *** [all] Error 2

I've dug into it a bit, but I'm not much of a C++ developer and not sure
where to go next.  It looks to me like size is defined of type off_t on
line 61, but the compiler is obviously complaining about it for some reason

Original issue reported on code.google.com by bchecke...@gmail.com on 8 Apr 2010 at 2:16

GoogleCodeExporter commented 9 years ago
Also, FWIW this is on a 64-bit CentOS 5.3 virtual server.

Original comment by bchecke...@gmail.com on 8 Apr 2010 at 2:20

GoogleCodeExporter commented 9 years ago
oh oh oh :)
Basically, the problem is that types like off_t, uintx_t, intx_t, etc.. are 
defined 
in a header called stdint.h that were introduced in C99.
GCC decided to merge C99 into C++03, VS did not do the merge.

Fact is that these types are really useful since they have a fixed size.
For the library to be built on VS and GCC, i chose to redefine these types 
myself, 
but I did not added the tons of per-architecture conditions that would make 
them 
totally multiplatform.

So, well, basically the idea is that you should be able to just comment the 
intx_t, 
uintx_t and off_t in sc2replay/types.h, and replace them with a #include 
<stdint.h>
That should do the trick.

I add on my todo list to really do a clean fix of these typing problems, and 
add a 
multiplatform stdint.h to the project.

Let me know if you still have problems, and thanks for pointing it out :)

Original comment by vallee.aurelien on 9 Apr 2010 at 3:45

GoogleCodeExporter commented 9 years ago

Original comment by vallee.aurelien on 9 Apr 2010 at 3:45

GoogleCodeExporter commented 9 years ago
Awesome.  Thanks for looking into this.  I just I just commented out the typdef 
for
off_t, in inc/sc2replay/types.h line 28 and it successfully compiled.  I was 
able to
parse a couple of the samples in the material/ directory.

Original comment by bchecke...@gmail.com on 9 Apr 2010 at 2:27

GoogleCodeExporter commented 9 years ago
Thanks, I had the same problem and deleting off_t and including the standard 
types
made the project build. I'm using the extract tools and they works very well!

Original comment by makev...@gmail.com on 11 Apr 2010 at 4:23

GoogleCodeExporter commented 9 years ago
FWIW, I tried building this on another machine that is 32-bit and it compiled, 
but
segfaults when trying to run anything.   

Original comment by bchecke...@gmail.com on 16 Apr 2010 at 4:49

GoogleCodeExporter commented 9 years ago
Same problem in my 32-bit machine. I can compile file, but then I get only 
Segmentation fault 

Original comment by milutin....@gmail.com on 17 Apr 2010 at 7:02

GoogleCodeExporter commented 9 years ago
Hello,
Thanks for the feedback!
Could you test using StormLib versus libmpq ?
If the problem persists, could you paste a gdb log (with a "bt" and "list" if 
possible ^^)

Original comment by vallee.aurelien on 18 Apr 2010 at 12:13

GoogleCodeExporter commented 9 years ago
Hi,
first of all I don't know how to use Stormlib. I installed it so I have these:
install libStorm.so /usr/local/lib
mkdir -p /usr/local/include/StormLib
cp StormLib.h /usr/local/include/StormLib
cp StormPort.h /usr/local/include/StormLib

However, if i set cmake -DLIBMPQ=OFF .. - this doesn't change DLIBMPQ to OFF 
(how it is in 
README, also -BUILD_LIBMPQ=OFF doesn't do it)  so I modified CMakeLists.txt in 
OPTION and I 
got:

CMake Error: The following variables are used in this project, but they are set 
to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake 
files:
MPQLib
    linked by target "SC2Replay" in directory /home/sc2replays

-- Configuring incomplete, errors occurred!
make: *** No targets specified and no makefile found.  Stop.

I tried to change FINDLIBRARY with libStorm, also with parameter PATH, but it 
doesn't work.  
So I stuck with libmpq. And I tried first time gdb like gdb read_mpq

(gdb) run test.SC2Replay 
Starting program: /home/sc2replays/build/tests/read_mpq test.SC2Replay

Error loading MPQ file test.SC2Replay.

Program received signal SIGSEGV, Segmentation fault.
libmpq__archive_close (mpq_archive=0x0) at mpq.c:331
331 mpq.c: No such file or directory.
    in mpq.c
Current language:  auto
The current source language is "auto; currently c".

(gdb) bt
#0  libmpq__archive_close (mpq_archive=0x0) at mpq.c:331
#1  0x08058ad2 in ~MPQArchiveImpl (this=0x8061028, __in_chrg=<value optimized 
out>)
    at /home/sc2replays/src/mpqimpl.cpp:26
#2  0x08058896 in ~MPQArchive (this=0xbffff1e4, __in_chrg=<value optimized out>)
    at /home/sc2replays/src/mpq.cpp:19
#3  0x0805670b in sc2replay::Replay::load (this=0xbffff254, filename=...)
    at /home/sc2replays/src/replay.cpp:56
#4  0x08055ffc in Replay (this=0xbffff254, filename=...) at 
/home/mito/sc2replays/src/replay.cpp:15
#5  0x08052424 in main (argc=2, argv=0xbffff454) at 
/home/sc2replays/tests/read_mpq.cpp:18

(gdb) list
326 in mpq.c

I hope my naive try helps you to help me :)

Original comment by milutin....@gmail.com on 18 Apr 2010 at 11:34

GoogleCodeExporter commented 9 years ago
Hi, i am having the same problem :

~/work/webapps/starcraft2replay/build  $ make -j
Scanning dependencies of target SC2Replay
[  7%] [ 15%] Building CXX object CMakeFiles/SC2Replay.dir/src/gameevents.cpp.o
Building CXX object CMakeFiles/SC2Replay.dir/src/messageevents.cpp.o
[ 23%] [ 30%] Building CXX object CMakeFiles/SC2Replay.dir/src/mpq.cpp.o
Building CXX object CMakeFiles/SC2Replay.dir/src/replay.cpp.o
[ 38%] [ 46%] [ 53%] Building CXX object 
CMakeFiles/SC2Replay.dir/src/mpqimpl.cpp.o
Building CXX object CMakeFiles/SC2Replay.dir/src/info.cpp.o
Building CXX object CMakeFiles/SC2Replay.dir/src/syncevents.cpp.o
/home/jon301/work/webapps/starcraft2replay/src/mpqimpl.cpp: In member function 
‘const 
sc2replay::MPQFile* sc2replay::MPQArchiveImpl::getFile(const 
sc2replay::MPQArchive*, 
const std::string&) const’:
/home/jon301/work/webapps/starcraft2replay/src/mpqimpl.cpp:65: error: invalid 
conversion from ‘sc2replay::off_t*’ to ‘off_t*’
/home/jon301/work/webapps/starcraft2replay/src/mpqimpl.cpp:65: error:   
initializing 
argument 3 of ‘int32_t libmpq__file_unpacked_size(mpq_archive_s*, uint32_t, 
off_t*)’
make[2]: *** [CMakeFiles/SC2Replay.dir/src/mpqimpl.cpp.o] Erreur 1
make[2]: *** Attente des tâches non terminées....
make[1]: *** [CMakeFiles/SC2Replay.dir/all] Erreur 2
make: *** [all] Erreur 2

I commented the line 26 in inc/sc2replay/types.h :
typedef int64_t off_t;

I manage to compile but the replay parser fails :
~/work/webapps/starcraft2replay/build/tests  $ ./read_mpq 
../../tests/test.SC2Replay 
Error loading MPQ file ../../tests/test.SC2Replay.
Erreur de segmentation

Thank you for helping :p

Original comment by jon...@gmail.com on 19 Apr 2010 at 11:45

GoogleCodeExporter commented 9 years ago
Same problem in my 32-bit linux machine.I commented out the typdef for
off_t and compiled success, but then I also get  
Segmentation fault 

Original comment by kaixi...@gmail.com on 21 Apr 2010 at 4:57

GoogleCodeExporter commented 9 years ago
when i use stormlib to build the sc2parser, some errors occur with the 
libStorm.so:

Linking CXX executable extract_info_dump
Linking CXX executable extract_gameevents_dump
Linking CXX executable extract_messageevents_dump
Linking CXX executable extract_syncevents_dump
Linking CXX executable extract_map
/usr/local/lib/libStorm.so: undefined reference to `LzmaEncode'
/usr/local/lib/libStorm.so: undefined reference to 
`AddFileToArchive(TMPQArchive*,
void*, char const*, unsigned int, unsigned int, unsigned int, bool*)'
/usr/local/lib/libStorm.so: undefined reference to `CompressADPCM(unsigned 
char*,
int, short*, int, int, int)'
/usr/local/lib/libStorm.so: undefined reference to `DecompressADPCM(unsigned 
char*,
int, unsigned char*, int, int)'
/usr/local/lib/libStorm.so: undefined reference to `LzmaDecode'
/usr/local/lib/libStorm.so: undefined reference to `DecompressSparse(unsigned 
char*,
int*, unsigned char*, int)'
/usr/local/lib/libStorm.so: undefined reference to `LzmaEncProps_Init'
/usr/local/lib/libStorm.so: undefined reference to `CompressSparse(unsigned 
char*,
int*, unsigned char*, int)'

Original comment by kaixi...@gmail.com on 21 Apr 2010 at 6:15

GoogleCodeExporter commented 9 years ago
I suspect that the segfault is from libmpq.  I was trying to help out by 
testing with
stormlib, but don't see how to compile it and don't see any instructions either
inside the zip file or online.  Anybody have a hint on how to build that?

Original comment by bchecke...@gmail.com on 21 Apr 2010 at 12:52

GoogleCodeExporter commented 9 years ago
Would you mind logging to irc.rizon.net #nibbits ? that would be easier to fix 
this 
together

Original comment by vallee.aurelien on 21 Apr 2010 at 2:55

GoogleCodeExporter commented 9 years ago
I just commited a fix that would cause libmpq to crash on a segfault if the 
provided replay path does not exists.
This seems to be the problem that most of you had.

Original comment by vallee.aurelien on 21 Apr 2010 at 3:17

GoogleCodeExporter commented 9 years ago
Ok, after your fix I receive this message:
Error loading MPQ file test.SC2Replay.
Replay file does not exists or is invalid.
If you are using libmpq (default) this may randomly happen. Try to install 
StormLib 
(http://www.zezula.net/en/mpq/stormlib.html) and use the CMake option 
-DBUILD_LIBMPQ=OFF

I try many names for replay file, but anyone was working. So I tried install 
stormLib. In 
the zip file you suggest I start make in StormLib/stormlib folder and there was 
error with 
wave.o so I deleted wave.o in MakeFile and then it works. Also I downloaded 
ghost++ where is 
modified stormLib v5.0 which works also with wave.o. 

I modified CMAKELists where instead of FIND_LIBRARY( MPQLib NAMES StormLib) I 
used 
FIND_LIBRARY( MPQLib NAMES StormLib libStorm.so). So finally it found a 
library, however 
during compiling I get this error:

[ 53%] Building CXX object CMakeFiles/SC2Replay.dir/src/gameevents.cpp.o
In file included from /usr/include/c++/4.4/streambuf:796,
                 from /usr/include/c++/4.4/ios:44,
                 from /usr/include/c++/4.4/istream:40,
                 from /usr/include/c++/4.4/fstream:40,
                 from /home/mito/Desktop/starcraft2replay/src/mpqimpl.cpp:4:
/usr/include/c++/4.4/bits/streambuf.tcc: In member function ‘virtual 
std::streamsize 
std::basic_streambuf<_CharT, _Traits>::xsgetn(_CharT*, std::streamsize)’:
/usr/include/c++/4.4/bits/streambuf.tcc:54: error: expected unqualified-id 
before ‘(’ token
/usr/include/c++/4.4/bits/streambuf.tcc: In member function ‘virtual 
std::streamsize 
std::basic_streambuf<_CharT, _Traits>::xsputn(const _CharT*, 
std::streamsize)’:
/usr/include/c++/4.4/bits/streambuf.tcc:88: error: expected unqualified-id 
before ‘(’ token
In file included from /usr/include/c++/4.4/istream:830,
                 from /usr/include/c++/4.4/fstream:40,
                 from /home/mito/Desktop/starcraft2replay/src/mpqimpl.cpp:4:
/usr/include/c++/4.4/bits/istream.tcc: In member function ‘std::streamsize 
std::basic_istream<_CharT, _Traits>::readsome(_CharT*, std::streamsize)’:
/usr/include/c++/4.4/bits/istream.tcc:641: error: expected unqualified-id 
before ‘(’ token
In file included from /usr/include/c++/4.4/fstream:915,
                 from /home/mito/Desktop/starcraft2replay/src/mpqimpl.cpp:4:
/usr/include/c++/4.4/bits/fstream.tcc: In member function ‘virtual typename 
std::basic_filebuf<_CharT, _Traits>::int_type std::basic_filebuf<_CharT, 
_Traits>::underflow()’:
/usr/include/c++/4.4/bits/fstream.tcc:304: error: expected unqualified-id 
before ‘(’ token
/usr/include/c++/4.4/bits/fstream.tcc: In member function ‘virtual 
std::streamsize 
std::basic_filebuf<_CharT, _Traits>::xsputn(const _CharT*, std::streamsize)’:

- this is some crazy stuff with fstream - so I stopped here. 

Original comment by milutin....@gmail.com on 21 Apr 2010 at 5:35