简体   繁体   English

静态链接 boost program_options

[英]Statically linking boost program_options

One of the few Boost libraries that are not header only (therefore need to be compiled separately) is program_options.为数不多的不只是头文件(因此需要单独编译)的 Boost 库之一是 program_options。

I need to run a program that I compile on my PC in a cluster that has no Boost installed.我需要在没有安装 Boost 的集群中运行我在 PC 上编译的程序。 I don't have administrative rights to install Boost and contacting the cluster's admin is too burocractic and slow.我没有安装 Boost 的管理权限,联系集群管理员太粗鲁和缓慢。

How can I compile my program in my PC (which has Boost) such that it includes program_options (I think this is called static linking)?如何在我的 PC(具有 Boost)中编译我的程序,使其包含 program_options(我认为这称为静态链接)?

Now, I plan to run several instances of my program.现在,我计划运行我的程序的几个实例。 Is static linking the best approach?静态链接是最好的方法吗? Every instance of my program will load a separate instance of program_options, which is wasteful.我的程序的每个实例都会加载一个单独的 program_options 实例,这很浪费。 Is there a better alternative?有更好的选择吗? Some sort of "local dynamic linking" that I can setup on the cluster without root access?我可以在没有root访问权限的情况下在集群上设置某种“本地动态链接”?

You can compile and install Boost, or just Boost Options, as a local user.您可以作为本地用户编译和安装 Boost,或仅安装 Boost Options。 Then compile your program against this local version.然后针对这个本地版本编译你的程序。 Finally, run your code with an updated LD_LIBRARY_PATH environment variable that includes where the Boost Options library lives.最后,使用更新的 LD_LIBRARY_PATH 环境变量运行您的代码,其中包括 Boost Options 库所在的位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM