Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

dviator

How do I link a static lib when writing my own library?

This topic is 6107 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi.. I''m trying to write a static library that makes use of OpenGL, and I''m unsure of whether I need to link to opengl32.lib or not. I''ve included gl.h in one of the headers. I''m using MSVC++ 6, and in Project/Settings there isn''t a Link tab. So I guess the question is do I, or can I, link a static .lib like opengl32.lib for instance when creating my own static library? This way when I''m using my library I can just add mylib.lib to a project without having to add opengl32.lib as well. I already know about using a pragma comment, is that the only way to do this? Thanks

Share this post


Link to post
Share on other sites
Advertisement
quote:
Original post by dviator
So I guess the question is do I, or can I, link a static .lib like opengl32.lib for instance when creating my own static library?

You can. Whether you should is up to you.

quote:
I already know about using a pragma comment, is that the only way to do this?

You can add the names of libraries to link in Project Settings MSVC).

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!

Share this post


Link to post
Share on other sites
quote:
You can add the names of libraries to link in Project Settings MSVC).


If you create a new Win32 Static Library project in MSVC, there is no Link tab under Project/Settings. Any ideas?

Share this post


Link to post
Share on other sites
#pragma is not necessary (tho, it will work). under your project settings, there is a "library" tab. you can add linker settings there. the preferred method tho, would be to add the ".lib" file to your project files under the project workspace.

right-click on the project and select "add files to project" from the pop-up menu. select "Library Files (.lib)" for the "Files of type" and then locate and add your library file. done deal.

NOTE: "OpenGL32.lib" is NOT a static library file in the sense that your talking about. it''s actually a link to the "OpenGL32.dll" file, but does not contain object information (i.e. data and instructions). a static library (better named "archive") does.

To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!