HELP linking driver written in C++

Vasili Goutas Kernel Hacker (vgo@ratio.de)
Fri, 02 Oct 1998 09:55:41 +0200


Hi,

I´m writing a Linux device driver in C++ and have some problems by
linking.
Because the Linux kernel "speeks" only C and C++ compiled objects
differs
in some things, I write my source insite a ´Extern "C" { }´ declaration.

This works fine till now.
I divide my driver into several modules, each one in an other directory.

One module contains of 1-3 classes.
I compile each class with ´cc -c -O3 ...´ and link the modules by ´ld
-Ur ... -o all.o´,
so at the end I link them all together with
´ld -Ur .../A/all.o .../B/all.o ..../C/all.o -o driver.o´
When I want to insert this object into the kernel by ´insmod driver.o´ I
get a lot of
´unresolved symbols´.

-Some of them are inline functions which for some reason are not
compiled in even I use
the ´-O3´ and ´-finline-functions´ Option.

-Some other are function names which are declared ´virtual´ in a base
class.

-In this base class there are also some ´static´ members which for some
reasons also are
unresolved symbols.

The base class loocks like this:
class base
{
static unsigned char xx;
static unsigned char yy;
static unsigned char zz;
...
protected:
...
public:
base( void );
virtual ~base( void );
};
some other classes are devived from base

class derived : protected base
{
int a;
char b;
...
protected:
virtual init( void );
...
public:
derived( void );
virtual ~derived( void );
};

end then finaly some classes on which I work on inherits from derived
class finalA : protected derived
{
...
};
class finalB : protected derived
{
...
};

so when one of the final classes changes the static members of the base
class
I want to se this changes in all of the final classes.
Another way may be global variables, I know, but why does this not work?

An other unresolved symbol is the __buildin_new operator of C++. How is
the library called
which contains the C++ new operator? I link my objects against g++ and
stdc++ whith
´ld -Ur driver.o -lg++ -lstdc++´ but ´new´ is still missing.

Last but not least the symbol ´__divdi3´ is also unknown, and I don´t
know where it comes from.
Maybe its a function call of division in the math lib.

I hope posting this in news groups and mailing lists will reach enough
experience developer
and some of you can help me.

Any Ideas are welcome

TIA
Vasili Goutas

please CC to vgo@ratio.de

--

********************************************************************** * Vasili Goutas RATIO Entwicklungen GmbH * * P:+49-(0)40-369007-37 Admiralitätstr. 59 * * F:+49-(0)40-369007-25 D-20459 Hamburg * * Email: mailto:vgo@ratio.de * **********************************************************************

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/