X

Help Articles are product support tips and information straight from the NV5 Geospatial Technical Support team developed to help you use our products to their fullest potential.



18041 Rate this article:
4.0

How to create a 64-bit C DLL with MSVC 2017 and IDL 8.7 for Windows 10

 

Background:

 

IDL 8.7 is compiled using Microsoft Visual Studio version 2010. Thus, the recommended compiler to create a DLL for IDL 8.7 would be version 2010 of MSVC. However:

 

  • The free version of MSVC 2010 is 32-bit only
  • The SDK library required to compile 64-bit DLL with MSVC 2010 mode (see link below) is no longer supported with Windows 10.

https://www.harrisgeospatial.com/Support/Self-Help-Tools/Help-Articles/Help-Articles-Detail/ArtMID/10220/ArticleID/16074/How-to-compile-a-64-bit-C-DLL-using-MVS-2010-and-run-it-in-IDL

 

 

Available options to create a DLL with MSVC 2010 for Windows 10

 

There are currently 3 options to compile a DLL for IDL 8.7 and Windows 10 using MSVC 2010. However, none is ideal.

 

Option 1:  use the PRO version of MSVC 2010. However, it is not a free version and it requires to buy a MSVC license

 

Option 2: create 32-bit DLL using MSVC 2010. However, it requires to call such DLL in IDL 32-bit, which is not ideal due to memory limitations of 32-bit applications.

 

Option 3: it seems there are some ways to install the SDK library so MSVC 2010 free version may compile 64-bit DLL. However, it requires to modify registry keys which is not possible for many customers - and is potentially not recommended either.

 

 

How to create a 64-bit DLL using MSVC 2017 for IDL 8.7 on Windows 10

 

Another option is to use a higher version of the MSVC compiler such as 2017 which is 64-bit compatible. It is usually not recommended to use a compiler of a different version than the one used to compile IDL:  there could be some library incompatibilities due to the changes between 2 compiler versions which will cause the compilation to fail.

However, the procedure below shows how to configure and use MSVC 2017 to successfully compile a 64-bit DLL to be called in IDL 8.7 on Windows 10.

 

1. Download and install MSVC 2017 free version

 

2. If not yet installed on your Windows 10 system: download and install Windows Kits 10: 

https://developer.microsoft.com/en-US/windows/downloads/windows-10-sdk

 

3. Start the MSVC 2017 prompt called: x86_x64 cross Tools Command Prompt for VS 2017. 

This is the only prompt which will allow to build a 64-bit DLL compatible with IDL 8.7

 

4. Launch IDL 8.7 64-bit from the MSVC prompt 

cd "C:\Program Files\Harris\IDL87\bin\bin.x86_64"

idl.exe

 

5. Initialize the working directory where the .c code - to be used to build the DLL- resides. For example:

c_dir="C:\TEMP\test_dll"

cd,c_dir

 

6. Adapt the !MAKE_DLL variable to take into account the changes in library names between MSVC 2010 and MSVC 2017

!make_dll.ld='link /out:%L /nologo /nodefaultlib /dll %O /def:%E "C:\Program Files\Harris\IDL87\bin\bin.x86_64\idl.lib" ucrt.lib vcruntime.lib libcmt.lib kernel32.lib %X'

 

7. Define LIB and INCLUDE environment variables to point to the expected libraries and headers (adapt the path if needed).

SETENV, 'LIB=C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\ucrt\x64;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\x64;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.17763.0\um\x64' 

print,GETENV("LIB")

 

SETENV, 'INCLUDE=C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include'

print,GETENV("INCLUDE")

 

8. Build the 64-bit DLL. The below example is based on the testmodule C code example available in the IDL distribution C:\Program Files\Harris\ENVI55\IDL87\external\dlm.

The testmodule.c code and its DLM are previously saved in the working directory defined at step 5: C:\TEMP\test_dll.

make_dll, 'testmodule', 'IDL_Load', input_directory=c_dir, OUTPUT_DIRECTORY=c_dir

 

9. Save a copy of the testmodule.dlm and the testmodule.dll created at step 8 DLM default path. For example: C:\Program Files\Harris\IDL87\bin\bin.x86_64

 

10. Run the DLL

DLM_REGISTER,'C:\Program Files\harris\IDL87\bin\bin.x86_64\testmodule.dlm'

print,testfun()

IDL  should output  :

% Loaded DLM: TESTMODULE

% TESTFUN: This is from a loadable module function.

TESTFUN    

 

 

 

 

-------------------------------------------

Created by BC on 02/11/19 - Reviewd by BenC on 02/15/19   

 

 

Please login or register to post comments.
Featured

End-of-Life Policy Enforcement for ENVI 5.3 / IDL 8.5 and Earlier Versions

5/6/2024

April 1, 2024 Dear ENVI/IDL Customer,  We are reaching out to notify you of our supported... more »

How to Upgrade licenses to ENVI 6.x / IDL 9.x

12/5/2023

What is the new Upgrade function? Starting with ENVI 6.0 and IDL 9.0, we have implemented an... more »

What to do if the 'License Administrator - License Server' for the Next-Generation License Server does not start?

6/13/2023

Background: With the release of ENVI 5.7 & IDL 8.9 and the corresponding Next-Generation licensing... more »

Next-Generation Licensing FAQ

4/28/2023

  NV5 Geospatial has adopted a new licensing technology for all future releases of our ENVI, IDL... more »

The IDL Virtual Machine

6/6/2013

What is the IDL Virtual Machine? An IDL Virtual Machine is a runtime version of IDL that can... more »