Force linking of libs

Is there a way to force the linker to include a library, even if no symbols
are needed from it?
The reason is, my library creates a global object of a class, and I want the
constructor to be executed.
Markus

Markus Loffler <loffler@ces.clemson.edu> wrote:

Is there a way to force the linker to include a library, even if no symbols
are needed from it?
The reason is, my library creates a global object of a class, and I want the
constructor to be executed.

This may not be what you’re looking for… but you could declare an extern
reference to that global object.

-David

QNX Training Services
dagibbs@qnx.com

I managed to do it with the option -W l,-udummy
and defining the global variable “dummy” in the library I like to include.

The only thing I haven’t figured out, is how to use a class variable or
function instead of “dummy”. I tried “MyClass:myfunc” but it didn’t work.
Something about name mangling?
Markus


“Markus Loffler” <loffler@ces.clemson.edu> wrote in message
news:9deut6$1t0$1@inn.qnx.com

Is there a way to force the linker to include a library, even if no
symbols
are needed from it?
The reason is, my library creates a global object of a class, and I want
the
constructor to be executed.
Markus

I’m porting my code from QNX 4.22 with Watcom C to QNX RTP with gnu C and was
wondering if anyone could send me a sample recursive makefile to get me going.
If you have any tips for me that would be great too.

Here’s my setup:
I have a toplevel directory which contains about 10 subdirectories, each of
which produces a single executable. One of the subdirectories (global) produces
a bunch of stand alone executables as well as a library that the other
subdirectories use/reference. In addition, I have a pre-made motion controller
library that needs to be included in all subdirectories.

I tried typing “make” on the new QNX RTP, but it complained at me and I’m not
sure I know where to even start fixing it…I’m guessing I need to set some
compiler flags somewhere or something. Also, my processor is an AMD K6-2, so if
anyone knows any generic optimizer flags (and how to use them) for that
processor, that would be an added bonus. Any help, especially samples, would be
terrific. Thanks!

Neville