public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* gcc library and linker documentation
@ 2003-12-15 12:28 Joseph Jolic
  2003-12-15 16:01 ` Eljay Love-Jensen
  2003-12-15 17:10 ` Torsten Reuss
  0 siblings, 2 replies; 5+ messages in thread
From: Joseph Jolic @ 2003-12-15 12:28 UTC (permalink / raw)
  To: gcc-help; +Cc: josephjolic

Hi
I am a beginner with gcc and am having difficulty finding certain information 
on programming with gcc, such as:

-how to search and get relevant documentation for using certain functions

-I'm unclear as to when I would need to use the L option to specify libraries 
on the command line.  I'm used to specifying libraries through #include 
statements only.

Do you know of any tutorials on the internet that would cover these kinds of 
fundamentals.

Thank you.

Joseph Jolic

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: gcc library and linker documentation
  2003-12-15 12:28 gcc library and linker documentation Joseph Jolic
@ 2003-12-15 16:01 ` Eljay Love-Jensen
  2003-12-15 16:48   ` Justin Findlay
  2003-12-15 17:10 ` Torsten Reuss
  1 sibling, 1 reply; 5+ messages in thread
From: Eljay Love-Jensen @ 2003-12-15 16:01 UTC (permalink / raw)
  To: Joseph Jolic, gcc-help; +Cc: josephjolic

Hi Joseph,

>how to search and get relevant documentation for using certain functions

Stroustrup's C++ Programming Language (3rd ed or Special ed).

Cline, Lomow, Girou's C++ FAQs (2nd ed).

>I'm unclear as to when I would need to use the L option to specify libraries 
on the command line.

The -L option is used to specify the path which libraries are located.  For instance, if you had some libraries at ~jolic/3party/hotdog you could specify -L~jolic/3party/hotdog and GCC would use that path location to resolve the -lhotdog library.

Without the -L~jolic/3party/hotdog, GCC wouldn't know to check in that location for libhotdog.so or libhotdog.a.

>Do you know of any tutorials on the internet that would cover these kinds of  fundamentals.

<http://gcc.gnu.org/onlinedocs/>

HTH,
--Eljay


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: gcc library and linker documentation
  2003-12-15 16:01 ` Eljay Love-Jensen
@ 2003-12-15 16:48   ` Justin Findlay
  2003-12-15 17:34     ` Oliver Lange
  0 siblings, 1 reply; 5+ messages in thread
From: Justin Findlay @ 2003-12-15 16:48 UTC (permalink / raw)
  To: Eljay Love-Jensen; +Cc: Joseph Jolic, gcc-help, josephjolic

On Mon, 15 Dec 2003, Eljay Love-Jensen wrote:

> Hi Joseph,
> 
> >how to search and get relevant documentation for using certain functions
> 
> Stroustrup's C++ Programming Language (3rd ed or Special ed).
> 
> Cline, Lomow, Girou's C++ FAQs (2nd ed).

http://www.cplusplus.com
http://www.sgi.com/tech/stl/
//although the STL documented is a little older than the ANSI/ISO C++
//standard
/*MSDN also has some instructive pedagogical examples*/

> >I'm unclear as to when I would need to use the L option to specify libraries 
> on the command line.
> 
> The -L option is used to specify the path which libraries are located.  For instance, if you had some libraries at ~jolic/3party/hotdog you could specify -L~jolic/3party/hotdog and GCC would use that path location to resolve the -lhotdog library.
> 
> Without the -L~jolic/3party/hotdog, GCC wouldn't know to check in that location for libhotdog.so or libhotdog.a.
> 
> >Do you know of any tutorials on the internet that would cover these kinds of  fundamentals.
> 
> <http://gcc.gnu.org/onlinedocs/>


Justin

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: gcc library and linker documentation
  2003-12-15 12:28 gcc library and linker documentation Joseph Jolic
  2003-12-15 16:01 ` Eljay Love-Jensen
@ 2003-12-15 17:10 ` Torsten Reuss
  1 sibling, 0 replies; 5+ messages in thread
From: Torsten Reuss @ 2003-12-15 17:10 UTC (permalink / raw)
  To: Joseph Jolic; +Cc: gcc-help, josephjolic

> Hi
> I am a beginner with gcc and am having difficulty finding certain
> information 
> on programming with gcc, such as:
> 
> -how to search and get relevant documentation for using certain functions

O'Reilly's "Programming with GNU Software" might be good choicd for you. It
handles not only gcc and g++ but also the related tools like gdp and gprof.

That's not an internet tutorial, alright.

> -I'm unclear as to when I would need to use the L option to specify
> libraries 
> on the command line.  I'm used to specifying libraries through #include 
> statements only.

What's generally refered to as libraries, typically consists of two parts:
The header files and the library itself. Header files are what you include
into your C source code by using #include. The library is later either
statically or dynamically linked to your program.

Example 1: You are doing a string comparisn in your C program.
In your source code you will have #include<strings.h> which tells the
compiler that it should read the function declarations in that header file.  So if
you call strcmp somewhere in your program, the compiler will actually know
what you want to do and if you are calling the function correctly (i.e. with
two arguments of type <char *>). The include file is in /usr/include, a
standard path which you don't have to specify. The implementation of strcmp is in
the standard C library (libc). As all C programs are linked against this
library, you don't have to tell the compiler.

So gcc -c -o hello.o hello.c will successfully compile your program
gcc -o hello hello.o will successfully link it.
The resulting program hello will be linked against the standard C library.
If you don't believe me and you are using Linux, BSD or Solaris you can verfy
by issuing the command ldd hello.

Example 2: You have compiled yourself the libz library in your home
directory, so that the include files are now located in /home/joseph/include and the
library is in /home/joseph/lib. You can write your C program just the same
and have the line #include <zlib.h> in your source code. But now you have to
tell the compiler when compiling where to additionally look for include files,
which is the -I option
gcc -c -I/home/joseph/include -o hello.o hello.c will compile it without
problem.
Linking is the same, but you need to tell the compiler two things: What
library to additionally link against, and where they are. That's the -l and -L
option
gcc -L/home/joseph/lib -lz -o hello hello.o

(Note that "z" is the name of the library without the lib and without any .a
or .so suffix).

I hope this will get you further. Regards,

                               Torsten

-- 
+++ GMX - die erste Adresse für Mail, Message, More +++
Neu: Preissenkung für MMS und FreeMMS! http://www.gmx.net


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: gcc library and linker documentation
  2003-12-15 16:48   ` Justin Findlay
@ 2003-12-15 17:34     ` Oliver Lange
  0 siblings, 0 replies; 5+ messages in thread
From: Oliver Lange @ 2003-12-15 17:34 UTC (permalink / raw)
  To: gcc-help

>>
>>>how to search and get relevant documentation for using certain functions
>>

what about:

man fopen
man malloc

...

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-12-15 17:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-15 12:28 gcc library and linker documentation Joseph Jolic
2003-12-15 16:01 ` Eljay Love-Jensen
2003-12-15 16:48   ` Justin Findlay
2003-12-15 17:34     ` Oliver Lange
2003-12-15 17:10 ` Torsten Reuss

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).