如何安装第三方库 [英] How to install third party libraries

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

问题描述

我是C ++的新手,我决定尝试使用 odeint 做一些模拟,因为python对我的需求太慢了。



我发现此包< a>,我想玩。我只是不完全确定如何安装或在哪里放置这些库。是否有类似于 pip install



C ++ p>边注:我试图这样做使用 Eclipse Kepler ,但我没有结婚的想法。

解决方案

我建议不要把代码放入你自己的项目 - 这是一个相当快速和肮脏的解决方案。在C ++中使用库的正确方法(事实上,在我知道的任何编程语言中)是在文件系统单独位置

保持所有库与您自己的项目分离。 >

然后告诉你的环境在哪里找到库文件,并告诉你的项目使用它们。它总是相同的基本想法,无论你使用Makefile或Visual Studio项目文件。



查看此库的文档。它说:


odeint是一个只有标题的库,没有链接到预编译的代码
是必需的


这意味着我刚才提到的库文件只是头文件。这让你更容易,因为你不必处理链接器选项。在C ++中,可以找到其他(项目外部)头文件的位置通常称为包含路径。



因此,您的新问题应该是:如何告诉Eclipse Kepler我的包含路径?



将这个新问题输入Google(如eclipse kepler include path)会产生一些有趣的结果。它最终会引导您访问 Eclipse文档关于包含路径,您可以在其中了解如何编辑C ++包含路径。



现在,一切都已设置完毕,您可以使用库的头文件在您的项目中通过如下行:

  #include< boost / numeric / odeint.hpp> 

您注意到< > ?他们有很大的区别,因为他们是C ++的方式说这不是我的项目的一部分,请从我的包含路径。就像标题是语言的一部分(例如< vector> < iostream> )。 p>

所有这些可能在开始时看起来很麻烦,也许你甚至在开始时从中获得一点点,但是从长远来看,对于许多不同的项目和许多不同的库,是防止混乱的唯一方法。


I'm sorta new to C++ and I've decided to try and use odeint to do some simulations because python is too slow for my needs.

I found this package, which I want to play with. I'm just not totally sure how to install or where to place these libraries. Is there something for C++ similar to python's pip install?

Side note: I'm trying to do this using Eclipse Kepler, but I'm not married to that idea.

解决方案

I recommend not putting the code into your own project - that is a rather quick and dirty solution. The correct way to use a library in C++ (in fact, in any programming language that I know) is to keep all libraries separate from your own projects, at a separate location on your filesystem.

You then tell your environment where to find the library files and tell your project to use them. It's always the same basic idea, whether you are using Makefiles or Visual Studio project files.

Look at the documentation of this library. It says:

odeint is a header-only library, no linking against pre-compiled code is required

This means that the "library files" I just mentioned are just header files. That makes it much easier for you, because you don't have to deal with linker options. In C++, the location where additional (project-external) header files can be found is usually called the "include path".

Your new problem should therefore be: How to tell Eclipse Kepler my include path?

Entering this new problem into Google (as "eclipse kepler include path") yields a few interesting results. It will eventually lead you to the Eclipse documentation about include paths, where you can learn how to edit the C++ include path.

Now that everything is set up, you can finally use the library's header files in your projects via lines like the following:

#include <boost/numeric/odeint.hpp>

Do you notice the < >? They make a big difference, because they are the C++ way of saying "this is not part of my project, please get it from my include path". Just like headers which are part of the language (e.g. <vector> or <iostream>).

All of this may appear troublesome at first, and perhaps you even gain little from it at the beginning, but in the long run, for many different projects and many different libraries, it's the only way to prevent chaos.

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

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