Visual Studio - 添加netCDF库 [英] Visual Studio - adding netCDF library

查看:1071
本文介绍了Visual Studio - 添加netCDF库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Windows 64位上使用Visual Studio Express 2013在C项目中使用netCDF格式。我已从官方网站下载安装文件,执行了.exe。

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.

然后,我查了一下这篇文章,看看我应该怎么做链接等
更具体来说,在我的Visual Studio项目中,我做了以下工作:

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:


  1. #include< netcdf.h>

  2. 在VC ++目录,库目录中,我添加了C:\Program文件(x86)\\\
    etCDF 4.3.3.1 \lib ; C:\程序文件(x86)\\\
    etCDF 4.3.3.1\bin;

  3. 在VC ++目录中,包括目录,我添加了C:\Program文件(x86)\ netCDF 4.3.3.1\include; C:\程序文件(x86)\\\
    etCDF 4.3.3.1\bin;

  4. 在链接器>输入>附加依赖关系中,我添加了netcdf.lib(和所有其他.lib netCDF中的\lib文件夹中找到的文件4.3.3.1

  5. 将Windows \System32和Windows \中的netCDF 4.3.3.1 \bin文件夹的所有.dll文件放在SysWOW64

  1. Put #include < netcdf.h >
  2. 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;
  3. 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;
  4. 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
  5. Placed all .dll files of the \bin folder of netCDF 4.3.3.1 in Windows\System32 and Windows\SysWOW64

但是,当我运行项目(F5)时,会出现以下2个错误:

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



  • 错误LNK2019:未解析的外部symbol_nc_strerror在函数_main中引用

  • 错误LNK1120:1未解决的外部 - >这是我假设的,因为第一个错误。

我几乎完全新的C编程和Visual Studio可以帮助吗?

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

提前感谢

推荐答案

我终于在其他人的帮助下工作了,这是两个工作的(详细)步骤Visual Studio 2010作为Visual Studio 2013。

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.

我有一台64位Windows机器,但使用了netCDF的4.3.3.1(32位)版本。我选择32位的原因是因为32位代码可以在32位和64位机器上运行。整个设置通常包括三个部分:库安装,为您的计算机配置环境变量,并配置Visual Studio的属性。

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.

以下是我PC上的一步一步设置。

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


1. netCDF库安装在C:\Program Files(x86)\\\
etCDF 4.3.3.1

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


2.转到计算机,右键单击,选择属性 - >高级系统设置 - >转到高级选项卡页 - >点击环境变量 - >在系统变量字段中,查找一个名为路径的变量,然后单击编辑
- >将以下内容附加到当前路径变量(';'用于分隔变量):

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;

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


3.转到Visual studio - > Project - >属性 - >点击VC ++目录配置属性) - >通过添加'C:\Program Files%28x86%29 \\\
etCDF 4.3.3.1 \include' - >编辑'Include Directories'字段的值,通过添加' C:\Program Fil es%28x86%29\\\
etCDF 4.3.3.1\lib'

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. (仍在属性中)转到链接器/常规(另一个配置属性) - >确保启用增量链接字段为否 - >编辑附加库目录,方法是添加以下两个路径:

C:\程序文件%28x86%29 \\\
etCDF 4.3.3.1 \lib
C:\程序文件%28x86%29 \\\
etCDF 4.3.3.1 \\ \\ bin

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


  1. (仍在链接器中) - >点击链接器/输入 - >编辑'附加依赖'添加'netcdf.lib'。

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

属性设置完成。在C / C ++代码中,您只需要使用

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



include



请注意,对于较旧的4.3.0版本,还包括其他目录(deps / shared)。这些新的4.3.3.1版本不再单独列出,但直接添加到\bin和\lib目录。

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.

这篇关于Visual Studio - 添加netCDF库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