问题描述
我目前有一个控制台项目,它创建一个.exe文件;我想它也创建一个.lib文件,所以其他项目,编译为DLL,将能够从原始项目调用函数。
I currently have a console project which creates an .exe file; I want it to also create a .lib file so other projects, compiled as DLLs, would be able to call functions from the original project.
我知道这是可能的,但我找不到如何做到这一点。如何告诉链接器也链接.lib?
I know it is possible, but I couldn't find how to do that. How do I tell the linker to also link a .lib?
推荐答案
这是不可能的 - 静态库和可执行文件完全不同种类的动物。处理这种情况的方法是创建两个项目 - 一个用于库,其中包含所有功能。和一个用于可执行文件,它是一个简单的调用函数库中的函数的薄包装。
It's not possible in general - static libraries and executables are completely different kinds of animal. The way to handle this situation is to create two projects - one for the library, which contains all the functionality. and one for the executable, which is a thin wrapper that simply calls functions in the library.
这篇关于如何在Visual C ++中创建.lib文件和.exe文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!