library netcdf 路径,Visual Studio - 添加netCDF库

I want to use netCDF formats in a C project using Visual Studio Express 2013 on a Windows 64bit. I've downloaded the installation file from the official website and executed the .exe.

Then, I've looked into this post to see how I should do the linking etc.

More specifically, in my project in Visual Studio, I did the following:

Put #include < netcdf.h >

in VC++ Directories, Library directories, I added C:\Program Files (x86)\netCDF 4.3.3.1\lib; C:\Program Files (x86)\netCDF 4.3.3.1\bin;

in VC++ Directories, Include directories, I added C:\Program Files (x86)\netCDF 4.3.3.1\include; C:\Program Files (x86)\netCDF 4.3.3.1\bin;

in the linker>input>Additional Dependencies, I added netcdf.lib (and all other .lib files I found in the \lib folder of netCDF 4.3.3.1

Placed all .dll files of the \bin folder of netCDF 4.3.3.1 in Windows\System32 and Windows\SysWOW64

However, when I run the project (F5), it gives the following 2 errors:

error LNK2019: unresolved external symbol_nc_strerror referenced in function _main

error LNK1120: 1 unresolved external --> which is, I assume, due to the first error.

I'm a almost completely new to C programming and Visual Studio. Could somebody help?

Thanks in advance!

解决方案

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'

(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

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

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值