10065
How to compile a 64-bit C DLL using MVS 2010 and run it in IDL
This Help article describes the steps to compile a 64-bit C DLL using Microsoft Visual Studio 2010 Express and how to call it in IDL afterwards.
Requirements:
- A 64-bit Windows machine
- A C compiler that supports 64-bit
- A 64-bit version of IDL
- The test will be run using a C code available in IDL distribution:
C:\ProgramFiles\Exelis\IDLxx\external\dlm\testmodule.c
Before starting this tutorial please copy the testmodule.c file in addition to the testmodule.dlm_base file from the above directory into a test folder. For example
C:\temp\test_dll_64bit\
Then rename testmodule.dlm_base to testmodule.dlm
Installation and configuration of the compiler
- Download a C compiler. In this example we will use the following free C compiler: Microsoft Visual Studio 2010 Express
Note: In order to have Microsoft Visual Studio 2010 Express compiling 64 bit application sit requires to install the following SDK library: Microsoft Windows SDK 7.1 & .NET Framework 3.5 SP1
- Install the C compiler (and the SDK library mentioned above) on your 64-bit machine
Creation of the 64-bit C DLL
- Start the Microsoft SDK command line:
Start > All Programs > Microsoft Windows SDK v7.1 > Windows SDK 7.1 Command Prompt
- Start the 64-bit IDL command line from the compiler prompt so the compiler path is automatically set.
cd "C:\Program Files\Exelis\IDLxx\bin\bin.x86_64"
idl.exe
- Build the 64-bit dll using the following IDL commands:
c_dir='C:\temp\test_dll_64bit\'
cd, c_dir
make_dll, 'testmodule', 'IDL_Load', input_directory='c_dir', $
OUTPUT_DIRECTORY=c_dir
Run the DLL from IDL
- Paste the testmodule.dlm and the testmodule.dll created at the previous step from the test directory into the DLM default path. For example:
C:\Program Files\Exelis\IDLxx\bin\bin.x86_64
- Restart IDL using the IDL icon and run the commands:
DLM_REGISTER,'C:\Program Files\Exelis\IDLxx\bin\bin.x86_64\testmodule.dlm'
print,testfun()
The output should be
% Loaded DLM: TESTMODULE
% TESTFUN: This is from a loadable module function.
TESTFUN
_________________________________________
HA reviewed on 3/25/2014 by DS