What is the purpose of Browse Information generated by Visual Studio - c++

I got a huge C++ third-party project with set of project in one solution. So build time is rather long and Browse Information generation takes a lot too. So what is the purpose of Browse Information? What functionality will be lost if i disable Browse information generation?

Visual Studio 6 required browse information to do the things that Doug T. mentioned.
Newer versions of visual studio can use the browse information file, but by default use a newer Intellisense database. For those versions, there is basically an Intellisense daemon that builds the database in the background instead of being directly embedded in the build process. It really helps to have more than one processor or core when using Intellisense. Otherwise it can really bog down your system.

From here
Select Generate Browse Info under the
C/C++ project settings tab, for any
source-files that you want to be
included. This is very useful for
searching for function definitions and
declarations - just right-click a
function / variable and select "Goto
Definition Of..." and the IDE will
take you straight there.
You will lose some ability to easily navigate your code. This may matter a lot in a very large code base. I know that without it and tools like Visual Assist X, I would be lost. Still, Visual Studio has a very efficient find-in-files operation that cannot be completely replaced with browsing tools.

Related

How to compile c++ without needing a [duplicate]

My current preferred C++ environment is the free and largely excellent Microsoft Visual Studio 2005 Express edition. From time to time I have sent release .exe files to other people with pleasing results. However recently I made the disturbing discovery that the pleasing results were based on more luck that I would like. Attempting to run one of these programs on an old (2001 vintage, not scrupulously updated) XP box gave me nothing but a nasty "System cannot run x.exe" (or similar) message.
Some googling revealed that with this toolset, even specifying static linking results in a simple hello-world.exe actually relying on extra .dll files (msvcm80.dll etc.). An incredibly elaborate version scheming system (manifest files anyone?) then will not let the .exe run without exactly the right .dll versions. I don't want or need this stuff, I just want an old fashioned self contained .exe that does nothing but lowest common denominator Win32 operations and runs on any old win32 OS.
Does anyone know if its possible to do what I want to do with my existing toolset ?
Thank you.
For the C-runtime go to the project settings, choose C/C++ then 'Code Generation'. Change the 'runtime library' setting to 'multithreaded' instead of 'multithreaded dll'.
If you are using any other libraries you may need to tell the linker to ignore the dynamically linked CRT explicitly.
My experience in Visual Studio 2010 is that there are two changes needed so as to not need DLL's. From the project property page (right click on the project name in the Solution Explorer window):
Under Configuration Properties --> General, change the "Use of MFC" field to "Use MFC in a Static Library".
Under Configuration Properties --> C/C++ --> Code Generation, change the "Runtime Library" field to "Multi-Threaded (/MT)"
Not sure why both were needed. I used this to remove a dependency on glut32.dll.
Added later: When making these changes to the configurations, you should make them to "All Configurations" --- you can select this at the top of the Properties window. If you make the change to just the Debug configuration, it won't apply to the Release configuration, and vice-versa.
I've had this same dependency problem and I also know that you can include the VS 8.0 DLLs (release only! not debug!---and your program has to be release, too) in a folder of the appropriate name, in the parent folder with your .exe:
How to: Deploy using XCopy (MSDN)
Also note that things are guaranteed to go awry if you need to have C++ and C code in the same statically linked .exe because you will get linker conflicts that can only be resolved by ignoring the correct libXXX.lib and then linking dynamically (DLLs).
Lastly, with a different toolset (VC++ 6.0) things "just work", since Windows 2000 and above have the correct DLLs installed.
In regards Jared's response, having Windows 2000 or better will not necessarily fix the issue at hand. Rob's response does work, however it is possible that this fix introduces security issues, as Windows updates will not be able to patch applications built as such.
In another post, Nick Guerrera suggests packaging the Visual C++ Runtime Redistributable with your applications, which installs quickly, and is independent of Visual Studio.

How to organize dependencies in Visual Studio 2010 C++ best?

