MSVC 6.0 and .lib files

Started by
8 comments, last by shdaga 21 years, 8 months ago
Currently every time I make a new project, I have to go to the project settings->linker tab, and add all of the directX .libs, plus any other pertinent .libs. I was wondering if there was a way to do this once, and have every project I make from then on automaitcally find em. I''ve already tried copying the directX .libs to the MSVC lib folder, but that seems to have no effect so far. Any suggestions? Thanks.
Here's a new dance everyone can do, do the Kirby:<(*.*<) <(^.^)> (>*.*)> <(^.^)> <(*.*<) (>^.^)>
Advertisement
Yes there is a solution.

When you write your engine, create a header file you will include in all of your (future) projects. This file contains all the lib you need to link :


...

// Librairies to link
#pragma comment(lib,"dxguid.lib")
#pragma comment(lib,"dxerr8.lib")
#pragma comment(lib,"ddraw.lib")
#pragma comment(lib,"dsound.lib")
#pragma comment(lib,"d3d8.lib")
#pragma comment(lib,"dinput8.lib")
// add any other lib you want ...
...




__________________________



Bruno Wieckowski
Lead Programmer
Exood4 Studios
Thanks for the reply. Would I still have to use #includes as well in the header file, or do the #pragma statements replace em?
Here's a new dance everyone can do, do the Kirby:<(*.*<) <(^.^)> (>*.*)> <(^.^)> <(*.*<) (>^.^)>
Wait,I see what you mean now. Just create a header file, like directX.h or something and in that file put all the #pragmas, and then include it in all of my other engine files. Is this correct?
Here's a new dance everyone can do, do the Kirby:<(*.*<) <(^.^)> (>*.*)> <(^.^)> <(*.*<) (>^.^)>
I have a question: Do I need to include those #pragmas in every CPP file, or just one? It makes sense to just have it once, because the linker only gets called once
I typically put those in my Stdafx.cpp file -- I don''t know if it''s a good idea to put them in a header file that''s included more than once, but I suspect that probably works okay too. Putting them in Stdafx.cpp -- or any other .cpp file -- works perfectly.

Cheers, dorix
Thats funny, it didn''t work no matter where I put it
Nope, doesnt seem like the #pragma had any effect except to make my project un-linkable...
Here's a new dance everyone can do, do the Kirby:<(*.*<) <(^.^)> (>*.*)> <(^.^)> <(*.*<) (>^.^)>
You also have to make sure that the path to your DirectX libraries is known to the compiler. In Tools/Options/Directories, click the drop-down box and choose Libraries, and make sure DirectX is there.

I also slightly misunderstood your original question. If you use the #pragma comment lines, they have to be in a file that''s compiled or #included in every project you do.

Cheers, dorix
I use the #pragma comment(lib,...) method all the time. works like a charm
daerid@gmail.com

This topic is closed to new replies.

Advertisement