edoren / STP

SFML TMX Parser -
edoren.github.io/STP
Other
30 stars 13 forks source link

How to use this in Ubuntu? #3

Closed ghost closed 10 years ago

ghost commented 10 years ago

Hi, I am using Ubuntu 14.04 and Code::Blocks. I am unsure how to include this library in my code. Can you add some more information to the Wiki? I have added

include "include/STP/TMXLoader.hpp"

and made a directory called STP containing the TMXLoader. (in my include dir) and the Core folder.... but I am missing something. I have only used libraries available on the system (SFML, Box2D, tinyxml, etc...) through the repositories up to this point.

So... the first thing that needs clarification is needing this compiler flag -std=c++11 I'm using GNU C++ compiler, and it tells me I need this.

Then, I get this error: /usr/bin/ld: obj/Debug/src/STP/Core/Parser.o||undefined reference to symbol 'inflateInit2_'|

Not sure quite what I am missing here, but I'd like to try your library out :)

ghost commented 10 years ago

Ok... so I found a clue in the Ubuntu system zlib (yes I changed things to use the system libraries)

/*
ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
                                     int  windowBits));
 comments edited out
*/

And later on...

ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int  windowBits,
                                      const char *version, int stream_size));

Which explains the error since it doesn't include the const char* version in Parser.cpp (52) (it is ZLIB_VERSION here below) or the stream_size?

#define inflateInit2(strm, windowBits) \
        inflateInit2_((strm), (windowBits), ZLIB_VERSION, \
                      (int)sizeof(z_stream))

So is this a bug in Ubuntu (a slightly misplaced /* ) library? Or is there some incompatibility with Linux that requires commenting that out? Or did I miss something else?

edoren commented 10 years ago

Yeah, sorry, I will add more documentation about how to setup in each OS as soon as I can.

The problem you got is because it needs the library zlib, in Ubuntu try installing it using the command sudo apt-get install zlib1g-dev and then run cmake, it will search for library in the system and link it.

ghost commented 10 years ago

I have version 1:1.2.8.dfsg-1ubuntu1 already installed maybe I forgot to link it, it was getting late, and I was linking in some box2d stuff... I will check again. Once I get it all set up, I might write something for your wiki if you like

ghost commented 10 years ago

Ah... I did forget to link it. So far what I need to link (when I changed the source to use the native libraries) is

/usr/lib/x86_64-linux-gnu/libz.a
/usr/lib/x86_64-linux-gnu/libz.so
/usr/lib/x86_64-linux-gnu/libpugixml.a
/usr/lib/x86_64-linux-gnu/libpugixml.so

I guess I was just tired :) and missed linking it up. Of course all the SFML stuff needs to be linked. And Code::Blocks links all of them in that I need except

/usr/lib/x86_64-linux-gnu/libsfml-audio.sp