SFML community forums

Help => System => Topic started by: KraXarN on July 25, 2016, 06:35:29 pm

Title: InputStream issue
Post by: KraXarN on July 25, 2016, 06:35:29 pm
Hello!

So, I want to load files from a zip file. I tried following the example from http://www.sfml-dev.org/documentation/2.3.2/classsf_1_1InputStream.php (http://www.sfml-dev.org/documentation/2.3.2/classsf_1_1InputStream.php), but I ran into multiple issues. Firstly, Int64 isn't a thing, but that was probably because it was missing sf::Int64, but when compiling, I get this error now instead when attempting to call "ZipStream stream("data.zip")"
undefined reference to `ZipStream::ZipStream(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
and
undefined reference to `vtable for ZipStream'
for the class

Thanks!
Title: Re: InputStream issue
Post by: Hiura on July 25, 2016, 07:15:36 pm
The ZipStream example is incomplete; so my guess is that you didn't implement it or you forgot to link your implementation file with the rest of your code.

EDIT: negation was missing
Title: Re: InputStream issue
Post by: KraXarN on July 25, 2016, 07:23:26 pm
The ZipStream example is incomplete; so my guess is that you did implement it or you forgot to link your implementation file with the rest of your code.

I also tried following the tutorial on user data streams, but it doesn't explain much more. I included the file where the class is, do I need to do more?
Title: Re: InputStream issue
Post by: eXpl0it3r on July 25, 2016, 08:06:54 pm
What's your code?
Title: Re: InputStream issue
Post by: KraXarN on July 25, 2016, 10:41:06 pm
What's your code?

Just straight from the example pretty much

class ZipStream : public sf::InputStream
{
    public:
        ZipStream(string archive);
        bool openFile(string archive);
        bool open(string filename);
        sf::Int64 read(void* data, sf::Int64 size);
        sf::Int64 seek(sf::Int64 position);
        sf::Int64 tell();
        sf::Int64 getSize();
};

And then I call it from my main cpp file with

ZipStream stream("data.zip");
Title: Re: InputStream issue
Post by: eXpl0it3r on July 25, 2016, 10:57:26 pm
And where's the implementation of the function?
Title: Re: InputStream issue
Post by: KraXarN on July 26, 2016, 02:49:29 am
And where's the implementation of the function?

What do you mean? Where I have that code? That code is in the main cpp file outside of main and call it inside of the main
Title: Re: InputStream issue
Post by: Hapax on July 26, 2016, 02:57:42 am
And where's the implementation of the function?
That code is in the main cpp file outside of main
Can you show this implementation?

I tried following the example from http://www.sfml-dev.org/documentation/2.3.2/classsf_1_1InputStream.php (http://www.sfml-dev.org/documentation/2.3.2/classsf_1_1InputStream.php)
[...]
Firstly, Int64 isn't a thing, but that was probably because it was missing sf::Int64
This documentation should be updated to use the full sf::Int64 typename as external implementations will be not be inside the sf namespace.
Title: Re: InputStream issue
Post by: KraXarN on July 26, 2016, 03:08:57 am
And where's the implementation of the function?
That code is in the main cpp file outside of main
Can you show this implementation?

The code I have is the code I posted before
Title: Re: InputStream issue
Post by: Hiura on July 26, 2016, 08:21:54 am
Please, don't take this the wrong way, but you clearly need to review your C++ bases... If you don't know what an implementation is from a definition, you will not go anywhere. :-/

Take the time to learn how C++ really works before starting using libraries, especially if they require you to have advanced knowledge.
Title: Re: InputStream issue
Post by: KraXarN on July 28, 2016, 06:34:44 pm
Please, don't take this the wrong way, but you clearly need to review your C++ bases... If you don't know what an implementation is from a definition, you will not go anywhere. :-/

Take the time to learn how C++ really works before starting using libraries, especially if they require you to have advanced knowledge.

I'm fairly new to C++ so, but I can't find any sort of information of where I can read more about this...
Title: AW: InputStream issue
Post by: eXpl0it3r on July 28, 2016, 06:58:53 pm
Any C++ book/resource that talk about classes. You may even Google what the difference is between class definition (aka implementation) and class declaration.