Hello,
I'm learning C++ and trying to build my own file zipper, because i like very much to work with zip files, but now i want to build my own zipper and it's so hard to find good resources to start. As you can see in my previous posts i was trying to correct the only code snippet that i've founded in Google, but it's getting so much errors.

Then the only thing that i want is a very good snippet to start my zipper, remember that i want to build a zipper, not an unzipper.

Thanks,
Nathan Paulino Campos

Recommended Answers

All 6 Replies

As you can see in my previous posts i was trying to correct the only code snippet that i've founded in Google, but it's getting so much errors.

I was able to build with no errors the code you posted. My IDE hides the feeding of the linker, but I think I got it to go from the command line with (pretty much as was discussed here):

g++ -IB:/Tools/Zlib/include mainpp.cpp -LB:/Tools/Zlib/lib -lzlib

You may want to simplify your test driver:

int main(int argc, char* argv[])
{
   std::string allinput("All work and no play makes Jack a dull boy.");
   std::string cstr = compress_string( allinput );
   std::cerr << "Deflated data: "
      << allinput.size() << " -> " << cstr.size()
      << " (" << std::setprecision(1) << std::fixed
      << ( (1.0 - (float)cstr.size() / (float)allinput.size()) * 100.0)
      << "% saved).\n";
   std::cout << cstr;
}

Deflated data: 43 -> 49 (-14.0% saved).
xÚsÌÉQ(Ï/ÊVHÌKQÈËW(ÈI¬TÈMÌN-VðJL

See here my console log:

ubuntu@eeepc:~$ g++ -IB:/home/ubuntu/.zlib/include comp.cpp -LB:/home/ubuntu/.zlib/lib -llibz
/usr/bin/ld: cannot find -llibz
collect2: ld returned 1 exit status
ubuntu@eeepc:~$

And if i try zlib:

ubuntu@eeepc:~$ g++ -IB:/home/ubuntu/.zlib/include comp.cpp -LB:/home/ubuntu/.zlib/lib -lzlib
/usr/bin/ld: cannot find -lzlib
collect2: ld returned 1 exit status
ubuntu@eeepc:~$

I tryed this two modes, because the lib file name is libz.a

Only one question more: You can compile this in your compiler?

Thanks,
Nathan Paulino Campos

See here my console log:

ubuntu@eeepc:~$ g++ -IB:/home/ubuntu/.zlib/include comp.cpp -LB:/home/ubuntu/.zlib/lib -llibz
/usr/bin/ld: cannot find -llibz
collect2: ld returned 1 exit status
ubuntu@eeepc:~$

And if i try zlib:

ubuntu@eeepc:~$ g++ -IB:/home/ubuntu/.zlib/include comp.cpp -LB:/home/ubuntu/.zlib/lib -lzlib
/usr/bin/ld: cannot find -lzlib
collect2: ld returned 1 exit status
ubuntu@eeepc:~$

I tryed this two modes, because the lib file name is libz.a

You installed zlib on B: drive too?

Only one question more: You can compile this in your compiler?

Compile, link, run: yes.

Thanks very much!!!!!!!!

i am getting
error: ‘compress_string’ was not declared in this scope

program is after including required header files is

#include<string>
#include <iostream>
#include <iomanip>
int main(int argc, char* argv[])

{

std::string allinput("All work and no play makes Jack a dull boy.");

std::string cstr = compress_string( allinput );

std::cerr << "Deflated data: "

<< allinput.size() << " -> " << cstr.size()

<< " (" << std::setprecision(1) << std::fixed

<< ( (1.0 - (float)cstr.size() / (float)allinput.size()) * 100.0)

<< "% saved).\n";

std::cout << cstr;

}

i am getting
error: ‘compress_string’ was not declared in this scope

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.