eclipse CDT:copying library paths from debug to release mode - c++

I have been developing a C++ app and running in debug mode, I have now set active build to release mode and have realized that I have to re-add all of the include paths and libraries (there are a lot of them!) is there any way to automatically do this/a bulk copy paste?
Thanks

You can also select "all configurations" in the menu where you set your paths. The typical workflow for setting up a project is to first set "all configurations", do your stuff, and then selectively put in the Debug/Release specific things (like the NDEBUG symbol, or optimizer flags). No copying is required. Note that most good IDEs have this feature (including Visual Studio).

Just figured it out (kinda). You can highlight all libs and copy them, then can just click on the box in the release dialogue and hit paste.

Related

Exclude files from Eclipse Indexing that are included in the build

This question provides good answers to the question of excluding files from indexing that are also excluded from a build. An open question remains: how does one prevent files that are part of the build from populating the code-completion or code-insight functions?
My use-case is a TrueSTUDIO (was System Workbench, was bare Eclipse) project which includes some modules from another project. They are wrapped in safe-to-use stubs and wrappers and should never be called directly. The external modules cannot be edited because they must stay in sync with the other project, so their filenames and other symbols clash confusingly with the current project's. When using code completion to include a header or complete a function name, the filenames and function names of the modules that are not to be used directly appear in the completion lists.
I wish to continue to include the modules in my builds, but not have any of their contents appear in the code-complete/insight features.
I see in Project Properties -> C/C++ General -> Indexer there are options to configure the indexer to use a different build configuration. This is promising, but will probably quickly lead to a indexer that is sorely out of sync with the primary build configuration.
Any advice on a practical method?
The only way I found to exclude files from Eclipse indexing is using the abovementioned Indexer-specific build configuration. In my case, it helped with the annoying problem of indexer freezing on .cu (NVidia CUDA) files.
This is how it works:
Prepare a new (Indexer-specific) build configuration.
Exclude unwanted source files from this configuration using the
Source Location exclude filter.
Let Indexer use this particular build configuration.
Eclipse configuration is a bit tricky with Indexer, so this is a step-by-step guide (as for Eclipse 2021-09):
Preparing a new build configuration:
Project->Build Configurations->Manage->New:
Give it a name, e.g., "4indexer".
Select "Copy settings from" with your preferred configuration. In my case, "Debug" worked just fine.
Excluding unwanted source files:
Project->Properties->Paths and Symbols->Source Location:
Select "4indexer" as the configuration to be managed on the top of the properties window.
Apply an exclusion pattern of your choice. In my case, I added "*.cu" at the end of the "Source Folder Exclusion Patterns" list by clicking Add... button and typing *.cu in the "Add Exclusion Pattern" text field.
Reconfiguring Indexer:
Window->Preferences->C/C++->Indexer:
Allow any Indexer to work with a project-specific build configuration (it was tricky to figure it out): check the "Use the build configuration specified in the project's indexer settings" radio button.
Project->Properties->C/C++ General->Indexer:
Check the "Enable project specific settings".
Select the new build configuration for your project Indexer: check the "Use a fixed build configuration" and select "4indexer" from the drop-down list below.
I also unchecked the "Index source files not included in the build", but I'm not sure if it is necessary.
Sometimes Indexer is trying to reindex a project as you try to reconfigure it, freezing Eclipse. So, I turned it on and off and restarted Eclipse a few times.

Visual C++ 2010 Different configurations for multiple projects

I've got a solution with multiple projects.
Now every project has its own configuration and nearly all projects do even have multiple configurations.
When building the projects I want that all configurations that do exist are built. Is there a way to do this automatically without picking every configurations by hand and start the building process over and over again?
To do it by hand in MSVC GUI you can do the following:
1. Right-click on the solution, in the popup menu go to the menu item "Batch build..."
2. In the dialog that will appear, do "Select all" or just select the projects/configurations you need.
3. Click button "Build" (or "Rebuild" if you prefer a clean build).
You could write an MSBuild or NAnt script (or even a plain old batch file) to compile all the configurations so you don't have to do it all by hand.

