spree

Hey all, I"m frustrated from working with Visual C++ and libraries :/

I am developing my MFC based project, for which I wanted to add a log system to track my bugs and error msg and etc.,

I have created a static library project and created my Log class:


Re: Visual C++ Language Libraries linkage errors make me CRAYZEEE

einaros

Make sure that your .exe project and all static libraries link the same runtime library. For debug build, all projects should e.g. use "multi-threaded debug", and for release build, all should use "multi-threaded". The setting can be found in your project properties (ALT+F7) -> configuration properties -> c/c++ -> code generation.




Re: Visual C++ Language Libraries linkage errors make me CRAYZEEE

spree

it is already set to multi-threaded mod, and these projects are in the same solution.

Is there a way to "hide" the inclusion of <iostream> so only the log project can see it

 





Re: Visual C++ Language Libraries linkage errors make me CRAYZEEE

einaros

spree wrote:

it is already set to multi-threaded mod, and these projects are in the same solution.

Is there a way to "hide" the inclusion of <iostream> so only the log project can see it

Make sure that only the source files which need the iostream header, includes the iostream header. You should also be very careful letting the .exe project include files from the static library, and under no circumstances should you go the other way (static library including headers from the .exe proj).

By multi-threaded I assume you mean that neither of your projects use the "* dll" option for the runtime library






Re: Visual C++ Language Libraries linkage errors make me CRAYZEEE

spree

einaros wrote:

Make sure that only the source files which need the iostream header, includes the iostream header.

But how do I accomplish this when at the declaration of my log class I have to declar an ostream object

class Log

{

std::ofstream file;

...




Re: Visual C++ Language Libraries linkage errors make me CRAYZEEE

einaros

spree wrote:

But how do I accomplish this when at the declaration of my log class I have to declar an ostream object

In some cases you simply cannot get around it; the definition simply has to be present. With the STL, this will generally not produce errors such as the one noted in your initial post.

spree wrote:

And I do use dll's but staticly linked from the complier ( pragma comment(lib,"mydll.lib") ... )

That wasn't what I meant. If you check the runtime library setting in the Project properties -> Configuration properties -> C/C++ -> Code generation, you will see that a few of the options use DLL's, while the others use static libraries. You must make sure that all the libraries in your solution either uses the DLLs, or the static libraries. Don't select an "DLL"-option for one project and non-dll for another.






Re: Visual C++ Language Libraries linkage errors make me CRAYZEEE

spree

I resolved the problem for now by going to the projects properties>linker>input>Ignore Specific Library>msvcrtd.lib

Are there some books or tutorial on the matter of how to correctly use includes :P





Re: Visual C++ Language Libraries linkage errors make me CRAYZEEE

einaros

For one, I just noticed a post made by Marius Bancila in another thread: http://www.codeguru.com/forum/showthread.php t=296307. Otherwise I'd recommend you to get a good C++ reference book.