Archived

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

PyroBoy

VC++ 6 Code Generation Settings

Recommended Posts

I''m building a library that staticly links to another library that was compiled with the "Multithreaded DLL" code generation setting. I want the lib I''m building to be staticly linkable without having to switch the code generation settings on the target project. Is there any way at all to accomplish this scenario without making at least one step (my lib''s link to the external lib or the target''s link to my lib) a dynamic link?

Share this post


Link to post
Share on other sites
You really need to have everything in the project link to the same library, either static or DLL. Otherwise Bad Things may happen, especially if the library and its users exchange pointers to dynamic memory.

So the answer is that you either need to modify the library you''re linking against to make it use the static CRT, or else modify your own library to use the DLL version. If you''re writing your own DLL it''s generally best to use the DLL version.

--
Eric

Share this post


Link to post
Share on other sites
Check out the sweet snipptes section. I have an article that describes a method of doing so.

However, the more I work with static libraries, the more I am convinced they should not be distributed. It''s less hassle to give the users the source and let the recompile from there.

Share this post


Link to post
Share on other sites
You mean this?:
http://www.gamedev.net/reference/articles/article1316.asp

I don''t see how that relates to my question, but perhaps I picked the wrong article...

>>You really need to have everything in the project link
>>to the same library, either static or DLL. Otherwise
>>Bad Things may happen, especially if the library and
>>its users exchange pointers to dynamic memory.

I''m not sure what you mean here...


Share this post


Link to post
Share on other sites
ah sorry. Missed that one!

>>My solution is
>>1.Provide 6 different versions of the static library
>>2.Define a naming convention for naming the .lib file.
>>3.Provide a name decoration scheme that links in the
>>correct .lib file based on client project settings

I don''t see how this would work for me, since the issue at hand isn''t just with my library. Like I said, this library links with another static library whose creators apperantly weren''t as enlightened on these issues as you seem to be! :-)

My library is a sound system. The library I''m linking to is the Ogg Vorbis vorbisfile library, and a few other base ogg and vorbis libs. These libs were compiled against the multithreaded runtimes. There are no other versions provided in their SDK.

From what I gather from your article, I assume I''m pretty much hooped unless I can find a version of these other libraries that were compiled against the other c runtimes. Correct?

Share this post


Link to post
Share on other sites
Yes, you are pretty much hooped.

The problem goes much deeper than that. Static libraries for C code is ok. If you are using C++, then

1. the client must use the same compiler. C++ name mangling is non-standard.

2. you force the client to use any 3rd party libs u link to explicitly or implicitly.

A very subtle example is STL library implementation. If your clients use a different STL library, you probably won''t get any linking errors but the results are gonna be ugly.

Share this post


Link to post
Share on other sites