- May
- 120
- 1
I'm having huge trouble getting my plugin to link correctly. The code
is C, not C++ - I can compile it as C++, but it does not use any C++
features, and I'd rather not use C++ unless I have to.
The problem lies in the C name mangling (_function@N), which I cannot
seem to get to work sanely. Part of the problem is that the SDK only
supplies a C++-compatible import library for TakeCmd.dll. However, I
can generate an appropriate (maybe!) .lib based on MS KB entry 131313.
I'm using MS C++ 2008 Express Edition. My sources are compiled using
cl /c lua.c. For my link, I am doing
link /out:lua.dll /DLL *.obj TakeCmd.lib
DLL has an export table that looks like this:
ordinal hint RVA name
1 0 00001020 _GetPluginInfo@0
2 1 00001090 _InitializePlugin@0
3 2 000010B0 _ShutdownPlugin@4
4 3 00001550 __lua_release@4
5 4 00001520 __lua_version@4
6 5 00001260 _f_lua@4
7 6 00001580 _lua@4
When I try to load the plugin, I get
"Lua"
OK, what procedure???!? If I use a .def file to get names without the
initial underscore or terminating @N, it makes no difference. If I use
gcc, I get a .dll with *both* names in the export table, and the
plugin loads OK. I'm baffled as to why.
I've tried all sorts of combinations and variations, with different
results which, quite frankly, I cannot explain.
To a large extent, I'm tempted to ignore the issue and stick with GCC.
But MSC gives a dll 1/4 of the size, so I'd rather get it working if
at all possible.
Can anyone tell me how to build a plugin, using C rather than C++,
with the MS C command line compiler? It can't be this hard, surely???
Paul.
is C, not C++ - I can compile it as C++, but it does not use any C++
features, and I'd rather not use C++ unless I have to.
The problem lies in the C name mangling (_function@N), which I cannot
seem to get to work sanely. Part of the problem is that the SDK only
supplies a C++-compatible import library for TakeCmd.dll. However, I
can generate an appropriate (maybe!) .lib based on MS KB entry 131313.
I'm using MS C++ 2008 Express Edition. My sources are compiled using
cl /c lua.c. For my link, I am doing
link /out:lua.dll /DLL *.obj TakeCmd.lib
DLL has an export table that looks like this:
ordinal hint RVA name
1 0 00001020 _GetPluginInfo@0
2 1 00001090 _InitializePlugin@0
3 2 000010B0 _ShutdownPlugin@4
4 3 00001550 __lua_release@4
5 4 00001520 __lua_version@4
6 5 00001260 _f_lua@4
7 6 00001580 _lua@4
When I try to load the plugin, I get
TCC: (Sys) The specified procedure could not be found.>plugin /L Lua
"Lua"
OK, what procedure???!? If I use a .def file to get names without the
initial underscore or terminating @N, it makes no difference. If I use
gcc, I get a .dll with *both* names in the export table, and the
plugin loads OK. I'm baffled as to why.
I've tried all sorts of combinations and variations, with different
results which, quite frankly, I cannot explain.
To a large extent, I'm tempted to ignore the issue and stick with GCC.
But MSC gives a dll 1/4 of the size, so I'd rather get it working if
at all possible.
Can anyone tell me how to build a plugin, using C rather than C++,
with the MS C command line compiler? It can't be this hard, surely???
Paul.