From: pkurpis@keck.hawaii.edu (Peter Kurpis)
To: carlanunes@yahoo.com
Cc: gcc-help@gcc.gnu.org
Subject: Re: gcc compile options
Date: Thu, 05 Jul 2001 18:40:00 -0000 [thread overview]
Message-ID: <200107060139.PAA14916@kalani.keck.hawaii.edu> (raw)
> 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.
next reply other threads:[~2001-07-05 18:40 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-07-05 18:40 Peter Kurpis [this message]
-- strict thread matches above, loose matches on Subject: below --
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
2001-07-06 11:33 gcc compile options Peter Kurpis
2001-07-05 17:12 Carla Nunes
2001-07-05 18:15 ` Alexandre Oliva
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200107060139.PAA14916@kalani.keck.hawaii.edu \
--to=pkurpis@keck.hawaii.edu \
--cc=carlanunes@yahoo.com \
--cc=gcc-help@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).