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
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 
-lz

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"?

Alexander



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 Leonid Lenyashin, and has 130 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close