WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

!! WIL SDK !!
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Problem creating extender DLL from .CPP

Keywords:   SDK CPP

Question:

I bought the extender SDK and I've been able to add some very useful functions to the basic DLL. I love it; I've managed to speed up some routines by a factor of about 200 (!) and simplify my WIL code. But I've encountered a snag. I can create a working DLL from a .C source, no problem, but I haven't yet managed to generate a workable DLL from a C++ (.CPP) source. I'm using MS Visual C++ 5.0. The workspace settings are the same in both cases.

A ".C" source compiles clean and the resulting DLL loads and executes normally. If I rename the same source as a ".CPP" it also compiles and links clean, but AddExtender() fails to load the ".CPP" version. Instead I get a "3395: Not a valid extender" error.

I'd like to be able to generate the DLL from a .CPP to be able to use MFC and incorporate DAO (MS Access) functions. Adding DAO to a .C source is an excellent way to generate a couple hundred thousand compile errors. In fact, I suspect that you could set a new world record that way, as far as nasty compiles go.

Advice please. Can I build a true C++ DLL that AddExtender will accept, and if so, how?

Answer:

The trick is to have the main entry point in a C program, then simply call CPP subroutines. Basically make a CPP file and add it to the project.

Question (continued):

OK, thanks. That's great if I can do it in a round-about fashion. But I'm curious. Why does it have to be a C program?

Would it be difficult to add an "AddExtCPP()" function to permit use of C++ generated DLLs?

Answer:

Most of the problem is the way CPP "decorates" the entry point name. If you can figure out how to get it to not mangle the entrypoint, then it should work.

We've tried in the past with older compiler and gave up. The newer compiler might have some options to allow the name not to be mangled.

There is some utility that can display the names for you (or make a MAP file from the link) to see that names you are getting.

The extender load process basically does a LoadLibrary on the extender, then tries a GetProcAddress to get the entrypoint name. If it cannot find it, it whines and claims that it is not a valid extender DLL.


Article ID:   W12586
Filename:   Problem Creating Extender DLL from CPP.txt
File Created: 2017:07:28:12:58:14
Last Updated: 1999:04:15:15:48:14