Unable to register x64 MapWinGIS.ocx

Sorry to bring back an old issue. My issue is a bit different. It is about missing dependencies such as API-MS-WIN-CORE-XXX.dll.

I built MapWinGIS.ocx as followed:

  • Run VS2017 as admin on Windows 10
  • Git clone latest MapWinGIS, branch master (branch develop didn’t build)
  • GDAL 2.4.3
  • Set VS2017 to build the solution as production x64, click rebuild solution.
    x64 MapWinGIS.ocx was created but not registered (both in VS2017 and in an admin command prompt). VS2017 error MSB8011 - Failed to register output. regsvr32 error is “the module .\MapWinGIS.ocx failed to load”.
    I copied the whole x64\ folder including MapWinGIS.ocx and other dll’s to another Windows 10 laptop and could not register it either.

I downloaded “dependency walker” and opened MapWinGIS.ocx. It shows many missing DLLs (see attached picture).

I really need the x64 ocx. Please advise. Thank you.

Hello @anhvu00, and welcome.

I have used ‘dependency walker’ many times in this circumstance, and I consider all of the ‘API-MS-xxx’ DLL’s to be false negatives. In other words, I have never found those to actually be a reason that the OCX is not loading, and they appear in the list even when the OCX can load successfully. Generally, you should see that something else is missing, perhaps under GDAL or GEOS?

Have you basically followed the steps outlined in this tutorial to set up the development environment?

Please let me know if something else is also listed as missing (other than the API- references).

Thank you.
Jerry.

Hello Jerry, thanks for the quick reply.
I did follow the instruction from the video but selected x64 for my build.
Besides the API-MS-XXXX, there are others:
API-MS-WIN-XXXX
EXT-MS-WIN-XXXX
GDAL204.DLL
EMCLIENT.DLL
HVSIFILETRUST.DLL
IESHIMS.DLL
The error message is the same: “Error opening file. The system cannot find the file specified (2).”
Thank you very much for your help. Regards.

Hello @anhvu00

I believe that GDAL is the primary problem, so let’s start there. One particular step in the video tutorial is the unpacking of GDAL files (from gisinternals.com) into specific directories prior to building. Make sure you have done that step.

Regards,
Jerry.

Follow-up:
I’m sorry, I misread your message at first. I thought it said you did not follow the instruction from the video.
So GDAL is likely present, so it must be a dependency of GDAL? what is that dependency?

Thanks for replying on a Saturday.

First, I built the x32 as instructed in the video to make sure nothing wrong with my setup. The x32 build worked and registered. I also verified it on regedit.
Then, I built the x64 following the same steps (i.e. copy x64 GDAL 2.4.3 \bin, \include, and \lib to \support\GDAL_SDK\v141(bin/lib/include)\x64, then build SupportLibs.sln). The built failed because it could not register (same as before).
When I examined the console output, I saw that it could not find a few files. This did not happen in the x32 build.

Example:

The x32 console output began as:

"1>------ Rebuild All started: Project: MapWinGIS, Configuration: Debug Win32 ------
1>Copying executables…
1>C:\Anh\sandbox\MapWinGIS\src…\Support\GDAL_SDK\v141\bin\Win32\gdal\plugins\gdal_MrSID.dll
1>1 File(s) copied
1>C:\Anh\sandbox\MapWinGIS\src…\Support\GDAL_SDK\v141\bin\Win32\gdal\plugins\gdal_netCDF.dll
1>1 File(s) copied
1>C:\Anh\sandbox\MapWinGIS\src…\Support\GDAL_SDK\v141\bin\Win32\gdal\plugins\gdal_HDF5.dll
1>1 File(s) copied
1>C:\Anh\sandbox\MapWinGIS\src…\Support\GDAL_SDK\v141\bin\Win32\gdal\plugins\gdal_HDF5Image.dll
1>1 File(s) copied
1>C:\Anh\sandbox\MapWinGIS\src…\Support\GDAL_SDK\v141\bin\Win32\gdal\plugins-optional\gdal_ECW_JP2ECW.dll
1>1 File(s) copied
1>C:\Anh\sandbox\MapWinGIS\src…\Support\GDAL_SDK\v141\bin\Win32\gdal\plugins-optional\ogr_MSSQLSpatial.dll
1>1 File(s) copied
1>C:\Anh\sandbox\MapWinGIS\src…\Support\GDAL_SDK\v141\bin\Win32\gdal\plugins-optional\ogr_PG.dll
1>1 File(s) copied
"

While the x64 console output began as:
"1>------ Rebuild All started: Project: MapWinGIS, Configuration: Debug x64 ------
1>Copying executables…
1>File not found - .
1>0 File(s) copied
1>File not found - .
1>0 File(s) copied
1>Could Not Find C:\Anh\sandbox\MapWinGIS\src\bin\x64\gdal*.dll
1>File not found - gdal2*.dll
1>0 File(s) copied
1>Could Not Find C:\Anh\sandbox\MapWinGIS\src\bin\x64\xerces-c*.dll
1>File not found - xerces-c*.dll
1>0 File(s) copied
1>Could Not Find C:\Anh\sandbox\MapWinGIS\src\bin\x64\lti_dsdk*.dll
1>File not found - lti_dsdk*.dll
1>0 File(s) copied
"
I went back to \src\bin\Win32 and saw gdal204.dll there, but \src\bin\x64 did not have it.
The file gdal204.dll is actually in my \support\GDAL_SDK\v141\bin\x64\bin folder.
It is also in my C:\Program Files\GDAL folder (I installed the gdal-204-1911-x64-core.msi from GISInternals before).

Could it be the x64 build did not look for those DLLs in the right place?
Thanks.

FYI, the end of the x64 console output is:
"1> Creating library Debug\x64\MapWinGIS.lib and object Debug\x64\MapWinGIS.exp
1>MapWinGIS.vcxproj -> C:\Anh\sandbox\MapWinGIS\src\bin\x64\MapWinGIS.ocx
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(1840,5): warning MSB3073: The command “regsvr32 /s “C:\Anh\sandbox\MapWinGIS\src\bin\x64\MapWinGIS.ocx”” exited with code 3.
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(1852,5): error MSB8011: Failed to register output. Please try enabling Per-user Redirection or register the component from a command prompt with elevated permissions.
1>Done building project “MapWinGIS.vcxproj” – FAILED.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

"

Hello Anh Vu.

Forgive me if I’m mistaken here, but it looks as if you copied the binaries into a new \bin directory below the x64 directory instead of into the x64 directory. Just as the 32-bit binaries are in \bin\Win32, the 64-bit binaries should be in \bin\x64.

Could that be the case?

Regards,
Jerry.

I believed I have copied to the right places.
There are 2 types of folders: one is to build the Support libs (i.e. under \support…). This is shown in the instruction video. The other is the output, populated by VS2017 (i.e. \src\bin\Win32 or src\bin\x64). I only copied the \support files in order to build. After the build, the correspondent output folder is populated. In this case, the x32 build did it correctly because it could find all the files. But the x64 build could not find the files to copy, thus its output directory did not have those files.
It must be something in the x64 build different from the x32 build to cause such error/DLL not found.
Thanks.

I was just basing my comment on your previous note, in which you said:

Note the extra \bin reference following \x64. If that is actually where you found gdal204.dll, then it is in the wrong directory. It should be up one level.

These dlls should be copied, by you, from the gisinternals zip file into

support\GDAL_SDK\v141\bin\x64

Then, during the build, VS2017 will copy from that directory into

src\bin\x64

You can verify this, if you open the MapWinGIS Project Properties, and go to Build Events | Pre-Build Event

you will see in the Evaluated value of the Command Line for the Win32 platform

C:\dev\MapWinGIS\src\CopyTamasFiles.bat C:\dev\MapWinGIS\src\..\Support\GDAL_SDK\v141\bin\Win32 C:\dev\MapWinGIS\src\bin\Win32\

and for the x64 platform, it should say

C:\dev\MapWinGIS\src\CopyTamasFiles.bat C:\dev\MapWinGIS\src\..\Support\GDAL_SDK\v141\bin\x64 C:\dev\MapWinGIS\src\bin\x64\

This will tell you where it is looking for the binaries, and where it will copy them to. I copied these from my project, but your project should be the same.

Respectfully,
Jerry.

Success!
You were right. I was careless during the copy of x64 GDAL to \support…\x64\bin folder. The x64 GDAL folder structure had more files and different layout than the 32-bit counterpart. One cannot just cut-n-paste as in the video (32-bit build).
After moving those GDAL files up 1 level, rebuilding the Support solution, then the MapWinGIS solution was built and registered successfully.
Thank you very much for your help. I appreciate it.
This ticket is solved and can be closed.