Visual studio 2010 - retain project properties between different build configurations?

I have two projects in my solution. I am currently using the default configuration mode which is 'Debug'. When I want to do a 'Release' build, I switch to Release-mode and then I see all my previous projects properties are set to default, meaning I have to add all properties again manually to this mode.
Is there a convenient way to solve this in VS2010, for example to copy all properties like include paths, preprocessor macros, build macros, etc from 'Debug' to 'Release' mode?
Configuration settings are stored in .vcproj / .vcxproj file. You could open it in some text editor and copy some settings manually, but it wouldn't be convenient. For now you could just open projects properties and copy these settings while switching Debug / Release configuration in the upper left corner of that window.
Next time when you are setting properties that are intended to be the same for all configurations, choose Configuration: All Configurations to avoid troubles.
Property sheets can solve this and a few other property-related issues with ease.
In short, all the properties in a project are just nodes in an XML document, and the property group nodes can have a condition attribute. They're easy to change in any text editor, but a lesser-known feature is the ability to import other XML documents, which can provide settings (for all but a few project-specific ones).
This blog post has a good tutorial on using project sheets, and some more info in this question. You can create them in Visual Studio, edit them (including copying your existing project settings over), then attach them to your project with the property manager (not the property window).
The groups in your property sheet use the same syntax as regular settings, and can be set for all configurations or filtered to only apply on some. They can also be filtered by project name and a few other things, using VS' variable and condition system. For example, I use:
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
<Optimization>Disabled</Optimization>
<EnablePREfast>true</EnablePREfast>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
</ClCompile>
</ItemDefinitionGroup>
for some of my builds, to apply the same settings to all project (full file here).
One of the most convenient uses is giving the build directory in the file, so all your projects build uniformly into the same directory (make sure to use the project name for the output).
Managing almost all the properties across multiple different builds (debug, release, win32, x64 etc.) can be accomplished with a single collection of settings by using Macros.
Thus, before editing a project settings, make sure you've set Configurations to All Configurations and, Platform: to All Platforms. Now almost all settings can be done in this way, across all the different configurations. Say, you want different configurations and platforms to use different versions of various libraries. Assuming you are using a naming convention that's consistent across all projects, you can then use:
Additional Library Directories: ..\..\foo\bar\lib\$(Platform)_$(Configuration)
You can see what macros will expand to, by hitting the edit button, and then clicking on the Macros>> button.
You could also recreate the new mode you want using the configuration manager and then you can choose from which configuration you want to copy all the settings.

Using Separate Libs for Debug and Release in VC++

I'm downloading GLFW for use with Visual Studio 2010. I see that the download has a separate folder for Debug and Release builds (each folder has two Libs and one DLL), but the filenames in both folders are the same. How should I configure Visual Studio to pick the right file, since I would expect that renaming a Lib or DLL would interfere. My research has been relatively unfruitful, and I think it may have to do with ifdef commands or something. Thanks in advance.
Visual Studio build properties (including the directories where it searches for files) are all build configuration specific. On the project configuration dialog, just press the drop-down to switch from Debug to Release. The settings you change will affect that particular build configuration and no others.
If you don't have this dropdown, then you're using the non-advanced interface, which no human being should ever use. Switch to the advanced interface.

copy build configuration to release configuration (Eclipse)

Once I have set the include directories and linking directories for an Eclipse project in debug configuration, is there an easy way to copy them over to the release configuration without entering them in again manually (or vice versa)?
In the project properties, in the field Configuration, you should choose between Debug, Release and All Configuration. If you select "All configurations", everything you set will be applied to Debug and Release.
The issue is that, sometimes, include and linking directories depends on the configuration. For instance : ".../Include/Debug" or ".../Include/Release". In this case, you can still use "All Configurations" and write ".../Include/${ConfigName}"
ConfigName is an Eclipse variable that is automatically preset to Debug or Release according to the configuration.
${Var} means that you want to include the value of Var. In the example above, the string will be understand by Eclipse as ".../Include/Debug" or ".../Include/Release" according to the configuration.
You can add your own variable in Properties / C/C++ Build / Build Variables, in order to do more powerful things.