0

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.

Narf the Mouse
  • 1,541
  • 5
  • 18
  • 30
  • 1
    If you are new to C++, I highly recommend that you [pick up an introductory C++ book](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list). It does not matter that you have prior coding experience (although it certainly helps), you must learn proper C++ first. You don't necessarily have to be a guru, but you should have some clue as to what good C++ looks like. Then you can toy around with the class library and/or the Windows API. – In silico Feb 16 '11 at 10:54
  • @In silico: I, more or less, agree with you. But since he's got programming experience, he might pick things up as he goes (hopefully). @Narf: If you're a newbie to C++ it's also wise, as In silico says, to read and learn a bit more about C++. I do have an answer for you. But I don't know how much of it you'll be able to pick-up. Depends on your understanding of C++ really. Copy-pasting might work but then you wouldn't know how things work internally. – Vite Falcon Feb 16 '11 at 10:59
  • I am planning on doing that; just that my reading list is rather large at the moment. Bashing my head against this, however, is a break from bashing my head against the inefficiencies in pathing of my STRIPS implimentation in C#, when that book hasn't arrived yet (And is currently almost on the other side of the country, if Amazon's tracker is to be believed). – Narf the Mouse Feb 16 '11 at 11:20

1 Answers1

2

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.

Vite Falcon
  • 6,575
  • 3
  • 30
  • 48
  • Ok, thanks, that was thorough and what I was looking for. Unfortunately, it's now complaining of a missing .lib file - Rightly so, as no such .lib file exists. In fact, no .lib files exist in the solution at all. – Narf the Mouse Feb 16 '11 at 11:14
  • If you created a DLL file, then you need to export your class for the project to be able to create a lib file. Lib files contains definitions of variables, functions and classes exposed, be it DLL or static library. But with DLL you need to explicitly mention that a class, function or variable is exposed. Read about __declspec(dllexport) and __declspec(dllimport). If you're looking to expose a static library, make sure that the project is of the right type and then in the solution set your exe to be dependent on the static library. Linking should be automatically done for you. – Vite Falcon Feb 17 '11 at 10:26