public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* GCC COMPILE OPTIONS
@ 2006-11-08  7:30 Lalit Seth
  2006-11-08 15:54 ` Ian Lance Taylor
  0 siblings, 1 reply; 9+ messages in thread
From: Lalit Seth @ 2006-11-08  7:30 UTC (permalink / raw)
  To: gcc-help

Hi All,

I like to knw why we use "gmake bootstrap-lean" to compile GCC instead
of "gmake". How they are different and what behaviour changes are
there in 2 cases for GCC compiler.

Thanks
Lalit Seth

^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: gcc compile options
@ 2001-07-06 11:33 Peter Kurpis
  0 siblings, 0 replies; 9+ messages in thread
From: Peter Kurpis @ 2001-07-06 11:33 UTC (permalink / raw)
  To: carlanunes; +Cc: gcc-help

> I have one more question regarding the creation of a
> shared library...
> 
> Should I use the g++ command with the -Wl options or
> can I use the ld command directly? Which one is
> better?

In general, I think  g++ -shared  is more convenient,
because it silently includes  libstdc++.so.* , for
instance.  But I think either can be used, although
to be honest, I've not used nor seen  ld  used to
build shared libs from c++ modules.

(When creating an executable,  gcc  and  g++  are even
more handy, since they link in the startup module 
(usually called something like  crt.o ), etcetera,
whereas with  ld , I think you'd have to be explicit
about these things.)

BTW, you may need to use  -fpic  when compiling source
code that you plan to link into a shared lib.

One way to see how things are commonly done on your
system is to examine native makefiles.  Besides looking
at them with an editor, you can also (with GNU make,
which you probably have on your system) do e.g.

	make -np | grep "^CPPFLAGS"

to see how  CPPFLAGS  is defined.  (The  -n  turns off
any actual building.)  Or, you can see how a particular
target would be build (again, without actually building
anything) with e.g.

	make -n mylib.so

assuming there's a target called  mylib.so .

^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: gcc compile options
@ 2001-07-05 18:40 Peter Kurpis
  0 siblings, 0 replies; 9+ messages in thread
From: Peter Kurpis @ 2001-07-05 18:40 UTC (permalink / raw)
  To: carlanunes; +Cc: gcc-help

> have to do the following: compile multi-thread C++
> programs, generate an executable file and create a
> shared library with a list of exported external
> symbols of the shared object files. I need to do that
> in three distinct steps since I have to use a make
> file previously developed for use on AIX (VisualAge
> C++ compiler).
> 
> I'm thiinking of using the folowing commands
> ("make-like") to compile and create an executable
> file, but I don't know how to create shared libraries
> and export the symbols...
> 
> compile:
> gcc -x c++ -g -Iincdir -c srcdir/*.c objdir/*.o
> -mthreads

Use  g++  to compile c++ code, not  gcc -x c++ .  Also,
you need to use  -o  to specify the output file.

If you are writing a makefile, I would guess you just
need to specify the standard make variables, e.g.

CXX = g++
CPPFLAGS = -g -Iincdir

and use make's implicit rule for .cc files.

> create the executable:
> gcc -lsomelib -o execfile objfiles

The order of libs and objfiles matters, as the linker
only makes one pass through the command line resolving
symbols.  Ordinarily, libs resolve symbols in your
objfiles, so

g++ -o execfile objfiles -lsomelib

Note again the use of g++.  It has knowledge of what to
link against implicitly, a different set of things than 
gcc.

To create a shared library, since you are using the GNU
ld (inherently configured into gcc):

g++ -shared -o sharedlib objfiles

I haven't looked up whether you can create a list of 
exported symbols at link time -- you probably can, and 
you can pass the option to  ld  via
 -Wl,-xxx  where  xxx  is the option string.  (See  man ld
for the right thing.)  Alternatively, you can use  nm  
and  grep  to do the same thing.

^ permalink raw reply	[flat|nested] 9+ messages in thread
* gcc compile options
@ 2001-07-05 17:12 Carla Nunes
  2001-07-05 18:15 ` Alexandre Oliva
  0 siblings, 1 reply; 9+ messages in thread
From: Carla Nunes @ 2001-07-05 17:12 UTC (permalink / raw)
  To: gcc-help

Hi!

I'm just getting started using the GCC compiler, and I
have to do the following: compile multi-thread C++
programs, generate an executable file and create a
shared library with a list of exported external
symbols of the shared object files. I need to do that
in three distinct steps since I have to use a make
file previously developed for use on AIX (VisualAge
C++ compiler).

I'm thiinking of using the folowing commands
("make-like") to compile and create an executable
file, but I don't know how to create shared libraries
and export the symbols...

compile:
gcc -x c++ -g -Iincdir -c srcdir/*.c objdir/*.o
-mthreads

-x c++ ---> c++ language
-g ---> to debug
-I ---> include directory
-c ---> to generate the .o files. do not link.
-mthreads ---> allows to handle with thread-safe
exception

create the executable:
gcc -lsomelib -o execfile objfiles

-lsomelib ---> i need to use some special libs

Any help will be welcome.

Thanks, Carla.

BTW, I'm using the GCC version 2.96-RH that comes with
Red Hat 7.1.




__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

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

end of thread, other threads:[~2006-11-10 11:34 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-08  7:30 GCC COMPILE OPTIONS Lalit Seth
2006-11-08 15:54 ` Ian Lance Taylor
2006-11-08 17:32   ` Tim Prince
2006-11-10 11:30     ` Lalit Seth
2006-11-10 11:34       ` Andrew Haley
  -- strict thread matches above, loose matches on Subject: below --
2001-07-06 11:33 gcc compile options Peter Kurpis
2001-07-05 18:40 Peter Kurpis
2001-07-05 17:12 Carla Nunes
2001-07-05 18:15 ` Alexandre Oliva

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).