Re: Error compiling GNU C++ project with -lz option

  • From: Alexander Simon < >
  • To:
  • Cc: ifxbr < >
  • Subject: Re: Error compiling GNU C++ project with -lz option
  • Date: Tue, 26 Jun 2012 11:49:11 +0400

On 06/25/12 19:14, ifxbr wrote:
Hi all,

I'm working on a C++ project that uses Zlib to compress strings before send 
it through TCP socket in order to save network bandwidth.

Everything is fine with my code, but when I try to compile and make my 
project, I receive an error from GNU C++ compiler that says:

c++ -lz    -o dist/Release/GNU-Linux-x86/compress 
build/Release/GNU-Linux-x86/main.o: In function `compress_string(std::basic_string<char, 
std::char_traits<char>, std::allocator<char>  >  const&, int)':
main.cpp:(.text+0x56): undefined reference to `deflateInit_'
main.cpp:(.text+0xaa): undefined reference to `deflate'
main.cpp:(.text+0xda): undefined reference to `deflateEnd'
build/Release/GNU-Linux-x86/main.o: In function `decompress_string(std::basic_string<char, 
std::char_traits<char>, std::allocator<char>  >  const&)':
main.cpp:(.text+0x2bb): undefined reference to `inflateInit_'
main.cpp:(.text+0x312): undefined reference to `inflate'
main.cpp:(.text+0x342): undefined referec++ -lz    -o 
dist/Release/GNU-Linux-x86/compress build/Release/GNU-Linux-x86/main.o  nce 
to `inflateEnd'
collect2: ld returned 1 exit status
make[2]: *** [dist/Release/GNU-Linux-x86/compress] Error 1
make[2]: Leaving directory `/home/sinteck/compress'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/home/sinteck/compress'
make: *** [.build-impl] Error 2

As I am using Zlib on my project, I used the -lz aditional option to my C++ 
compiler, but the error persist.

So I tried to run the command manually, with the option -ls at the end of 
command, as such:

c++ -o dist/Release/GNU-Linux-x86/compress build/Release/GNU-Linux-x86/main.o 

and now the compilation ends with success.

So, how can I set the -lz aditional option on Netbeans 7.1.2 ?
Please help!

Hi ifxbr,

Did you try to specify "-lz" library in "Project Properties->Linker->Libraries->Add Options->Other Options"?


Error compiling GNU C++ project with -lz option

ifxbr 06/25/2012

Re: Error compiling GNU C++ project with -lz option

Alexander Simon 06/26/2012

Error compiling GNU C++ project with -lz option

ifxbr 06/26/2012

Project Features

About this Project

CND was started in November 2009, is owned by DimaZh, and has 187 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20160708.bf2ac18). © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
Please Confirm