This article is also available in Japanese.
The article How Do I Write an Extension in C? gives full details of how to write and compile ZEMAX extensions using the C-compiler in Microsoft Visual Studio 6. Microsoft is now shipping Visual Studio 2005, and this article describes how to configure that compiler. Please see the original article for an explanation of what Extensions are.
Start Visual Studio 2005, and then define a new C++ Win32 project
Enter a name for this project: in this case I used the name VS2005. Then press OK. In the next screen, "Application Settings", declare this to be an empty project, so no files are created.:
Set the project to Release Mode:
In the Solution Explorer, click on the Source Files folder (red box 1 below), then right-mouse-click and choose Add...Add Existing Item. Add the two files hello_world.c and zclient.c. Both can be downloaded from the links at the end of this article:
{Now if you are using the Jan 22 2007 or earlier release of ZEMAX, you should use the zclient.c which is included at the end of this article, and NOT the version that is distributed with ZEMAX. This new version contains an extra line, specifically for Microsoft Visual Studio 2005:
#pragma warning ( disable : 4996 )(Each implementation of C and C++ supports some features unique to its host machine or operating system. The #pragma directives offer a way for each compiler to offer machine- and operating system-specific features while retaining overall compatibility with the C and C++ languages. Pragmas are machine- or operating system-specific by definition, and are usually different for every compiler.)
// functions like strcpy are now deprecated for security reasons; this disables the warning


------ Build started: Project: VS2005, Configuration: Release Win32 ------That's it! Everything else is the same as in the article How Do I Write an Extension in C?
Compiling...
zclient.c
hello_world.c
Linking...
Generating code
Finished generating code
Embedding manifest...
VS2005 - 0 error(s), 0 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========