Compiling and Linking Your DLL

To create your DLL, you need a 32-bit Microsoft compiler — Visual C++ 5.0, 6.0 or 7.0 (.NET) will all work. Instructions on compiling and linking your DLL are given in the README.TXT file in the USEREFI/microsft subdirectory, along with the outline given below. You can also build the samples with VCBuild.exe, a free, public domain tool from Microsoft. Go to http://www.gotdotnet.com/team/cplusplus/samples/vcbuild.zip to download it. The cl.exe (the C++ compiler) is still required to run VCBuild, so users who want to build with it have to get the Platform SDK from Microsoft, which contains the compiler, a linker, various libraries and documentation. The Platform SDK can be downloaded via Windows Update.

In the userefi/microsft/sources directory there is a Visual Studio solution called userefi.sln that includes all the projects for UserDLL examples. In each example directory there is a .vcproj file. You can open and build each project file separately or the solution as a whole in the Visual Studio 2003 IDE. In addition you can use the following command to build all of the examples from the command line:

"%MS_DEV%devenv.exe" userefi.sln /build debug

This builds the debug configuration of the whole solution, assuming that userefi.sln is in the current working directory.

To build a single project, use a command of the form:

"%MS_DEV%devenv.exe" userefi.sln /build release /project multiply

This builds the release configuration of the multiply.vcproj project.

Default paths for required libraries and header files are:

In Visual Studio 7 or Visual C++ 7 (.NET)

To build your own projects from scratch, choose File > New > Project to create a Visual C++ Project.

  1. Choose a Win32 Project. In the resulting Application Settings wizard, specify a DLL type. Under Additional Options, specify an empty project.
  2. Add or create your source files. Use the Source Files directory in the project.
  3. Right-click the project name in the Solution Explorer and choose Properties.
  4. Under C/C++ > General properties, set an Additional Include Directory (first choice). Specify the full path to the header file MCADINCL.H. You must use quotes.
  5. Under Linker > Input properties, set an Additional Dependency (first choice) to the path and MCADUSER.LIB library file. You must use quotes.
  6. Under Linker > Advanced properties, set an Entry Point (first choice) to DllEntryPoint.

Build the project, and copy the resulting .dll file from the Project directory to the /userefi subdirectory under your Mathcad installation. (You can configure Visual Studio to automatically copy the .dll to this directory.) To use your new function, restart Mathcad with the new .dll in place.

Debugging

Specify mathcad.exe as the command line to launch when debugging the DLL project. Once Mathcad launches, you can call your compiled DLL function in Mathcad and use breakpoints in the code to debug.

If you are still having trouble getting a UserDLL to run (particularly if you are trying to execute someone else's code), you may wish to use the Microsoft Development analyzer tools, such as depends.exe, which lists any files (typically system DLLs) upon which your DLL depends.

Note: