From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24927 invoked by alias); 29 Jun 2005 20:15:16 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 24900 invoked by uid 22791); 29 Jun 2005 20:15:11 -0000 Received: from zproxy.gmail.com (HELO zproxy.gmail.com) (64.233.162.194) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Wed, 29 Jun 2005 20:15:11 +0000 Received: by zproxy.gmail.com with SMTP id m22so475818nzf for ; Wed, 29 Jun 2005 13:15:10 -0700 (PDT) Received: by 10.36.158.10 with SMTP id g10mr7100608nze; Wed, 29 Jun 2005 13:15:09 -0700 (PDT) Received: by 10.36.55.17 with HTTP; Wed, 29 Jun 2005 13:15:09 -0700 (PDT) Message-ID: <4a618d080506291315447adeba@mail.gmail.com> Date: Wed, 29 Jun 2005 20:15:00 -0000 From: Arturas Moskvinas Reply-To: Arturas Moskvinas To: Angel Tsankov Subject: Re: Passing names of libraries to linker. Cc: gcc-help mailing list In-Reply-To: <4a618d0805062913006d93422a@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <001101c57cd9$92459bb0$cf34000a@sven> <4a618d0805062913006d93422a@mail.gmail.com> X-SW-Source: 2005-06/txt/msg00209.txt.bz2 > > MS C++ compiler supports a > > > > #pragma comment(lib, "library.lib") > > > > directve, that causes the compiler to pass the quoted file name to the > > linker. The linker is expected to add this file name to the list of > > libraries to be searched for external symbols. Is there a similar mecha= nism > > in gcc/g++? Maybe some short "introduction".=20 When you compile file, gcc (gcc -c some.c -o some.o) (-c option means compile file but do not link) makes object file, eg. some.o. If you want to compile another file and link it with some.o. Then you can w= rite: gcc another.c some.o gcc will automatically compile another.c, and pass those two files (object file of another.c and some.o) to linker. >From manual: The only difference between using an -l option and specifying a file (my example) name is that -l surrounds "library" with `lib' and `.a' and searches several directories. (eg.: gcc -llibrary means find file named liblibrary.a and link with it, the same goes with dynamic libraries...) Arturas Moskvinas P.S.: if you will compile C++ program, do not use "gcc file.cpp" (or file.cc)(it will complain about linking problems...), use gcc-c++: "c++ file.cpp".