help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: using 'g++ -shared' causes Segmentation fault <address@hidden> <addr


From: Mateusz Krzeszowiec
Subject: Re: using 'g++ -shared' causes Segmentation fault <address@hidden> <address@hidden.california.localhost>
Date: 25 Jun 2006 15:04:36 -0700
User-agent: G2/0.2

Heh, thanks to all of you guys :) these were my first steps in Linux
programming and using gcc :)

Many thanks for the patience!

cheers!

Robert Heller wrote:
> At 21 Jun 2006 06:50:49 -0700 "Mateusz Krzeszowiec" 
> <Mateusz.Krzeszowiec@gmail.com> wrote:
>
> >
> >
> > Paul Pluzhnikov wrote:
> > > "facedancer" <Mateusz.Krzeszowiec@gmail.com> writes:
> > >
> > > > I'm trying to learn c++ for Linux and I've got a big problem.
> > >
> > > Actually, you don't have a problem ...
> >
> > Actually, I have a problem :)
> >
> > I *need* to use shared libs (SDL & openGl libs) and I guess it's
> > -shared switch which set that 'linking option'. Every time I use it
> > (-shared) ANY program I'm trying to run gives 'Segmentation fault'...
> >
> > Yours
> > poor noob :)
>
> The '-shared' option is for *creating* a shared library only, NOT for
> linking a *program* to one -- you *NEVER* use -shared when you are
> creating a *program*.  You use the -L and -l options to link with
> libraries, both shared and static actually, depending on which is
> available and depending on the presence or absence of the -static
> switch. The -static forces a static link and is NOT the 'obverse' of
> -shared -- DON'T be confused by their adjacent placement in the man
> pages.  With modern O/Ss, the default is to link to the shared library
> (lib<mumble>.so), unless one is not available.  So to link with the
> shared libraries, you don't need any *extra* switches to 'force'
> linking with the shared libraries -- it will happen automagically by
> default.  You just need to specify the library names.
>
> If you are discovering that you are NOT linking to the shared libraries
> you thought you were going to link with there is something else going
> on, like maybe the shared libraries are not installed in the proper
> place or not installed at all.  You might need to include a -L<path>
> option before the -l<lib> option or something.  You don't add the
> '-shared' option.
>
> So what you want is (assuming you are wanting libSDL.so and libGL.so):
>
> g++ -o otestSDLa testSDLa.o -lSDL -lGL
>
> or maybe
>
> g++ -o otestSDLa testSDLa.o -L/usr/local/lib -lSDL -lGL
>
> or something like that.
>
>
> --
> Robert Heller             -- 978-544-6933
> Deepwoods Software        -- Linux Installation and Administration
> http://www.deepsoft.com/  -- Web Hosting, with CGI and Database
> heller@deepsoft.com       -- Contract Programming: C/C++, Tcl/Tk



reply via email to

[Prev in Thread] Current Thread [Next in Thread]