Visual Studio - adding netCDF library

匆匆过客 提交于 2019-12-06 01:49:36

I finally got it working with help of others. Here are the (detailed) steps that worked for both Visual Studio 2010 as Visual Studio 2013.

I have a 64bit Windows machine, but used version 4.3.3.1 (32-bit) of the netCDF. The reason that I choose 32-bit was because 32-bit code can run on both 32- and 64-bit machines. The whole setting in general includes three parts: library installation, configure Environmental variables for your computer, and configure Properties for Visual studio.

The following are the step by step settings on my PC.

1. The netCDF library was installed at C:\Program Files (x86)\netCDF 4.3.3.1

2. Go to 'Computer', right click, and choose 'property' -> Advanced system settings -> go to 'Advanced' tab page -> click 'Environmental Variables' -> At 'System variables' field, look for a variable called 'Path', then click 'Edit' -> Append the following to the current path variables (';' is used to separate variables):

;C:\Program Files (x86)\netCDF 4.3.0\bin;

3. Go to Visual studio -> Project -> Properties -> Click 'VC++ Directories' (one of the Configuration Properties) -> Edit the value of 'Include Directories' field by adding 'C:\Program Files %28x86%29\netCDF 4.3.3.1\include' -> Edit the value of 'Library Directories' by adding 'C:\Program Files %28x86%29\netCDF 4.3.3.1\lib'

  1. (still in the Properties) Go to Linker / General (another Configuration Properties) -> make sure 'Enable Incremental Linking' field is 'No' -> Edit 'additional Library Directories' by adding the following two paths:

C:\Program Files %28x86%29\netCDF 4.3.3.1\lib C:\Program Files %28x86%29\netCDF 4.3.3.1\bin

  1. (still in the Linker) -> click Linker / input -> Edit 'Additional Dependencies' by adding 'netcdf.lib'.

  2. Properties setup done. In the C/C++ code, you just need to include netcdf library using

include

Note that for the older 4.3.0 version, other directories are also included (deps/shared). These are not listed separately anymore in the newer 4.3.3.1 version, but added directly to the \bin and \lib directories.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!