From owner-freebsd-questions@FreeBSD.ORG Fri Mar 21 22:37:06 2008 Return-Path: Delivered-To: FreeBSD-questions@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CC0C5106566B for ; Fri, 21 Mar 2008 22:37:06 +0000 (UTC) (envelope-from chuckr@chuckr.org) Received: from mail5.sea5.speakeasy.net (mail5.sea5.speakeasy.net [69.17.117.7]) by mx1.freebsd.org (Postfix) with ESMTP id 99C198FC15 for ; Fri, 21 Mar 2008 22:37:05 +0000 (UTC) (envelope-from chuckr@chuckr.org) Received: (qmail 14646 invoked from network); 21 Mar 2008 22:37:05 -0000 Received: from april.chuckr.org (chuckr@[66.92.151.30]) (envelope-sender ) by mail5.sea5.speakeasy.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP for ; 21 Mar 2008 22:37:05 -0000 Message-ID: <47E4375A.9090607@chuckr.org> Date: Fri, 21 Mar 2008 18:31:54 -0400 From: Chuck Robey User-Agent: Thunderbird 2.0.0.6 (X11/20071107) MIME-Version: 1.0 To: mdh References: <12987.84776.qm@web56809.mail.re3.yahoo.com> In-Reply-To: <12987.84776.qm@web56809.mail.re3.yahoo.com> X-Enigmail-Version: 0.95.5 OpenPGP: id=F3DCA0E9; url=http://pgp.mit.edu Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Eduardo Cerejo , FreeBSD-questions@FreeBSD.org Subject: Re: How do I add search paths to gcc X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Mar 2008 22:37:06 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 mdh wrote: > --- Eduardo Cerejo wrote: > >> My gcc is only looking in /usr/lib and /usr/include >> for libraries and hearders and I added the paths >> /usr/local/lib/ and /usr/local/include to my .cshrc >> file: >> >> set path = (/sbin /bin /usr/sbin /usr/bin /usr/games >> /usr/local/sbin /usr/local/bin /usr/local/lib >> /usr/local/include $HOME/bin) > > PATH in the environment is where your shell searches > for programs to run from the command line, system(), > etc. This allows you to type, say, `sh` instead of > having to type out `/bin/sh` or risking having > `/home/somekiddie/sh` run instead when you type it. > >> but I still have to use gcc with -I and -L switch >> for a program to compile or else it will fail. >> >> I'm using tcsh. > > There are two ways to set up alternate places to find > libraries. The first is ldconfig, and you can see > ports run this when you install a port containing > shared libraries for example. The other is to use the > LD_LIBRARY_PATH environment variable to set alternate > paths at run-time. > Well, that might be taken as confusing, even though your info is technically quite correct. Both those methods WILL get those added dirs searched for loading the libraries at run time, BUT it will NOT get your compiler to find the new paths, when linking the program during the build. I'm fairly sure that's what the person wanted, don't you think so? Because, if I'm wrong, you can delete this email right here and now, read no more. BUT you were quite correct, there are definitely *at least* two methods to set up your *compiler* library search paths. In fact, I think I can show you 3 methods right now. First, you can list the full path of the library on the command line, when you use your compiler to link your program. ] Second, you can (as the person suggested himself) you can use the -l/-L options to bring in libraries & paths. The -L should come first, it adds the path, and the -l afterwards adds the specific library. The 3rd method is the use the variables LDFLAGS and LDADD. These variables are NOT 100% reliable to use, although they are fairly reliable on BSD systems. The LDFLAGS is where you put your "-LExtraPath" and the LDADD is where you stick the -lExtraLibrary, like this (from a Makefile example): LDFLAGS+=-L/usr/local LDFLAGS+=-lgtk If you are using the BSD make util, the you use "+=" to add to your variables, instead of replacing them, in case they had some values in them to begin with. "Make" automatically adds in the obvious spaces, so your definitions don't have a train wreck for you. > The 'ldconfig(1)' man page has more info for you. > > Take care, mdh > > > > ____________________________________________________________________________________ > Looking for last minute shopping deals? > Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4 (FreeBSD) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFH5Ddaz62J6PPcoOkRAheZAKCFZGYrN4rx4GvuCUvvAeIIR5lvjQCeMfy/ rlsk+UF3+WKwh1676scYGOI= =MMpk -----END PGP SIGNATURE-----