I am new to Visual Stuido and I want to know how to organize the dependencies of a project in Visual Studio 2010 C++ (Express Edition) best.
The main problem is the following:
A project P requires lib L, so I add dependecy L to P. L is somewhere located at my system. I submit P to our version control. My colleague checks P out, but the configuration of P does not fit to his system (L is located somewhere else at his system). So he adjusts the configuration and submits the changes to P. I check P out and now it does not fit to my system.
I come from Java and Eclipse. In Eclipse you can set a variable globally for the whole IDE f.e. PATH_TO_L. In the project configuration the dependency is now variable PATH_TO_L and not anymore a path. So my colleague and I can use the exact same sources including the project configuration. All we have to do is to set both the variable PATH_TO_L. Nice.
Even nicer is Maven. So you do not have to care about copying the right dependencies to the right locations, because Maven does all the work for you.
I searched a little bit for a solution. One possible solution would be to use Property Sheets and to add a template Property Sheet to our version control. But templates in version control are not comfortable to use and I would have to adjust the settings for every project. Not a global setting.
I tried to use system environment variables, but I think Visual Studio 2010 does not use them.
So here is the question. How do you organize your projects in Visual Studio 2010? Is there an ideal way? Is there something like Maven, or is there a possibilty to use an repository manager like nexus in Visual Studio?
You are on the right track, with the property sheets.
You could use a property sheet to reference a environment variable. An example is here.
I would add the Path of library to the user specific property file named Microsoft.Cpp.<platform>.user. As this is included by default. More information is here.
As soon as you get familiar with the property sheets it not as bad as it seems. I actually start to like the msbuild system. But I am not aware of anything like maven for msbuild.
Quite a lot of people are using meta-build systems, these days, such as CMake, SCons...
Amongst other useful features, you can set up some variables that you can later reuse, for example for paths. This way, your colleague and yourself will have the same CMake configuration, but with individualised paths.
And, as these scripts are simple text files, they play nicely with version control (much better than MSVC xml configuration)

Import Existing C++ Source Code into Visual Studio

I am trying to import an existing c++ application's source into visual studio to take advantage of some specific MS tools. However, after searching online and playing with visual studio, I cannot seem to find an easy way to import existing c++ source code into visual studio and keep it structurally intact.
The import capacity I did find flattens out the directories and puts them all into one project. Am I missing something?
(This is all unmanaged C++, and contains specific builds for win/unix)
With no project/solution loaded, in Visual Studio 2005 I see this menu item:
File > New Project From Existing Code...
After following the wizard, my problem is solved!
Switching the "Show All Files" button shows the complete hierarchy with all directories and files within.
If the New Project From Existing Code... option isn't available, you'll need to add it in Tools > Customize...
I am not aware of any general solution under the constraints given - specifically having to create many projects from a source tree.
The best option I see is actually creating the project files by some script.
Creating a single project manually (create empty project, then add the files),
Configure it as close as possible as desired (i.e. with precompiled headers, build configurations, etc.)
Use the .vcproj created as skeleton for the project files to be created
A very simple method would file list, project name etc. with "strange tokens", and fill them in with your generator. If you want to be the good guy, you can of course use some XML handling library.
Our experience: We actually don't store the .vcproj and .sln in the repository (git) anymore, but a python script that re-genrates them from the source tree, together with VS 2008 "property sheet templates" (or whatever they are called). This helps a lot making general adjustments.
The project generation script contains information about all the projects specialties (e.g. do they use MFC/ATL, will it create DLL or an EXE, files to exclude).
In addition, this script also contains dependencies, which feeds the actual build script.
This works quite well, the problems are minor: python requried in build systems, not forgetting to re-gen the project files, me having to learn some python to make adjustments to some projects.
#Michael Burr "How complex are the python scripts and whatever supporting 'templates' you might need?"
I honestly can't tell, since I gave the task to another dev (who picked python). The original task was to provide a build script, as the VS2008 solution build was not good enough for our needs, and the old batch file didn't support parallelization. .vcproj generation was added later. As I understand his script generates the .vcproj and .sln files from scratch, but pulls in all the settings from separate property sheets.
Pros:
Adding new configurations on the fly. Some of the projects already had six configurations, and planning for unicode support meant considering doubling them for a while. Some awkward tools still build as MBCS, so some libs do have 8 configs now. Configuring that from hand is a pain, now it just doesn't bother me anymore.
Global changes, e.g. moving around relative project paths, the folder for temp files and for final binaries until we found a solution we were happy with
Build Stability. Merging VC6 project files was a notable source of errors for various reasons, and VC9 project files didn't look better. Now things seem isolated better: compile/link settings in the property sheets, file handling in the script. Also, the script mostly lists variations from our default, ending up easier to read than a project file.
Generally: I don't see a big benefit when your projects are already set up, they are rather stable, and you don't have real issues. However, when moving into the unknown (for us: mostly VC6 -> VC9 and Unicode builds), the flexibility reduced the risk of experiments greatly.
Create a new empty solution and add your source code to it.
For example,
File>New>Project...
Visual C++>Win32>Win32 Console Application
Application Settings>
- Uncheck "Precompiled Header"
- Check "Empty Project"
Project is then created. To add existing code:
Project>Add Existing Item...>
- Select file(s) to add
Recompile, done!
In the "Solution Explorer" you can click on the "Show All Files" button to have Visual Studio display the files as they exist on the file system (directories and all).
In my opinion this is an imperfect workaround, but I believe it's the best available. I'm unaware of a plug-in, macro or other tool that'll import a directory into an actual project with folders that mirror the file system's.
I know this question is already marked correct, but I was able to import existing code into a project with Visual Studio 2008 by doing "File" -> "New Project from existing code". The directory structure of my code was retained.
You can always switch view from project menu
For eg. Project->Show All Files
The above will display the files in unformated raw file system order
Not sure of older versions but it works on VS 2010
I understand you, I have the same problem: many .cpp and .h files organized in many folders and subfolders with include paths written for this folder structure. The only way you can do to import this folder structure together with the source files is to use "Show All Files" and then right-click on folders and select "Import in Project". This works for me when I am using C-Sharp projects. But it does not work for my C++ Projects. I am still searching for a solution...

