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


From: Paul Pluzhnikov
Subject: Re: using 'g++ -shared' causes Segmentation fault
Date: Tue, 20 Jun 2006 19:26:12 -0700
User-agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, linux)

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

> When I
> try to link shared libraries to my program it always outputs
> 'Segmentation fault' when I try to run it.

You are trying to *run* a library, but libraries aren't "runnable"
on any OS I know of [1].

> Of course I was trying to
> write something a bit more complicated ;) but after looking for a bug I
> removed all code and realized that the bug is not caused my my mistake.

Yes, it is. Your mistake is trying to run something that isn't
intended to run.

> g++ -c -otestSDL.o testSDLa.cpp
> g++ -shared -otestSDLa testSDLa.o
> ./testSDLa
> output: Segmentation fault

Don't do that ... Do this instead:

> g++ -otestSDL.o testSDLa.cpp
g++ -o testSDLa testSDL.o        # looks like you missed a step
> ./testSDLa
> output: ok

Cheers,

[1] Actually, on Linux 2 special libraries are runnable:
ld-linux.so.2 and libc.so.6. This is achieved via special assembly
magic, which is too advanced for a beginner to understand :)
-- 
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.


reply via email to

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