* start learning gcc ... how to ?
@ 2002-04-09 11:50 fox
2002-04-09 13:04 ` Miguel Griffa
0 siblings, 1 reply; 6+ messages in thread
From: fox @ 2002-04-09 11:50 UTC (permalink / raw)
To: linux-c-programming
Hi...
I'm newbie here...:)(also newbie in Linux)
I know a little about C/C++ programming (in DOS) and now I want to
learn about GCC, where I can find some (good) tutorials about it (urls
please)?
may be I need some example for compiling (and debugging) with
gcc...because gcc's option too many and it's not simple I think.
And, also, where I can find some good tutorials about using KDevelop ?
thank you...
--
Best regards,
adwin
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: start learning gcc ... how to ?
2002-04-09 11:50 start learning gcc ... how to ? fox
@ 2002-04-09 13:04 ` Miguel Griffa
2002-04-09 16:01 ` Re[2]: " adwin
0 siblings, 1 reply; 6+ messages in thread
From: Miguel Griffa @ 2002-04-09 13:04 UTC (permalink / raw)
To: fox; +Cc: linux-c-programming
[-- Attachment #1: Type: text/plain, Size: 1145 bytes --]
Hi,
gcc has lots of options, but theses are (almost) all I've needed:
-Wall (Warnings:ALL)
-g (generate debug info)
-ggdb (idem but with gdb extensions)
-o (output to file)
-c (compile only, don't link for makeing .o)
-ansi (kindda obvious)
Well, I know is little but it might help you to start
I'd strongly recomend you reading a make tutorial
On Tue, Apr 09, 2002 at 06:50:05PM +0700, fox@sby.centrin.net.id wrote:
> Hi...
>
> I'm newbie here...:)(also newbie in Linux)
> I know a little about C/C++ programming (in DOS) and now I want to
> learn about GCC, where I can find some (good) tutorials about it (urls
> please)?
> may be I need some example for compiling (and debugging) with
> gcc...because gcc's option too many and it's not simple I think.
>
> And, also, where I can find some good tutorials about using KDevelop ?
>
> thank you...
>
> --
> Best regards,
> adwin
> -
> To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re[2]: start learning gcc ... how to ?
2002-04-09 13:04 ` Miguel Griffa
@ 2002-04-09 16:01 ` adwin
2002-04-09 16:34 ` Elias Athanasopoulos
2002-04-09 22:09 ` Re[2]: " Glynn Clements
0 siblings, 2 replies; 6+ messages in thread
From: adwin @ 2002-04-09 16:01 UTC (permalink / raw)
To: linux-c-programming
MG> Hi,
MG> gcc has lots of options, but theses are (almost) all I've needed:
MG> -Wall (Warnings:ALL)
MG> -g (generate debug info)
MG> -ggdb (idem but with gdb extensions)
MG> -o (output to file)
MG> -c (compile only, don't link for makeing .o)
MG> -ansi (kindda obvious)
MG> Well, I know is little but it might help you to start
how about with -l option ? (for library). I still don't understand
when I have to use this option and when I don't need to use it.
for example for compiling program that use math.h,it need -lm and when
you create a program with QT library you need to use -lqt and -lglut
for opengl etc etc ...
MG> I'd strongly recomend you reading a make tutorial
do you mean gnu automake and autoconf tutorial ?
is there any IDE like Borland Turbo C++ ?
or may be how to use KDevelop ?
--
Best regards,
adwin
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: start learning gcc ... how to ?
2002-04-09 16:01 ` Re[2]: " adwin
@ 2002-04-09 16:34 ` Elias Athanasopoulos
[not found] ` <1018533665.9524.5.camel@abodh.lan.deeproot.co.in>
2002-04-09 22:09 ` Re[2]: " Glynn Clements
1 sibling, 1 reply; 6+ messages in thread
From: Elias Athanasopoulos @ 2002-04-09 16:34 UTC (permalink / raw)
To: adwin; +Cc: linux-c-programming
On Tue, Apr 09, 2002 at 11:01:18PM +0700, adwin wrote:
> how about with -l option ? (for library). I still don't understand
> when I have to use this option and when I don't need to use it.
When your program uses functions that someone else has implemented
for you, then you have to link the appropriate shared libraries. This
can happen either statically, either dynamically. Libraries contain
code that can be called from other programs. This is a great feature
and help us to avoid duplicating our code.
By default, gcc links to your code the libc (standard C library). Libc
contains the well known functions such as printf(), scanf(), etc. The
-l switch informs the linker to perform further linking and attach
to your source the code that is embeded in the libraries, which are
listed after the switch.
> is there any IDE like Borland Turbo C++ ?
> or may be how to use KDevelop ?
KDevelop helps for KDE (or plain Qt) apps. Glade is a form designer
for GTK+ apps. Adjusta is a full IDE for Gnome/GTK+ apps.
Elias
--
http://gnewtellium.sourceforge.net MP3 is not a crime.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Re[2]: start learning gcc ... how to ?
2002-04-09 16:01 ` Re[2]: " adwin
2002-04-09 16:34 ` Elias Athanasopoulos
@ 2002-04-09 22:09 ` Glynn Clements
1 sibling, 0 replies; 6+ messages in thread
From: Glynn Clements @ 2002-04-09 22:09 UTC (permalink / raw)
To: adwin; +Cc: linux-c-programming
adwin wrote:
> MG> gcc has lots of options, but theses are (almost) all I've needed:
> MG> -Wall (Warnings:ALL)
> MG> -g (generate debug info)
> MG> -ggdb (idem but with gdb extensions)
> MG> -o (output to file)
> MG> -c (compile only, don't link for makeing .o)
> MG> -ansi (kindda obvious)
> MG> Well, I know is little but it might help you to start
>
> how about with -l option ? (for library). I still don't understand
> when I have to use this option and when I don't need to use it.
> for example for compiling program that use math.h,it need -lm and when
> you create a program with QT library you need to use -lqt and -lglut
> for opengl etc etc ...
If you use functions from a particular library, you use -l to specify
that library. However, "gcc" includes "-lc" automatically, and "g++"
includes "-lc -lstdc++" automatically.
The argument to "-l" is the name of the library, without the "lib"
prefix or any suffixes. E.g. "-lX11" will link against libX11.so
(shared library) or libX11.a (static library). If the library isn't in
a standard directory (/lib or /usr/lib), you also need to specify the
directory with "-L" (e.g. "-L/usr/X11R6/lib" for X libraries).
> MG> I'd strongly recomend you reading a make tutorial
>
> do you mean gnu automake and autoconf tutorial ?
No, he means a tutorial for "make". This is the program which is
normally used to control compilation. If you are building a program
from multiple source files, you don't want to type lots of "gcc"
commands manually. See "info make" (or, if you are using Emacs,
"C-h C-i make RET").
--
Glynn Clements <glynn.clements@virgin.net>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: start learning gcc ... how to ?
[not found] ` <1018533665.9524.5.camel@abodh.lan.deeproot.co.in>
@ 2002-04-12 9:22 ` Elias Athanasopoulos
0 siblings, 0 replies; 6+ messages in thread
From: Elias Athanasopoulos @ 2002-04-12 9:22 UTC (permalink / raw)
To: sushmita roy; +Cc: linux-c-programming
On Thu, Apr 11, 2002 at 07:31:05PM +0530, sushmita roy wrote:
> On Tue, 2002-04-09 at 22:04, Elias Athanasopoulos wrote:
>
> > When your program uses functions that someone else has implemented
> > for you, then you have to link the appropriate shared libraries. This
> > can happen either statically, either dynamically.
>
> Can anyone please highlight on the fact as how do we link libraries
> statically or dynamically...
> what's the difference exactly???
> i usually compile my programs like -
>
> gcc sys_monitor.c -lcgic -lflate -L(specify the path here).. -o
> sys_monitor.o
By default, gcc forces dynamic linking, but you can use the -static
switch to make an explicit static linking.
Dynamic linking means that the elf of your app knows just what libraries
depends on. It doesn't embed the actual code. Instead, the dynamic linker
adds the required code whenever you run your application, by loading
the correct libraries. Using dynamic linking you reduce the size of your
executable, but you must be sure that you have the exact libraries needed
in every machine that your application runs.
Static linking means that the whole needed code would be added in the elf.
This results to huge executables, but also able to run everywhere since
they don't have any library depedencies.
% echo "int main(void) {}" > foo.c
% gcc foo.c -o foo
% ls -l foo
-rwxrwxr-x 1 anteater anteater 13592 Apr 12 12:18 foo
% gcc foo.c -static -o foo
% ls -l foo
-rwxrwxr-x 1 anteater anteater 1673122 Apr 12 12:18 foo
Elias
--
http://gnewtellium.sourceforge.net MP3 is not a crime.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2002-04-12 9:22 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-04-09 11:50 start learning gcc ... how to ? fox
2002-04-09 13:04 ` Miguel Griffa
2002-04-09 16:01 ` Re[2]: " adwin
2002-04-09 16:34 ` Elias Athanasopoulos
[not found] ` <1018533665.9524.5.camel@abodh.lan.deeproot.co.in>
2002-04-12 9:22 ` Elias Athanasopoulos
2002-04-09 22:09 ` Re[2]: " Glynn Clements
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 NNTP newsgroup(s).