http://asawicki.info/ Graphics programming, game programming, C++, games, Windows, Internet and more...
Entries for tag "visual studio", ordered from most recent. Entry count: 47.
Windows 8 Developer Preview
News about upcoming Windows 8 appear for some time. Information about the new Windows version directly from Microsoft, including technical details for developers, can be found in this PDF: Windows Developer Preview - Windows 8 guide. Recently Microsoft shared a full, development version of this system to download, install and test on your computer for free. It's a developer preview - it contains the new operating system along with new Visual Studio 11. You can download it as ISO image from Windows Developer Preview downloads. The system works in VirtualBox virtual machine. You can see my first gallery of screenshots here:
My first impressions after testing Windows 8 are... quite weird. Apparently they try to make desktop OS looking like a cellphone, with big fonts and all apps working in fullscreen. But that's only a half-truth. I feel that in Microsoft they always do it this way: a boss comes and tells that "we do it again from scratch only better, redefine everything, but we have to preserve backward compatibility", then a developer thinks how to implement it the simplest possible way and it ends in a new flashy UI containing several shortcuts to the most important commands with the old, good windows hiding somewhere under "Advanced" button. It was the same with Control Panel, with formatting functions in MS Office and now it's the same with the whole Desktop. You are presented a new screen full of colourful rectangles, but as soon as you move your cursor to the bottom-left corner of the screen and click "Start", you are teleported to the normal desktop with a wallpaper, taskbar and the Recycle Bin :)
Other things that attracted my attention: You now login to Windows using your Windows Live ID account. System is integrated with Facebook by providing some application to browse it. Explorer now uses the new Ribbon toolbar, just like new versions of MS Office, Paint or WordPad do for some time. There are lots of new games. New Task Manager is great because it now shows four columns with all most important statistics of every running program: the usage of CPU time, RAM memory, disk transfer and network transfer. Finally the new UI style: flat, colourful, minimalistic, full of solid filled rectangles.
Documentation in Visual CPP
Beginner programmers use only tutorials and are afraid of original documentation of any library. Most of programmers I know who use Visual C++ - even advanced ones - search for functions and classes documentation in Google, always being pointed to online version of MSDN Library. That's probably why noone told me about new Visual Studio documentation for such a long time.
But I can't imagine coding without having documentation for every library I use installed offline in my system and opened most of the time. For WinAPI, .NET, C and C++ standard libraries I used MSDN Library for Visual Studio 2008 SP1 - a free application that is available for download from Microsoft website in form of a DVD ISO image. But it's a 2008 version. I checked for some new version many times and couldn't find one.
Now I know that Microsoft changed this offline MSDN Library to a new help available in Visual Studio 2010, including Express edition. It can be installed by selecting Help / Manage Help Settings. A dialog box allows you to install, remove and update different parts of huge library (mine takes 3 GB of hard disk and it's located in C:\Users\All Users\Microsoft\HelpLibrary)
Files are downloaded, installed and after that, you can use Microsoft Help Viewer 1.1 to browse this documentation - hierarchical Contents, flat Index (I think it's the most useful), Favorites and full-text search. This help browser works faster than the old one (from MSDN Library). I recommend this method to anyone who code in Visual C++/C#/whatever.
Pointing to DLL Files in Visual CPP
When coding in Visual C++, we sometimes need to use some DLL libraries like FMOD, wxWidgets, Intel TBB etc. We download or build the library, setup directories to include and library files, finally #include <header.h>, #pragma comment(lib, "library.lib"), compile, run and...
Certainly our program also needs DLL file at runtime. Sure we have to attach it to the program when we distribute it, but do we really need to copy all these libraries to the Debug and Release subdirectories in our project? For a project run from Visual C++ to find required DLL files, they must be placed either in:
or in the PATH environmental variable. That's an option I've discovered yesterday. To use it in Visual C++, navigate to project properties / Configuration Properties / Debugging / Environment and set it to something like: PATH=$(PATH)$;C:\my_libraries\library_1\DLL_dir
If you do it correctly, your program launched from Visual C++ (with or without debugger - F5 or Ctrl+F5) will now be able to find required DLL libraries without need to copy them to your project directory.
Static C++ Code Analysis with PVS-Studio
By the courtesy of its authors, I have a chance to evaluate PVS-Studio - a static code analyzer for C, C++ and C++0x. This commercial application is installed as a plugin in Visual Studio 2005/2008/2010. Fortunately I have Visual Studio 2008 Professional at home so I could try it with the code of my personal projects. PVS-Studio differs from other tools of this kind, like free Cppcheck, by finding three types of errors or warnings: general, related to OpenMP and 64-bit portability issues.
After opening my solution in Visual Studio, I choose a command from the special menu to analyze all the code.
A progressbar appears while PVS-Studio does the computations, utilizing almost 100% of all 4 CPU cores. Finally, a dockable panel appears with a list of found issues.
The general category warns about exact float comparison with == and stuff like that. It managed to find few places where I forgot the "&" character while passing a vector as const refefence parameter, rightly telling that it will cause "decreased performance". But its greatest find in my CommonLib library code was this unbelievable bug:
Some messages look funny. Should I code some general, abstract, portable, object-oriented, Alexandrescu-style template-based solution here just to avoid copying some code into several similar instructions? :)
I didn't check how the OpenMP validation works because I don't currently use this extension. As for 64-bit compatibility issues, I have lots of them - just because my code is not prepared to be compiled as 64-bit. PVS-Studio seem to do a good job pointing to places where fixed-length 32-bit integers are mixed with pointers, array indexing etc.
Overall, PVS-Studio looks like a good tool for C++ programmers who care about the quality of their code. Finding issues related to OpenMP and 64-bit compatibility can be something of a great value, if only you need such features.
Too bad that PVS-Studio, opposite to Cppcheck, is a Visual Studio plugin, not a standalone application, so it obviously requires you to have a commercial MSVS version and do not work with Express edition. But this is understandable - if you need OpenMP or 64-bit, you probably already use Visual Studio Professional or higher.
PVS-Studio analyzes C, C++ and C++0x. It doesn't work with C++/CLI language, but that's not a big flaw too. I use C++/CLI at work, but I can see it's quite unpopular, niche language. Its compilation or analysis would also be very difficult because it mixes all features from both native C++ and .NET. Even Microsoft didn't find resources to implement IntelliSense for C++/CLI in Visual Studio 2010.
Visual Studio 2010 Service Pack 1 Released Yesterday
Yesterday Microsoft publicly released Visual Studio 2010 Service Pack 1. It is big (1.48 GB) and the installation takes quite long. It applies to all Visual Studio 2010 versions and components, including C++ Express, C# Express etc. Here is the list of changes and here is download link (you can find link to ISO file with offline installer at the bottom of that page). There are lots of fixes and improvements, but most of them apply to managed or web technologies like Silverlight. What's interesting for a C++ programmer is the addition of intrinsics to enable the extensions on the AMD and Intel new microprocessors that will be released next year - Intel AVX and AMD Bulldozer. Microsoft also claims to optimize and fix C++ compiler. Changelist mentions fixing lots of IDE crashes, including incompatibility with AMD CodeAnalyst.
Overall I think the new SP1 for VS2010 is worth installing, unless you have "Windows SDK for Windows 7 and .NET Framework 4" installed in your system. In that case an unsolved issue would happen so you should NOT install the Service Pack.
By the way: MSDN Library - the extensive documentation of C, C++, WinAPI, OpenGL, .NET and lots of other technologies - is available for free in form of an offline application for some time, but the latest version is MSDN Library for Visual Studio 2008 SP1. Do you know how to download some newer release? Or maybe that "Windows SDK" ships with it?
Generating LIB File for DLL Library
I've been recently trying to use libVLC - functionality of great, codec-less VLC media player enclosed in form of DLL library. By the way I've came across a great article: GenerateLibFromDll and now I know how to generate LIB file for any DLL library! Here is detailed description of the problem:
When you have a DLL library you want to use in your C++ code, you may do it dynamically by using LoadLibrary and GetProcAddress functions from WinAPI, but it's more convenient to do it statically. But it's not enough to just #include signatures of library functions and use them in your project. You also need to link with some LIB file, even if the file is not a real static library with compiled code, but only a few-kilobyte-long list of imported functions. I believe that's just another flaw of C++ language, because other languages like for example C# don't need this even when importing functions from native DLL libraries.
If you have some SDK prepared for Visual C++ or compile the library by yourself, you also get the LIB file next to DLL. But if you have only the library, that article shows following steps to generate matching LIB:
1. From Start menu run "Visual Studio Command Prompt".
2. Execute command:
dumpbin /exports DLL_FILE.dll > DEF_FILE.def
This command prints some information about given DLL library in textual form to its standard output. We redirect it to a text file with DEF extension. But to make it real DEF file, we need to edit it.
3. Open DEF_FILE.def in some text editor and edit it to contain only the names of exported functions in form of:
4. From the Visual Studio Command Prompt, execute another command:
lib /def:DEF_FILE.def /out:LIB_FILE.lib /machine:x86
And there you have it! The so much required LIB file generated from DLL library. You only need signatures of these functions with proper parameters and return values declared in some H header file and you can successfully use your DLL by linking with LIB file created by yourself :)
Compiling wxWidgets 2.9.0 in Visual C++ 2010 Express
NEW! (2011-02-18) I posted this entry months ago, wxWidgets keeps evolving and so it may no longer work. For building wxWidgets 2.9.1 in Visual C++ 2010, I now recommend you follow steps described here: Visual Studio C++ 2010 - Microsoft Visual C++ Guide - wiki.wxwidgets.org and here: Fixed wxWidgets 2.9.1 project files Visual Studio 2010 - forums.wxwidgets.org.
My old blog entry:
Today I wanted to compile wxWidgets library (version 2.9.0, which contains lots of interesting new features, including wxPropertyGrid control) under Visual C++ 2010 Express. A strange error appeared that stopped the build and explained nothing specific about the cause:
Microsoft.CppCommon.targets(151,5): error MSB6001: Invalid command line switch for "cmd.exe". The path is not of a legal form.
It took me some time to find a correct solution on Google, as many of them didn't work. (Copy setup.h file to some another directory? Made no difference in my case. Use the wx.dsw - project file for oldest IDE version? Didn't work either, my Visual says it cannot import such projects.)
Finally I've found this forum topic: http://forums.wxwidgets.org/viewtopic.php?t=27630. Sami Hamlaoui on 25th April 2010 posted a ZIP archive there containing converted and fixed project for Visual C++ 2010 that you can download and use to successfully build wxWidgets 2.9.0. Thanks for that!
After you build all projects in Debug and Release configuration, you just need to setup include and library paths in the IDE:
And finally you can use wxWidgets in your projects.
To do that, you need to #include files such as comctl32.lib, rpcrt4.lib, winmm.lib, advapi32.lib, wsock32.lib and desired wx libraries like wxbase29ud.lib and wxmsw29ud_core.lib ("d" is for debug,
use versions without "d" in Release configuration).
Also remember that the new wxWidgets has no ASCII support, so you have to use Unicode character set.
DXGI Format Cheatsheet Today I've prepared another small, single page cheat sheet related to DirectX 11: I've also solved my problem with Visual C++ 2010 Express that crashed every compilation on my computer. I've submitted this bug to Microsoft Connect, expecting that it may be because I have a 64-bit Windows 7 or because I also have Visual Studio 2008 Professional installed. But with the help from Microsoft I've figured out that it was just because of the AMD CodeAnalyst profiler. Uninstalling this program helped me so my VC2010 doesn't crash any more :D
comctl32.lib, rpcrt4.lib, winmm.lib, advapi32.lib, wsock32.lib
and desired wx libraries like wxbase29ud.lib and wxmsw29ud_core.lib ("d" is for debug, use versions without "d" in Release configuration). Also remember that the new wxWidgets has no ASCII support, so you have to use Unicode character set.
DXGI Format Cheatsheet
Today I've prepared another small, single page cheat sheet related to DirectX 11:
I've also solved my problem with Visual C++ 2010 Express that crashed every compilation on my computer. I've submitted this bug to Microsoft Connect, expecting that it may be because I have a 64-bit Windows 7 or because I also have Visual Studio 2008 Professional installed. But with the help from Microsoft I've figured out that it was just because of the AMD CodeAnalyst profiler. Uninstalling this program helped me so my VC2010 doesn't crash any more :D