From: Mumit K. <khan@NanoTech.Wisc.EDU> - 2001-06-30 03:20:59
|
On Fri, 29 Jun 2001, Rodrigo Hern=E1ndez wrote: >=20 > Function__FRt5deque3Zt12basic_string3ZcZt18string_char_traits1ZcZt24__def= ault_alloc_template2b0i0Zt9allocator1Zt12basic_string3ZcZt18string_char_tra= its1ZcZt24__default_alloc_template2b0i0Ui0P13GeneralObjectRi=20 > @ 1 ; LoadMap(deque<basic_string<char, string_char_traits<char>,=20 > __default_alloc_template<false, 0> >, allocator<basic_string<char,=20 > string_char_traits<char>, __default_alloc_template<false, 0> > >, 0> &,= =20 > GeneralObject *, int &) >=20 > I make a change so it instad reads like this: > Function =3D=20 > Function__FRt5deque3Zt12basic_string3ZcZt18string_char_traits1ZcZt24__def= ault_alloc_template2b0i0Zt9allocator1Zt12basic_string3ZcZt18string_char_tra= its1ZcZt24__default_alloc_template2b0i0Ui0P13GeneralObjectRi=20 > @ 1 ; LoadMap(deque<basic_string<char, string_char_traits<char>,=20 > __default_alloc_template<false, 0> >, allocator<basic_string<char,=20 > string_char_traits<char>, __default_alloc_template<false, 0> > >, 0> &,= =20 > GeneralObject *, int &) >=20 >=20 > then I use the DEF file to make an object file with exports like so: >=20 > dlltool -d AeonScript.def -e exports.o -l libAeonScript.a AeonScript.o >=20 > and compile >=20 > gcc exports.o -oScript.dll >=20 > this way I can call GetProcAddress with "Function" as paramether it works= ,=20 > however everytime I add a new function I have to go throw the process of= =20 > creating a new def and changing every function entry again. This is a tricky problem. C++, regardless of the compiler used, will=20 create mangled names, and loading a symbol at run using GetProcAddress=20 on Windows or dlsym/shl_findsym/etc on Unix all run into the same problem. There are two ways to ease dynamically loading C++ functions: 1. Use "C" linkage for the functions. The names are then not mangled. For each C++ function that needs to be dynamically loaded, I typically define a second function using C linkage that just calls the intended one. The indirection isn't necessary, and depends on your design/taste. 2. Use a "mangler" algorithm. I used this mechanism a long time ago, but gave up because various C++ compiler vendors don't release the algorithm used, and also the C++ ABI hasn't been stable on most platforms. If you *only* use GNU C++, then this is a good method. I recommend (1), with whatever local variations you need to make it work for you. This is not a GNU specific issue, but a C++ issue, and you'll have to deal with for all compilers. Regards, Mumit |