LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-10-2012, 12:26 AM   #1
sanganesh
LQ Newbie
 
Registered: Jan 2012
Posts: 2

Rep: Reputation: Disabled
Unhappy compiler error


when compiling programs, I getting this error

/usr/bin/ld: cannot find -lncurses
collect2: ld returned 1 exit status
** Unable to rebuild library /appo1/bnk/bnk.run/lib/lib41.so.27 *
 
Old 01-10-2012, 12:48 AM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
You have not installed all the dependencies the software needs.

You must read the documentation that comes with the source code. Typically, you will find a list of software that must be installed to support the program you are trying to compile. That information can be found in the README, INSTALL, or other files at the top-level of the source directory. Also, the project's web page will likely tell you what pre-installed software is necessary.

The error is telling you that your machine does not have the ncurses library installed.

If you are using a Debian-based distribution, you should be able to install it by running (as root):
Code:
apt-get install libncurses5
If you are not using a Debian-based distribution, then you need to search for the name of the package that provides the ncurses libraries.

Be aware that you may need to install other dependencies after ncurses. That is why you need to read and understand the documentation.
 
Old 01-10-2012, 03:12 AM   #3
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Better : # apt-get install libncurses-dev

Or # yum install ncurses-devel ( If Fedora based OS.)

I.e. the "-devel" packages are required, when compiling.
 
Old 01-10-2012, 04:01 AM   #4
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
Quote:
Originally Posted by knudfl
I.e. the "-devel" packages are required, when compiling
Indeed.

I should clarify my response so that anyone that reads this isn't left with half the story (in a manner of speaking). The original error was:
Code:
/usr/bin/ld: cannot find -lncurses
This error is caused by the linker. Creating a binary executable requires roughly two stages: compiling and linking--in that sequence.

The "-devel" packages contain source code files useful for the compilation stage. The source code in the "-devel" packages identify what external support is available to the program (such as ncurses terminal-drawing capabilities).

The linking stage no longer relies on source code, but rather, connects the new program with pre-compiled libraries. The pre-compiled libraries contain the machine code instructions that actually provide the support the new program wanted.

When creating a new binary, you typically need both: the "-devel" packages associated with a support library and the library itself.

Because the error above was a linker problem, the compiling would seem to have finished without error. That said, there are instances where a compiler warning has caused one of my own compile jobs to fail at the linking stage.

Anyway, the moral of the story is: install both source/development packages (for the source code) and the libraries itself.

Last edited by Dark_Helmet; 01-10-2012 at 04:03 AM.
 
Old 01-10-2012, 05:36 AM   #5
sanganesh
LQ Newbie
 
Registered: Jan 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thanks for ur explanation Mr.Dark Helmet.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
checking for C compiler default output... configure: error: C compiler cannot create clubbing80s Linux - Software 3 07-05-2010 08:17 PM
error while installing unixODBC-2.2.14 on AIX 5.3 -configure: error: C compiler canno sriram_nittala AIX 0 01-20-2010 03:18 AM
checking for C compiler default output... configure: error: C compiler cannot create fiorejm Linux - Software 6 11-12-2009 12:35 PM
GCC compiler giving syntax error before 'double' error dragonmint Programming 2 06-02-2007 02:07 PM
in gcc compiler error: parse error before string constsnt cynthia_thomas Linux - Networking 1 10-20-2005 01:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration