What target bit setting should I use to compile ZOS-API extensions? -Reply

  • 25 November 2023
  • 1 reply
  • 36 views

Userlevel 7
Badge +3

Hi,

In the posting What target bit setting should I use to compile ZOS-API extensions? | Zemax Community Ethan sets out a great point. Sadly that post is closed for further replies so I’m starting a new thread for replies 😁

I’d strongly recommend that only x64 executables be used with OpticStudio. OS was 64 bit from its earliest days on Windows 3.1, and users from back then will remember having to install the 64-bit extensions for 32-bit Windows 3.1 via floppy disk. The Operating System has been 64 bit natively since Windows 95 and NT 4.

The reason Zemax is 64 bit is to prevent cumulative errors when tracing from surface to surface. Using 32-bit means you can run out of precision with big systems when trying to keep track of sub-wavelength OPD errors.

As long as your code is only analysing data produced by OpticStudio, 32 bit might be OK, but I’d seriously avoid using 32 bit as it’s asking for trouble to mix 32 and 64 bit executables. Keep all extensions 64 bit unless you have a compelling reason to do otherwise. 32-bit being the default setting is not a ‘compelling reason’ IMHO

Keep it 64-bit!


1 reply

Userlevel 6
Badge +2

Hi Mark,

Great points.

Zemax officially removed the x86/Win32 entry point for the ZOSAPI_NetHelper.dll in 2022, so compiling ZOS-API executables (SA, UA, UE, or UDOC) will fail.  This entry point is part of the Windows Registry and the OpticStudio installer does not remove this WinReg entry when update versions of OpticStudio or if you uninstall a previous version of OpticStudio (assuming you still have at least 1 version of OpticStudio installed).  So, if you have OpticStudio from 2021 installed, you can still use 32-bit ZOS-API programs.

However, if you install OpticStudio on a brand new machine and you try to run a typical 32-bit application, you will get a “cannot locate OpticStudio error”.

Unfortunately Zemax did not publish this change in their release notes and they’re still shipping ZOS-API User Extensions and User Analysis with the Any CPU and Prefer 32-bit flags checked, so even some examples UE/UA don’t work for new users.  

As an additional point between 32-bit and 64-bit, all results from ZOS-API are doubles (64-bit) so unless the user is converting all doubles to floats (32-bit), you should always use 64-bit.

Reply