lua-users home
lua-l archive

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


On 7/9/07, Patrick Donnelly <batrick@hotmail.com> wrote:
> On 7/9/07, Patrick Donnelly <batrick@hotmail.com> wrote:
Why does `gcc mytest.c -shared` work? I get segmentation faults when I run
it.

-shared produces a dynamic library which resolves some of its
external, unresolved symbols at load or even run time by looking in
the running code's symbol table. This is great for when a program that
provides symbols can load a library that uses them while avoiding
having to compile those symbols into the library... which has nothing
to do with what you're doing :-P

In your case, since nothing provides those symbols, the runtime
linker gives up and your program dumps core. Sorry if this sounds
harsh, but it's probably better to understand what you're doing rather
than trying options blindly - we call that voodoo.

I'm afraid that the kinds of questions you're asking are best answered
in an operating systems course or book - check out Silberschatz'
http://codex.cs.yale.edu/avi/os-book/os7/ - coupled with the
experience I guess you're building up by programming in C already :-)
I actually had fun ripping through the Silberschatz book myself back
in the day not so long ago.

For a quick overview of the (linux-specific, unix general) runtime,
take a look at:
http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html

A little background goes a long way in making man pages useful and C
programming (a little) less frustrating.

-K