Installed ncurses, now how do I get my app to use it?

Ryan Schmidt ryandesign at macports.org
Sat Apr 26 17:04:55 PDT 2008


On Apr 26, 2008, at 6:52 PM, Timur Tabi wrote:

> Ryan Schmidt wrote:
>
>> Try adding -I/opt/local/include to your CPPFLAGS and -L/opt/local/ 
>> lib to your LDFLAGS.
>
> That didn't work.  If I try to set CFLAGS directly, the Makefile  
> complains that I'm changing CFLAGS.
>
> Here's the code that checks:
>
> # Check if we can link to ncurses
> check() {
>         echo -e " #include CURSES_LOC \n main() {}" |
>             $cc -xc - -o $tmp 2> /dev/null
>         if [ $? != 0 ]; then
>             echo " *** Unable to find the ncurses libraries or  
> the"    1>&2
>
> Adding the -I and -L to the $cc line didn't work either.  $cc is  
> equal to this:
>
> gcc -DCURSES_LOC=<ncurses.h> -DLOCALE -DKBUILD_NO_NLS -lncurses
>
> It looks like it found ncurses.h but not the library.  This is what  
> I have in /opt/local/lib/libncurses*:
>
>    ls /opt/local/lib/libncurses*
> /opt/local/lib/libncurses++.a		/opt/local/lib/libncurses.dylib
> /opt/local/lib/libncurses++w.a		/opt/local/lib/libncursesw.5.dylib
> /opt/local/lib/libncurses.5.dylib	/opt/local/lib/libncursesw.a
> /opt/local/lib/libncurses.a		/opt/local/lib/libncursesw.dylib
>
>
> My question is more broad than this specific case.  Since macports  
> installs all these libraries and header files in nonstandard  
> locations, they can't be found by any Makefile.  No matter what I'm  
> building, I would need to modify the Makefile in order to get it to  
> work.
>
> This seems contrary to the purpose behind MacPorts, which is  
> supposed to make it easy to install this kind of software.  But if  
> the installed applications, header files, and libraries are  
> sequestered into an obscure path, then nothing will find them!   
> There's got to be some easy way to add these paths so that they'll  
> always be picked up, isn't there?

The purpose of MacPorts is mainly to make it easy to install software  
using MacPorts. Installing other software manually in another prefix  
that links with libraries installed by MacPorts is not necessarily a  
goal of the MacPorts project, but it's certainly not discouraged and  
it should be possible.

The way MacPorts manages to get most ports to recognize most other  
installed ports is by adding -I/opt/local/include to the CPPFLAGS and  
-L/opt/local/lib to the LDFLAGS. This works in a majority of cases.  
If that is not sufficient for the software you're building, then  
maybe the configure script of the software you're building has an  
option like --with-ncurses=DIR where you could specify --with- 
ncurses=/opt/local. If not, you may need to talk with the developers  
of the software you're trying to build and ask them how they want you  
to tell it where ncurses is located.



More information about the macports-users mailing list