Setting file version number in Visual Studio 2005 C++

Can anyone point me in the right direction how to configure Visual Studio 2005 with our C++ console project how we can include a 'File Version' in the details section of the file properties.
I've tried resource files without any luck. This is with a C++ project just for clarification, and big thank you for the guys you responded with C# suggestions.
Thanks in advance.
If you are talking about unmanaged c++, you need to add a version resource to the project.
right-click on the project, choose add - Resource.... Choose Version and press new.
There you can enter all info you need.
You have to have one VS_VERSION_INFO section in your resource (*.rc) file(s) that compile into your project.
In the Visual Studio 2005 Solution Explorer, open the context menu on your C++ project and choose Add, Resource.
Mark Version and click "New".
Fill in the fields as desired and save the file.
Build.
Now your project output has a FileInfo resource.
Please be aware that Windows Vista does not show all available version info in the Explorer context menu's "Details" tab.
For c++ projects I use StampVer and call it as a post build operation including check in/out of revision control for release builds.
Unless you have a good reason for your file version to be different than the version of the assembly inside, I think it is a better idea to provide the AssemblyVersion alone. If you do not specify an AssemblyFileVersion, it will automatically get the same value, so you can see your assembly's version directly in the file's properties.
The advantage is that you can use a wildcard and allow the version to be automatically incremented, so that every time you compile the library you get a different build and/or revision number. As far as I can tell, this trick does not work with AssemblyFileVersion, so you have to increment it by hand.
Of course, all this only applies if you're writing .NET code. Are you by any chance talking about a project using unmanaged code?

How do I make a fully statically linked .exe with Visual Studio Express 2005?

My current preferred C++ environment is the free and largely excellent Microsoft Visual Studio 2005 Express edition. From time to time I have sent release .exe files to other people with pleasing results. However recently I made the disturbing discovery that the pleasing results were based on more luck that I would like. Attempting to run one of these programs on an old (2001 vintage, not scrupulously updated) XP box gave me nothing but a nasty "System cannot run x.exe" (or similar) message.
Some googling revealed that with this toolset, even specifying static linking results in a simple hello-world.exe actually relying on extra .dll files (msvcm80.dll etc.). An incredibly elaborate version scheming system (manifest files anyone?) then will not let the .exe run without exactly the right .dll versions. I don't want or need this stuff, I just want an old fashioned self contained .exe that does nothing but lowest common denominator Win32 operations and runs on any old win32 OS.
Does anyone know if its possible to do what I want to do with my existing toolset ?
Thank you.
For the C-runtime go to the project settings, choose C/C++ then 'Code Generation'. Change the 'runtime library' setting to 'multithreaded' instead of 'multithreaded dll'.
If you are using any other libraries you may need to tell the linker to ignore the dynamically linked CRT explicitly.
My experience in Visual Studio 2010 is that there are two changes needed so as to not need DLL's. From the project property page (right click on the project name in the Solution Explorer window):
Under Configuration Properties --> General, change the "Use of MFC" field to "Use MFC in a Static Library".
Under Configuration Properties --> C/C++ --> Code Generation, change the "Runtime Library" field to "Multi-Threaded (/MT)"
Not sure why both were needed. I used this to remove a dependency on glut32.dll.
Added later: When making these changes to the configurations, you should make them to "All Configurations" --- you can select this at the top of the Properties window. If you make the change to just the Debug configuration, it won't apply to the Release configuration, and vice-versa.
I've had this same dependency problem and I also know that you can include the VS 8.0 DLLs (release only! not debug!---and your program has to be release, too) in a folder of the appropriate name, in the parent folder with your .exe:
How to: Deploy using XCopy (MSDN)
Also note that things are guaranteed to go awry if you need to have C++ and C code in the same statically linked .exe because you will get linker conflicts that can only be resolved by ignoring the correct libXXX.lib and then linking dynamically (DLLs).
Lastly, with a different toolset (VC++ 6.0) things "just work", since Windows 2000 and above have the correct DLLs installed.
In regards Jared's response, having Windows 2000 or better will not necessarily fix the issue at hand. Rob's response does work, however it is possible that this fix introduces security issues, as Windows updates will not be able to patch applications built as such.
In another post, Nick Guerrera suggests packaging the Visual C++ Runtime Redistributable with your applications, which installs quickly, and is independent of Visual Studio.