<p>I'm curious about everyones practices when it comes to using or distributing libraries for an application that you write.</p>

<p>First of all, when developing your application do you link the debug or release version of the libraries? (For when you run your application in debug mode)</p>

<p>Then when you run your app in release mode just before deploying, which build of the libraries do you use?</p>

<p>How do you perform the switch between your debug and release version of the libraries? Do you do it manually, do you use macros, or whatever else is it that you do?</p>

[{'answer_id': 46120, 'author': 'Henk', 'author_id': 4613, 'author_profile': 'https://Stackoverflow.com/users/4613', 'pm_score': 2, 'selected': False, 'text': "<p>I would first determine what requirements are needed from the library:</p>\n\n<ol>\n<li>Debug/Release</li>\n<li>Unicode support</li>\n<li>And so on..</li>\n</ol>\n\n<p>With that determined you can then create configurations for each combination required by yourself or other library users.</p>\n\n<p>When compiling and linking it is very important that you keep that libraries and executable consistent with respect to configurations used i.e. don't mix release &amp; debug when linking.\nI know on the Windows/VS platform this can cause subtle memory issues if debug &amp; release libs are mixed within an executable.</p>\n\n<p>As Brian has mentioned to Visual Studio it's best to use the Configuration Manager to setup how you want each configuration you require to be built.</p>\n\n<p>For example our projects require the following configurations to be available depending on the executable being built.</p>\n\n<ol>\n<li>Debug+Unicode</li>\n<li>Debug+ASCII</li>\n<li>Release+Unicode</li>\n<li>Release+ASCII</li>\n</ol>\n\n<p>The users of this particular project use the Configuration Manager to match their executable requirements with the project's available configurations.</p>\n\n<p>Regarding the use of macros, they are used extensively in implementing compile time decisions for requirements like if the debug or release version of a function is to be linked. If you're using VS you can view the pre-processor definitions attribute to see how the various macros are defined e.g. _DEBUG _RELEASE, this is how the configuration controls whats compiled.</p>\n\n<p>What platform are you using to compile/link your projects?</p>\n\n<p>EDIT: Expanding on your updated comment..</p>\n\n<p>If the <strong>Configuration Manager</strong> option is not available to you then I recommend using the following properties from the project:</p>\n\n<ul>\n<li><strong>Linker</strong>-><strong>Additional Library Directories</strong> or <strong>Linker</strong>-><strong>Input</strong></li>\n</ul>\n\n<p>Use the macro <code>$(ConfigurationName)</code> to link with the appropriate library configuration e.g. Debug/Release.</p>\n\n<pre><code>$(ProjectDir)\\..\\third-party-prj\\$(ConfigurationName)\\third-party.lib\n</code></pre>\n\n<ul>\n<li><strong>Build Events</strong> or <strong>Custom Build Step</strong> configuration property</li>\n</ul>\n\n<p>Execute a copy of the required library file(s) from the dependent project prior (or after) to the build occurring.</p>\n\n<pre><code>xcopy $(ProjectDir)\\..\\third-party-prj\\$(ConfigurationName)\\third-party.dll $(IntDir)\n</code></pre>\n\n<p>The macro <code>$(ProjectDir)</code> will be substituted for the current project's location and causes the operation to occur relative to the current project.\nThe macro <code>$(ConfigurationName)</code> will be substituted for the currently selected configuration (default is <code>Debug</code> or <code>Release</code>) which allows the correct items to be copied depending on what configuration is being built currently.</p>\n\n<p>If you use a regular naming convention for your project configurations it will help, as you can use the <code>$(ConfigurationName)</code> macro, otherwise you can simply use a fixed string.</p>\n"}, {'answer_id': 51725, 'author': 'Dewm Solo', 'author_id': 4225, 'author_profile': 'https://Stackoverflow.com/users/4225', 'pm_score': 0, 'selected': False, 'text': '<p>I use VS. The way that I do it is that the libraries I need through the references of the project. Which basically just says in what folder to look for a specific library at project load time. I develop my libraries to be as project independent or reusable as possible. Therefore they are all projects of their own. So of the libraries that I need for a specific project, I create a "3rdParty" or "libs" folder at the same level as my "src" folder in my svn folder tree. I tend to only use released libraries, but when I get some unknown issues and want to switch to debug, I manually copy a debug version of the files in the "lib" folder and reload the project.</p>\n\n<p>I am unsure wether I should be keeping both debug and released versions in my svn tree. Although since they are projects of their own, keeping them in the svn tree of another project doesn\'t right. They can be built again without an hitch at any moment.</p>\n\n<p>And then I wanted to find a way of making the switch more...hmmm...well basically automatic if you while, but that\'s not what I really mean. It just feels that switching the files manually between released and debug isn\'t right. Maybe I haven\'t found it yet, but what I would like is an option that would do like:\nFor library "stack.dll" look in "......\\3rdParty\\" for release and "......\\3rdPartyD\\" for debug.</p>\n\n<p>Anything that those something like I don\'t know. What do you suggest?\nRemember libraries are external projects. There the built files are totally elsewhere. In fact think of it as you have to check out another project, build it, and copy the built library if you want another copy. How would you set that up?</p>\n'}]
['https://Stackoverflow.com/questions/45769', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4225/']