I work on a large Visual C++ (MFC) project in VS.NET 2005.
I have noticed strange behavior in Visual C++ 2005. Often, I will change one line of code in a .CPP file but many .CPP files will compile as a result of this. I have never seen this until VS.NET 2005. Theortically, changing a line of code in a .CPP file should simply require recompilation of that .CPP file and re-linking of the PE file.
What am I not understanding about the build process.
I found this link helpful when solving a similar problem, was under pressure at the time, I tried a few things and the issue went away, for the life of me I don't know (or can't remember) which - if any - helped.
Hope this helps
This is a strange bug in the VS2005 dependency behavior. To find out one suggestion would be to take the following steps:
Go to Tools -> Options ->
Projects and Solutions -> Build and
Run -> MSBuild Project Build output
Verbosity and select Detailed
Compile your project.
This will give you a detailed output of the build which "may" help you arrive at a solution to your problem.
Related
InstallShield must be the crappiest "industry standard" application in existence, for reasons too numerous to enumerate here. However, one of those deficiencies is something I'd like to be able to fix, and with my first foray into writing an extension for Visual Studio (currently using 2015 version).
InstallShield has created a .isproj type, to allow integration with Visual Studio. This allows a developer to create an installer that references the output of a project as the files to include in the installer (rather than having to manually select individual files to include). This works well enough as long as the .isproj is being built in Visual Studio, and in a solution that references the project for which you need the output.
However, I also have an automated build for my installer projects, that we run on a build server using MSBuild. When attempting to build this way, we were getting completely opaque error messages indicating that the project output references above couldn't be resolved.
As with all InstallShield errors, Googling for answers turned up nothing except for multitudes of other people having the same problem. So I decided to dig into the plain text of the .isproj to see what I could find.
As it turns out, the .isproj type is a just a regular MSBuild script, and it even has lines commented out that explain options that can be added to the project; one of those things that can be added is an ItemGroup containing ProjectReference nodes. Manually adding the nodes helped solve the problem. Command-line build now works.
However, I am dissatisfied with a) having to manually type this stuff in, b) having no visual representation of what projects are being referenced, and c) not finding out about a problem until the build fails. So, I would like to be able to extend Visual Studio to help me with this. Here's what I'd like to do:
1) Add a "References" node to the project in Solution Explorer that acts like the References node for any normal .csproj.
2) Restrict the available References to other projects in the the current solution.
3) Visually represent a project with missing references (e.g. by underlining the project name with a colored squiggly, as with errors/warnings), and potentially failing the build if missing (depending on whether I want to treat it as an error or a warning; TBD).
To these ends, I've downloaded MPF for Projects - Visual Studio 2013, which provides an SDK for creating a new project type.
However, before digging too deeply, I need to know if it's even possible to EXTEND an existing project type, as described above, as I obviously don't have InstallShield source code. Also, any links or guidance as to a starting point for doing so would be greatly appreciated.
I am using Visual Studio 2013 to execute c++ code.I want to see the execution time of my code.
I performed the following activities
Tools -> Options -> Projects and solutions ->VC++ Project Settings->Build timing->yes
**Tools -> Options -> Projects and Solutions -> Build and Run and set the MSBuild project build output verbosity to "Normal"**
but it's not working for me.
I use Squared Infinity's VS Commands Visual Studio extension which has an option to display a build summary in the output window that lists the time each project took to build.
If you want compilation time, as the title of your post suggests, you're in the right direction. You may want to look at this thread for further help.
If you want to know how your code performs at runtime, that's a different story. You can either insert use datetime variables along with print commands in your code to see the elapsed time in a console window (not very pretty or efficient) or use a profiling tool (much better IMHO).
Personally I use RedGate's ANTS Performance Profiler and am quite pleased with it. :) I should mention I never tried it with managed C++ but it should work just fine.
Visual Studio also has a built-in profiling tool, but I never tried it myself. You might want to take a look at it.
Hope that helps.
I am writing a simple C++ application using the Visual Studio IDE and the VC++ compiler.
In this application I have an erroneous file that affects the other files as well. When I compile it, as expected I get errors. Now, if I remove all references to the file from my project, and then run it, the compiler will still exit in an error. In the compile message I then see the filename of the erroneous file. The only way to prevent this from occurring is by either removing all contents of that file, or remove the file, and then recompile it.
My guess is, because VC++ is 'smart' it saves compilations and when they are unaffected it doesn't recompile it. But because the erroneous file affects the other files, some compile errors (not all) simply stay.
Does anyone know how to disable such behaviour?
Can you show the errors ?
If the file contains actual functional code then fix the compilation errors ?
If the file does not contain functional code, then what is it doing in your project.
I expect this "erronous" file to be a header (.h) file that is included in other c++ files, so when it tries to compile the c++ files it will generate an error (or more) per c++ file.
If you just remove the file from the IDE project; the compiler will still include the file (because it still exists on disk); and will continue generating errors.
If you actually remove the file on disk, then you will have other types of errors.
In all cases, just fix the compilation errors.
To recompile all files you can rebuild all, or make a clean build.
Yes VC++ will save compilations if things have not changed, it will probably say up to date.
I don't think that you can disable it, but a clean build should be able to solve it. If that is the entire problem, also check how it is linking things, there you should be able to remove references to files.
The build should be under the build tab.
MSBuild and the Visual C++ compiler to an excellent job producing a correct binary when you make changes such as adding or removing a file. Chances are, even without a complete rebuild the compiled executable will be correct. If you are seeing unexpected behavior, it is most likely caused by one of the following things:
Check that Visual Studio is configured to build your project before running it. Check the following options under Tools → Options... → Projects and Solutions → Build and Run:
Before building: Save all changes
On run, when projects are out of date: "Prompt to build" or "Always build"
On run, when build or deployment errors occur: "Prompt to launch" or "Always launch"
If Visual Studio asks if you want to run an old version of your program, you may have introduced a compile error by removing the file, so the compiled binary will certainly be out-of-date until you correct it.
If your project contains a file that directly or indirectly #include "yourRemovedFile", then removing the file from the project may have no effect.
The Visual Studio Errors List reports issues independently from the compiler. You might be seeing old errors reported that are no longer relevant to your project but have not been cleared from the UI yet. In these cases, when you run your program you would still get the same results. You can also see if this is your problem by restarting Visual Studio and seeing if the error messages persist.
Is there any way to get Intellisense in Visual C++ for Visual Studio 2005?
I'm trying to get the Boost libraries to load up with intellisense and in the object browser/class view.
I installed the binary for Windows with the BoostPro installer (BoostPro 1.40.0 Installer).
I'm not certain that it comes with the source code however, which may be required to make Intellisense work in VS2005.
Boost is open source, and mostly header only. Just make sure IntelliSense knows the directory where boost resides so it can explore it.
As an un-answer, you might try out Visual Assist X, which works far better and has more features that Visual Studio's IS.
To make sure Intellisense can find boost, just make sure Boost is in the include directories (under Project Properties->C/C++->Additional Include Directories). Maybe move it to the top. After that, close your instance of Visual Studio, and search the a *.ncb file near your project, and delete it. This will cause IntelliSense to refresh. This should hopefully be enough for it to assist you. (You have to include boost headers into your source files with #include for IntelliSense to consider it)
Keep in mind boost has some very complex parts that IS will choke on, but should still provide the names.
Intellisense scans the headers #included in source files in Visual C++ projects.
So create a project with a single source file that includes the top level header of the boost library that you're interested in. Some of the boost code can't be parsed by intellisense though, and the boost code contains a lot of code to workaround language or compiler limitations that's just noise to someone wanting to see the user facing structure of the libraries.
I found a great C++/ODBC example here...
The project I downloaded builds great and everything works. However, when I copy the .cpp and .h files into another project, I seem to have a linking problem.
The SQLConnect function in sql.h is the one I want. When I right-click this function in the easyodbc.h file in the project I downloaded, it jumps to the declaration in sql.h. Life is good.
However, in the project I created, when I do this it jumps to a UNICODE definition in sqlucode.h. This seems to be causing problems and my test project crashes.
I don't have an #include for sqlucdode.h anywhere in my project, yet it still resolves the declaration to the one in sqlucode.h. How can I prevent this? Thanks.
Seems like you have a preprocessor problem rather than a linking problem.
You probably have a preprocessor definition for UNICODE (or _UNICODE) in your project file. In Visual C++ 2005 and 2008 you can fix this by going to your project properties and changing Character Set from Use Unicode Character Set to Use Multi-Byte Character Set. When you apply this setting, Visual Studio fixes up the right preprocessor and linker settings for you.
If you have an earlier version of Visual Studio you can still fix it by changing the preprocessor definitions for UNICODE and _UNICODE to _MBCS - it's just you'll have to find them yourself.
EDIT: I just downloaded that example code and tried it - good news, it's exactly as I guessed, change to a multibyte character set and you'll be fine.