On Fri, 23 Feb 2007, Gareth Brown wrote:

> I've been racking my head for hours trying to compile PDCurses programs 
> on my Mac OS X installation, and Linux.  I'm in a dire need of help.  
> What I'm trying todo is compile the demos included separately using the 
> following;
> 
> $ gcc firework.c -lpdcurses -o firework
> 
> and get the following error;
> 
> /usr/bin/ld: can't locate file for: -lpdcurses
> collect2: ld returned 1 exit status

The "-l" option tells gcc, "take the following name, munge it in a system- 
specific way, and search the library path for the name". In Linux, it will 
prefix the name with "lib", and suffix it with ".so" or ".a"; in other 
words, it will look for the files "libpdcurses.so" and "libpdcurses.a". In 
Mac OS X, the suffix for shared libraries is ".dylib" instead of ".so".

So, have you got one of those files in your library path? Probably not. 
For one thing, the X11 version of PDCurses (which is what you have in 
Linux or Mac OS X), for historic reasons, is built with the name "XCurses" 
by default. The corresponding option would thus be "-lXCurses" rather than 
"-lpdcurses". You could change it to "pdcurses"; but if you had, you'd 
know it.

Secondly, you don't have it in your library path unless you've installed 
it there. That would mean you either ran "make install" (or perhaps "sudo 
make install"), with no errors, or else manually copied it to an 
appropriate place.

Now, "make install" doesn't work correctly in Mac OS X, because make sees 
the file "INSTALL" and thinks it satisfies the rule. This only happens in 
Mac OS X (and not Linux or other *nix), because of its case-preserving but 
non-case-sensistive file system. (Fixed in PDCurses CVS. You can fix it by 
adding a second colon after "install:" in the Makefile.)

You can also specify the full pathname to the library file directly. In 
that case, you don't use "-l".

Example -- if it's installed:

 gcc -ofirework firework.c -lXCurses

If it's not installed:

 gcc -ofirework firework.c ../pdcurses/libXCurses.a

> I'm completely stuck, should I put a file in /usr/bin/ld ?

/usr/bin/ld is the name of the linker executable, not a directory.

-- 
William McBrine <[EMAIL PROTECTED]>

Reply via email to