如何#包括第三方库 [英] how to #include third party libraries

查看:290
本文介绍了如何#包括第三方库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经建造和安装一个名为 OhNet 库。后使安装框架的相应的头文件已根据安装USR /本地/包括/ ohNet 。现在我想使用图书馆在我的C ++项目(我使用的Eclipse),但是当我尝试包括一些头文件,月食是无法找到这些文件。
据我所知Eclipse应该会在这些目录中搜索头文件(/ usr / include目录是/ usr /本地/包括......)默认情况下....什么我必须做使用图书馆?
我是pretty新的C ++和以前没有使用第三方来源。

感谢您。

- EDIT--
我只是想编写一个简单的HelloWorldPROGRAMM来验证我已经正确包含了框架。为了做到这一点,我想instatiate类 OpenHome ::网:: DvDeviceStdStandard 。请参阅: ohNet C ++参考

我现在可以包括使用头文件:
的#include< ohNet / OpenHome /网/核心/ DvDevice.h> 这工作正常。但是,如何创建类型的对象 OpenHome ::网:: DvDeviceStdStandard ?现在? Eclipse中说,这种类型不能得到解决。 :(

 的#include<&iostream的GT;
#包括LT&; ohNet / OpenHome /网/核心/ DvDevice.h>使用命名空间std;诠释主(){    OpenHome ::网:: DvDeviceStdStandard装置; //类型不能得到解决
    COUT<< !!!你好,世界!!! << ENDL;
    返回0;
}



  1. 使用 -I 编译器选项指向第三方库目录( -I在/ usr /本地/包括/ ohNet

  2. 使用的#include.H [无论你从oHNet需要]按需在你的头文件和编译单元(注意:您可能需要将相对preFIX pathes为subdirecories在第三方这里包含路径树!)

  3. 使用 -L 链接器选项来指定到你需要的第三方库的路径( -L在/ usr / local / lib目录可能)

  4. 使用 -l <​​/ code>链接器选项来指定你需要的任何具体的第三届库( -l [oHNet] 可能)

在看什么是真正被安装在那里的目录,图什么地方 [无论你从oHNet需要] .H [oHNet] ,s.th.像 liboHNet.a 后者。

您没有标记[标签:Eclipse CDT的]在此明确,只好到工程 - >属性 - > C ++ Builder->设置对话框,并查找C / C ++包括和链接器选项

I have built and installed a library called OhNet. After make install the corresponding header files of the framework have been installed under usr/local/include/ohNet. Now I want to use the Library in my C++ project (i am using eclipse) but when i try to include some header files, eclipse is not able to find the files. As far as i know eclipse should search for header files in these directories (/usr/include , /usr/local/include ,...) by default.... What do i have to do to use the library? I am pretty new to C++ and haven't used third party sources before.

Thank you.

--EDIT-- I simply want to write an easy "helloworld" programm to verify that i have included the framework correctly. In order to do that i want to instatiate the class OpenHome::Net::DvDeviceStdStandard. see: ohNet C++ reference

I can now include the header file using: #include <ohNet/OpenHome/Net/Core/DvDevice.h> That works fine. But how can i create an object of type OpenHome::Net::DvDeviceStdStandard ? now? Eclipse says that this type cannot be resolved. :(

#include <iostream>
#include <ohNet/OpenHome/Net/Core/DvDevice.h>

using namespace std;

int main() {

    OpenHome::Net::DvDeviceStdStandard device; //type cannot be resolved
    cout << "!!!Hello World!!!" << endl;
    return 0;
}

解决方案

  1. Use the -I compiler option to point to the 3rd party libraries directory (-I/usr/local/include/ohNet)
  2. Use #include "[whatever you need from oHNet].h" in your header files and compilation units as needed (Note: you might need to put relative prefix pathes for subdirecories in the 3rd party include paths tree here!)
  3. Use the -L linker option to specify a path to the 3rd party libs you need (-L/usr/local/lib probably)
  4. Use the -l linker option to specify any concrete 3rd libs you need (-l[oHNet] probably)

Look in the directories what actually was installed there to figure what to place for [whatever you need from oHNet].h and [oHNet], s.th. like liboHNet.a for the latter.

You didn't tag [tag:Eclipse CDT] explicitly here, but go to the Project->Properties->C++ Builder->Settings Dialog and look for C/C++ Includes and Linker Options.

这篇关于如何#包括第三方库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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