Setting up the build environment involves specifying the header files and libraries that you need to create an adaptor. For those familiar with their IDE environment, see the following sections for lists of these required include files and libraries. This section also describes how to create an environment variable that you can use to specify the MATLAB® installation folder. The header file and library paths use this environment variable. For detailed instructions on setting up your build environment in the Microsoft® Visual C++® development environment, see Creating an Adaptor Project Using Microsoft Visual C++.
|On this page…|
Note Users of Microsoft Visual C++ should be aware that there are certain project parameters that they must set. See Configuring Other Project Parameters.
The following table lists the locations of the header files and libraries that you need to build an adaptor.
Note You must also specify the location of the header files and libraries required by your device. Read your device's SDK documentation to get this information.
Header File and Libraries
Adaptor kit header files
Image Acquisition Toolbox™ engine library
[a] MATLAB is an environment variable that contains the name of your MATLAB installation folder.
For information about defining environment variables, see Using Environment Variables.)
To learn how to specify header files in Microsoft Visual C++, see Specifying Header Files in Microsoft Visual C++ 2010.
To learn how to specify the libraries in Microsoft Visual C++, see Specifying Libraries and Library Paths.
To create an environment variable on your Windows® 7 system that specifies your MATLAB installation folder, follow this procedure:
As the first step toward building an adaptor, open Microsoft Visual C++ and create a new project.
Note It is strongly recommended that you use a version of Microsoft Visual Studio®. For information on supported versions, see http://www.mathworks.com/support/compilers/current_release.
Set up any required environment variables—see Using Environment Variables.
Start Microsoft Visual C++ 2010.
Expand Visual C++, under Installed Templates, if needed, and select Win32.
Select Win32 Project.
Enter the name you want to assign to the project in the Name field and specify where you want to locate the project in the Location field.
You can give your adaptor project any name. A convention used by the toolbox is to name adaptors as follows:
vendor_name + imaq
where you replace the string vendor_name with something appropriate to your project. For example, this documentation specifies the project name MyDeviceImaq. Microsoft Visual C++ uses the project name as the default adaptor DLL name. To specify a different name for the adaptor DLL, open the project property pages (Project > Properties), open Linker, click General, and edit the Output File field.
Click OK. Visual C++ opens the Win32 Application Wizard.
After you create the project, close the Start Page . Visual C++ displays the project in its Solution Explorer, with separate folders for source files, header files, and other project resources, as shown in the following figure.
After you have created an adaptor, you generally only need to recompile it for use with new major versions of the Image Acquisition Toolbox software. Adaptor writers should recompile when a major update is released, such as Image Acquisition Toolbox Version 4.0. If your adaptor works in one version but not in the new version of the toolbox, try recompiling and relinking to see if that resolves the issue.
Minor updates of the toolbox generally do not include changes to the adaptor kit, so adaptor writers generally will not need to recompile their adaptors.
When you create a project, Microsoft Visual C++ automatically creates a solution that contains your project. As a convenience, while you are developing your adaptor, you might want to add the adaptor kit project to your solution to make it easier to refer to adaptor kit files. Adding the adaptor kit project to your solution does not affect the compilation or linkage of your adaptor DLL.
To add the adaptor kit project to your solution, go to the File > Add > Existing Project menu. In the Add Existing Project dialog box, open the following project file,
where matlabroot represents your MATLAB installation folder.
Before you can compile your adaptor, you must specify the locations of the header files required by the adaptor kit and by your device's SDK. For a list of the header files required by the adaptor kit, see Setting up a Build Environment on Windows Systems. The following section describes how to specify these header file locations in the Microsoft Visual C++ 2010 environment.
Note The examples in the following section use environment variables. For more information, see Using Environment Variables.
To specify the locations of the adaptor kit header files in Microsoft Visual C++ 2010, follow these instructions:
In this example, $(MATLAB) dereferences the environment variable MATLAB, which is set to the name of your installation folder. (See Using Environment Variables for more information.)
Before you can create your adaptor DLL, you must specify the libraries required by the adaptor kit and by your device's SDK. For a list of required libraries, see Setting up a Build Environment on Windows Systems. The following sections describes how to specify these libraries and library paths in Microsoft Visual C++.
This example adds this line to the field:
In the example,$(MATLAB) dereferences the environment variable MATLAB, which is set to the name of your installation folder — see Using Environment Variables. You must replace <ARCH> with the name of an architecture-specific folder, such as, win32 or win64.
To specify the library names, follow this procedure.
Specify the names of the adaptor kit libraries and the names of the libraries required by your device's SDK. Use spaces to separate the names of the libraries. The following shows the adaptor kit libraries.
In addition to specifying the header files and libraries, an adaptor project requires these additional settings. If you do not set these parameters, your adaptor might encounter run-time problems.
Select File > New > File.
In the New File dialog box, select Visual C++.
Select C++ File (.cpp) and then click Open.
Add the new source file to your project. From the File menu, select Move Source1.cpp into and select the name of your project. Accept the default file name for now; you can always change it later.
Open the Property Pages for your project by right-clicking on your project in the Solution Explorer and choosing Properties, or by selecting Properties from the Project menu.
Enable C++ Exceptions
Yes with Extern C functions (/EHs)
Multi-threaded DLL (/MD)
Buffer Security Check