如何创建一个真正独立的库 [英] How do I make a truly self-contained library

查看:93
本文介绍了如何创建一个真正独立的库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我已经构建了一个静态库,它包含一些围绕FORTRAN例程的c ++包装器。我的希望是,一旦我在具有FORTRAN编译器的PC上构建了库,我可以将我的静态库与我的应用程序在另一台PC上链接,而无需安装FORTRAN编译器,但是当我尝试构建应用程序时,它是说它找不到ifconsol.lib这是FORTRAN编译的库文件之一。



有没有办法让我的lib真正自包含或者我总是需要将FORTRAN编译器安装在同一台PC上?



我还没有到达运行应用程序的阶段所以它可能会要求一些FORTRAN DLL另外,但我认为这些是可再发行的,所以可以合法安装。



谢谢

解决方案

问题你看到的是,在你真正在exe(或dll)中使用它之前,静态库不会真正将它的依赖关系链接起来。但是,动态库确实会产生独立的二进制文件(对象文件),所以你应该可以这样做。



如果你想要但是坚持使用静态方法,依赖于lib与需要整个编译器不同,因此将lib用作项目中的依赖项是有效的。


I想出了解决方案。



看来链接器所需的FORTRAN库文件实际上包含在可再发行组件包中,但Visual Studio没有提取它们。我必须在Visual Studio的目录中添加FORTRAN可再发行文件夹的完整路径。如果有人有类似的问题,目录设置在......



工具 - >选项>项目和解决方案 - > VC ++目录 - >图书馆文件

Hi,

I have built a static library which consists of a c++ wrapper around some FORTRAN routines. My hope was that once I had built the library on a PC wich has the FORTRAN compiler, I could link my static library with my app on another PC without having to have the FORTRAN compiler installed but when I try to build the app, it is saying it cannot find ifconsol.lib which is one of the FORTRAN compile's library files.

Is there a way to make my lib truly self-contained or will I always need to have the FORTRAN compiler installed on the same PC?

I haven't got to the stage of getting a running app yet so it may well ask for some FORTRAN DLLs also but I think these are redistributable and so can legally be installed.

Thanks

解决方案

The problem you're seeing is that a static library won't really have it's dependencies linked until you actually use it in an exe (or dll). A dynamic library however, does result in a binary (versus object files) that is independent, so you should be able to do that.

If you'd like to stick to using the static method however, being dependent on a lib is not the same as requiring a whole compiler, so it is valid to use the lib as a dependency in the project.


I figured out the solution.

It appears that the FORTRAN library files needed by the linker are in fact contained in the redistributable package but Visual Studio was not picking them up. I had to add the full path to the FORTRAN redistributable folder in Visual Studio's 'Directories'. In case anyone has a similar problem, the directory settings are under...

Tools->Options>Project and Solutions->VC++ Directories->Library Files


这篇关于如何创建一个真正独立的库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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