开发者

How do I use a Win32 Class Library in a Win32 Application in Visual Studio 2010 Express?

As stated, I'm trying to use the class library in the application.

Specifically, I've got a (very small) test Console class with one Write(std::string) function. I want to access the class library, access the Console class and successfully send a std::string to the Write function开发者_如何学运维.

I don't, specifically, need to know how to use a class or a function (I'm a C++ newbie only, not a coding newbie), just get my library working with my application in VSE.

Not sure what else to add, but I'm not that good at figuring out what to add and, in this case, I'm not even sure what questions to ask.

Thanks.


First of all you need to decide how you wish to link your 'library' code. Do you want it to be static or dynamic? Static linking means the library you wrote gets 'merged' with your exe. So your exe file will be:

size-of-exe-code + size-of-lib (roughly, just remember that the exe size increases with the lib)

With the dynamic link approach (DLL), you have a DLL version of your console library (console.dll) and a lib file (console.lib). I'm not going to explain how to code a DLL because there is a bit of reading to do. (Also google to find out more). With the DLL version your exe size wouldn't increase size with your library because the DLL contains that part of the code and gets linked dynamically at runtime, while with static linking, it's done when linking the exe and creating it (more or less).

The simplest is to statically link your console library. Hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