如何在C ++中使用Fimex [英] How to use Fimex in C++

查看:94
本文介绍了如何在C ++中使用Fimex的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Quote:

您好,我的名字是Akmal,最近我正在尝试使用FIMEX读取GRIB文件,但我找不到任何文件关于如何在C ++中安装Fimex然后我已经阅读过FIMEX网站的说明。请帮我。我正在使用Fimex,例如下面的例子。所以当我使用一些函数例如defaultLogLevel然后它给我这个错误

Hello, my name is Akmal and recently I am trying to use FIMEX to read GRIB files, but I could not find any explanation about how to install Fimex in C++ and then I have already read FIMEX site. Please help me. I am using Fimex like bellow example. So while I use some function for instance "defaultLogLevel" and then it gaves me this error

Quote:



错误1错误LNK2019:未解析的外部符号void __cdecl MetNoFimex :: defaultLogLevel(enum MetNoFimex :: Logger :: LogLevel)(?defaultLogLevel @ MetNoFimex @@ YAXW4LogLevel @ Logger @ 1 @@ Z)在function main


Error 1 error LNK2019: unresolved external symbol "void __cdecl MetNoFimex::defaultLogLevel(enum MetNoFimex::Logger::LogLevel)" (?defaultLogLevel@MetNoFimex@@YAXW4LogLevel@Logger@1@@Z) referenced in function main




//Boost
#include <boost/version.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/test/unit_test.hpp>
//C++
#include <vector>
#include <fstream>
#include <iostream>
//FIMEX
#include <fimex/GribCDMReader.h>
#include <fimex/NetCDF_CDMWriter.h>
#include <fimex/Null_CDMWriter.h>
#include <fimex/Logger.h>
#include <fimex/Data.h></blockquote>
//Qt
#include <qdebug>
#include <QtCore/QCoreApplication></blockquote> 
using boost::unit_test_framework::test_suite;
using namespace std;
using namespace MetNoFimex;

int main(int argc, char *argv[])
    {
	    QCoreApplication a(argc, argv);
       
        string fileName( "GRIB file" );
        vector< string > gribFiles;
	    gribFiles.push_back( fileName );

        defaultLogLevel( Logger::INFO );
 
       return a.exec();
}

推荐答案

你用c ++ / Qt标记了你的问题,但更有用的是什么环境/你用来构建程序的编译器 - 例如



a)* nix with gcc,makefiles

b)带VS2010的Windows,IDE

...



所以我只能给你一个广泛的答案 - 除非FIMEX包含在你的项目的源代码中,你需要链接一个代表FIMEX构建的静态或动态库 - 你指出的错误是



a的症状)没有将正确的FIMEX库链接到你的代码(或根本没有链接)

b)(可能)使用不正确的功能,但我正在运行(a)作为我的第一选择



所以你需要查看FIMEX的文档和/或发行版,识别库对象,并根据你的平台/编译器环境适当地链接它们使用
You've tagged your question with c++/Qt, but what would be more useful is what environment/compiler you are using to build your program - eg

a) *nix with gcc, makefiles
b) Windows with VS2010, IDE
...

So I can only give you a broad answer - which is, unless FIMEX is included source-code wise into your project, you would need to link against a static or dynamic library that represents the FIMEX 'build' - the error you indicate is symptomatic of

a) not linking the correct FIMEX library into your code (or not linking at all)
b) (possibly) using an incorrect function, but Im running with (a) as my first choice

So you need to look at the documentation and/or distribution for FIMEX, identify the library object(s), and link them appropriately depending on what platform/compiler environment you are using


您需要将您的应用程序与FIMEX库链接。应该在 FIMEX安装期间构建库[ ^ ]。



然后添加库的路径和库名到链接器命令行(在与GCC链接时也可能是GCC命令行)或将它们导出到 LDFLAGS 环境变量。



选项是 -L< path-to-additional-library-directory> -l< library-name> 。请注意,必须指定库名称,不带前导'lib'前缀和任何扩展名。



导出示例(可能不适用于您的系统,检查路径和库name):

You need to link your application with the FIMEX library. The libraries should have been build during FIMEX installation[^].

Then add the path to the libraries and the library names to the linker command line (which may be also the GCC command line when linking with GCC) or export them to the LDFLAGS environment variable.

The options are -L<path-to-additional-library-directory> and -l<library-name>. Note that the library name must be specified without the leading 'lib' prefix and any extension.

An export example (might not work on your system, check path and library name):
export LDFLAGS='-L/usr/local/lib/fimex -lfimex'







我忽略了你使用Qt。

用Qt打开Qt项目文件( *。 pro )并将选项添加到LIBS(只需将它们附加到由空格分隔的现有行的末尾):




I overlooked that you are using Qt.
With Qt, open the Qt project file (*.pro) and add the options to the LIBS (just append them at the end of the existing lines separated by a space):

unix: LIBS += -L/usr/local/lib/fimex/
unix: LIBS += -lfimex


这篇关于如何在C ++中使用Fimex的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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