Configure PLplot for Visual CXX CLI
You need a working Visual C++ and CMake installation. You should also ensure the following directories are included in your Path variable:
<CMake install directory>\bin <MSVC++ install directory>\VC <MSVC++ install directory>\VC\bin
Copy the following commands into a text editor, add the correct directory on the first line and save as a batch file. Start the command line interface and execute the batch file. Of course, if you need, you can issue the commands directly from the command line.
The following commands will work if you are not using wxWidgets. A wxWidgets specific list af commands is below.
set PLWIN=<directory you extracted the source code to> cd %PLWIN% call vcvarsall mkdir buildnmake cd buildnmake set PATH=PLWIN\buildnmake\dll;%PATH% cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=install .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON nmake nmake install rename install\bin\plplotcxxd.dll plplotcxx.dll rename install\bin\plplotd.dll plplot.dll rename install\lib\plplotcxxd.lib plplotcxx.lib rename install\lib\plplotd.lib plplot.lib cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=install .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF nmake nmake install rename install\lib\plplotcxxd.lib plplotcxxs.lib rename install\lib\plplotd.lib plplots.lib cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=install .. -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF nmake nmake install rename install\lib\plplotcxxd.lib plplotcxxsd.lib rename install\lib\plplotd.lib plplotsd.lib cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=install .. -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=ON nmake nmake install
If you are using wxWidgets then the following commands provide the basics of what is needed. However, depending upon how you built wxWidgets you may need to specify additional parameters to the cmake call. Check Configuration of wxWidgets driver for more details.
set PLWIN=<directory you extracted the source code to> set WXWINDLL=%WXWIN%\lib\vc_lib cd %PLWIN% call vcvarsall mkdir buildnmake cd buildnmake set PATH=PLWIN\buildnmake\dll;%PATH% cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=install .. -DwxWidgets_LIB_DIR=%WXWINDLL% -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON nmake namake install rename install\bin\plplotcxxd.dll plplotcxx.dll rename install\bin\plplotd.dll plplot.dll rename install\bin\plplotwxwidgetsd.dll plplotwxwidgets.dll rename install\lib\plplotcxxd.lib plplotcxx.lib rename install\lib\plplotd.lib plplot.lib rename install\lib\plplotwxwidgetsd.lib plplotwxwidgets.lib cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=install .. -DwxWidgets_LIB_DIR=%WXWINDLL% -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF nmake nmake install rename install\lib\plplotcxxd.lib plplotcxxs.lib rename install\lib\plplotd.lib plplots.lib rename install\lib\plplotwxwidgetsd.lib plplotwxwidgetss.lib cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=install .. -DwxWidgets_LIB_DIR=%WXWINDLL% -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF nmake nmake install rename install\lib\plplotcxxd.lib plplotcxxsd.lib rename install\lib\plplotd.lib plplotsd.lib rename install\lib\plplotwxwidgetsd.lib plplotwxwidgetssd.lib cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=install .. -DwxWidgets_LIB_DIR=%WXWINDLL% -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=ON nmake nmake install
The commands above will build shared and static debug and release versions of the plplot library and install all files into the directory plplot\buildnmake\install.
For those who are not familiar with NMake and CMake here is an explanation of what we have just done. Nmake is a command line compiler included with Microsoft VC++ which can be used to build from source. Instead of project files it uses make files. To avoid creating make files for multiple compilers plplot includes CMake files. These are interpreted by CMake, along with the variables specified on the command line, to generate make files for many different compilers. So, in order, we performed the following actions:
Set up needed paths including MSVC++ paths using vcvarsall Called CMake to generate make files for static/share and release/debug builds Called Nmake to build PlPlot Called Nmake install to move the libraries and header files to the install folder Renamed the libraries with sensible postfixes to indicate static and debug versions.
Note: during the build the various DLLs are put in the subdirectory "dll" under the build directory. It is important that this directory is contained in the path during the build if you use the dynamic drivers facility as otherwise calls to get-drv-info will fail and the drivers won't be installed successfully. In addition, if you use wxWidgets driver you also must ensure that the wxWidgets DLL itself is in the path as well.
Alternatively you can use the GUI version of CMake, an easy-to-use user-interface that presents the available build options and lets you set them. It is mostly a matter of taste, but:
- The GUI version provides an overview of the build opions that are available
- The command-line version is particularly useful if you are experimenting with these options, as it can be run from a batchfile
Some of the options that are available for cmake:
- -DCMAKE_VERBOSE_MAKEFILE=ON: makefiles provide verbose informations
- -DBUILD_TEST=ON: all examples will be built also (for test purposes)
- Configuration of wxWidgets driver
If you used the -DBUILD_TEST=ON option, you need to copy some files in order to run the examples:
cd examples\c copy ..\..\..\data\*.fnt .
and additionally some dlls for a shared plplot built:
copy ..\..\dll\plplotd.dll . copy ..\..\dll\plplotcxxd.dll . (for c++ examples) copy ..\..\dll\csirocsa.dll . (if library was built)
and for the wxWidgets driver (if wxWidgets library is shared):
copy %WXWIN%\lib\gcc_dll\wxmsw26d_vc_custom.dll .
if this dll is not in the path.