28. May 2014

Book review: Visual Studio 2013 Cookbook

Visual Studio 2013 is a huge technological leap forward. The book Visual Studio 2013 Cookbook helps to get on track with latest features including enhanced support for JavaScript and C++.visual-studio-2013-cookbook

Software projects often combine many different technologies like C++, .NET or JavaScript. Professional developer must be aware of all these technologies. The book is a great source of essential information which helps developer to grasp important concepts implemented in Visual Studio.

Cookbook provides short and easy to understand chapters about wide range of features. Each chapter contains some links to web sites or related technologies.

I recommend to read the book one chapter a day. Learn new stuff, experiment with it and next day continue with next chapter.

What you can find inside the book? Here is selection of some interesting topics

Chapter 1: Discovering Visual Studio 2013

  • contains productive tips how to use Visual Studio in effective way (keyboard shortcuts, navigation in project)

Chapter 2: Getting Started with Windows Store Application

  • good starting point for building own application for Windows Store
  • introduction to analysiss of application performance

Chapter 3: Web development

  • learn how to work with Bootstrap
  • minification of JavaScript and CSS

Chapter 4: .NET 4.5.1 Development

  • unit testing of .Net apps
  • managing packages with NuGet

Chapter 5: Debugging .NET Application

  • debugging with IntelliTrace
  • debugging parallel code

Chapter 6: Asynchrony in .NET

  • introduction to popular way of programming applications
  • integration of async concepts with web applications

Chapter 7: Unwrapping C++ Development

  • C++ is still very popular and Visual Studio 2013 introduces several concepts known in .NET or JavaScript
  • Native Unit Test Project for C++
  • graphics programming – 3D, DGSL and diagnostics

Chapter 8: Working with Team Foundation Server

  • getting feedback from users
  • git integration

Chapter 9: Languages

  • highly improved integration with further languages like TypeScript or Python
  • Python support is simply awesome

Visual Studio 2013 Cookbook is available at Packt Publishing store.

28. April 2014

Gradle and build systems for C language – slides


Slides available in formats: PDFSlideShare

Source code: GitHub/georgik

26. November 2013

There is more to C 2013 – slides


Slides available in formats: PDFSlideShare

17. November 2013

How to build sample applications from Adobe Illustrator SDK CC by Microsoft Visual Studio 2013 Express

Let’s try to build sample applications from Adobe Illustrator SDK CC with Express version of Visual Studio.

Adobe Illustrator SDK is available at: http://www.adobe.com/devnet/illustrator/sdk.html

In readme file Adobe explicitly states requirement that you should use Microsoft Visual C++ 10 (Visual Studio 2010 SP1). Hm.

Unzip directory with SDK and go to samples directory. Let’s start with LiveDropShadow sample.

Double click LiveDropShadow.vcxproj to open project in Visual Studio 2013. Hit F7 to build the project.

You’ll get error message:

Error 1 error MSB8020: The build tools for Visual Studio 2010 (Platform Toolset = ‘v100’) cannot be found. To build using the v100 build tools, please install Visual Studio 2010 build tools.  Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting “Upgrade Solution…”. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.Cpp.Platform.targets

illustrator-wrong-target

Go to menu Project and select Retarget solution:

illustrator-retarget-project

This action converts project into project for VS 2013. Hit F7 for build.

After several seconds compilation fails and you’ll get another error message:

Error 20 error RC1015: cannot open include file ‘afxres.h’. C:\idea\Adobe Illustrator CC SDK\samplecode\LiveDropShadow\Resources\LiveDropShadow.rc 26 1 LiveDropShadow

illustrator-visualstudio

Double click error message and you’ll see problematic code.

illustrator-problematic-code-01

Problematic is include of afxres.h. It is reference to MFC library which is not part of Visual Studio Express 2013 edition. MFC is available only in Professional version. Do not worry. For many plugins you do not need MFC.

You can disable this include. There is also another problem few lines below with language code. We can disable this line of code for time being.

illustrator-problematic-code-02Hit F7. You’ll get error message that points into VersionInfo.rc file. There are several defines referencing MFC. You can disable those line for time being. (FILEFLAGMASK, FILEOS, FILETYPE, FILESUBTYPE)

illustrator-problematic-code-03

Hit F7 and now you’ll get AIP package 🙂

illustrator-visualstudio-success-build

Open Illustrator and configure path to Additional Plug-ins folder. Click Edit – Preferences – Plug-ins & Scratch Disks and set path to the folder where Visual Studio produced that aip file. It will be in directory Adobe Illustrator CC SDK\samplecode\output\win….

illustrator-preferences

Click OK, restart Illustrator.

Tadaaa, plug-in is working:

illustrator-working-01

Result:

illustrator-working-02

For more information about plug-ins read getting-started-guide.pdf document in SDK directory docs\guides. 🙂

 

18. November 2012

Allegro5.1 and Visual Studio 2012 – Unable to start examples – missing dll files

It’s easy to work with Allegro 5.1 project in Visual Studio 2012. Just clone the project from git repo. Invoke cmake-gui.

Note: Make sure that you have installed Windows SDK for Windows 8.

You can do it using following commands (use Developer Command Prompt for VS2012 or set proper variables):

git clone git://git.code.sf.net/p/alleg/allegro
cd allegro
mkdir Build
cd Build
cmake-gui ..

Click Configure and Generate. Then open solution in Visual Studio.

You can build whole solution. The only problem is that when you want to invoke any example then you’ll see something like this:

Those DLL files are located in Build\lib\RelWithDebInfo (or something like that). It is sufficient to update PATH environment variable. You can do it on per-project basis.

Press Alt+F7 (Right click – Properties) – Debugging – Environment – Set/Add:

PATH=$(ProjectDir)..\lib\RelWithDebInfo

Run the example again (F5):

15. December 2011

How to define C++ macro with string content and pass it to MSbuild

Imagine that we have C++ project e.g. for Visual Studio 2008. It is possible to build this project just by msbuild command:

msbuild MyProject.vcproj /p:Configuration="Release"

Let say that we want to use #define in the source code. It is necessary to define it in Configuration Properties > C++ > Command Line:

/DSIMPLE_DEFINE

This just pass SIMPLE_DEFINE as flag.

How to deal with string define which should behave like string? E.g.:

#define URL "http://georgik.sinusgear.com"

The trick is in escaping quotes. We can add following define to Command Line:

/DURL=\"http://georgik.sinusgear.com\"

It will transform into .vcproj file:

AdditionalOptions="/DURL=\"http://georgik.sinusgear.com\""

Let’s make one more step.

How to acquire such a define from environment variable? E.g. with following build.bat file:

set URL="http://georgik.sinusgear.com"
msbuild MyProject.vcproj /p:Configuration="Release"

It requires only small modification of .vcproj file:

AdditionalOptions="/DURL=\"$(URL)\""

😉

Small recap of flow: set env variable – pass it to XML – pass it compiler – pass it to code

14. October 2011

_ITERATOR_DEBUG_LEVEL’: value ‘0’ doesn’t match value ‘2’

Update 16.10. 2011: new information added to article.

I was trying to compile an application with Visual Studio 2010 which has some dependency on GDAL open source library.

Everything went ok. GDAL compiled without problem from VS and also from command line:

nmake -f makefile.vc MSVC_VER=1600 DEBUG=1

Compilation of application based on GDAL was also ok. The only problem was when I switched project from Release mode to Debug mode. Linker was throwing a lot of messages like this:

'error LNK2038: mismatch detected for _ITERATOR_DEBUG_LEVEL': 
value '0' doesn't match value '2' in vrtizer.obj

I found some explanation that new version of VS has _ITERATOR_DEBUG_LEVEL set to 2 in Debug mode. It means that there are some extra security controls over iterators to detect memory leaks and other problematic stuff with iterators.

After longer research I came to realization that GDAL is compiled with /MD switch and my application wasn’t. The solution was easy. I just added /MD and Debug mode of app start working like a charm.

Quote from MSDN about /MD compiler switch:

Defines _MT and _DLL so that both multithread- and DLL-specific versions of the run-time routines are selected from the standard .h files. This option also causes the compiler to place the library name MSVCRT.lib into the .obj file.
Applications compiled with this option are statically linked to MSVCRT.lib. This library provides a layer of code that allows the linker to resolve external references. The actual working code is contained in MSVCR71.DLL, which must be available at run time to applications linked with MSVCRT.lib.

Update 16.10. 2011

/MD solved problem, but there was another warning: Command line warning D9025: overriding ‘/MDd’ with ‘/MD’.

To solve Iterator issue for GDAL you need to compile DEBUG version of gdal.lib with switch /MDd instead of default /MD.

Just open nmake.opt file and replace /MD in lines with DEBUG definition by /MDd.

There are two lines with MD:

OPTFLAGS= $(CXX_ANALYZE_FLAGS) /nologo /MDd /EHsc /Zi /W4 /D_CRT_SECURE_NO_DEPRECATE 
/D_CRT_NONSTDC_NO_DEPRECATE /Fd$(GDAL_ROOT)\gdal$(VERSION).pdb /DDEBUG
OPTFLAGS=   /nologo /MDd /EHsc /GR /Zi /W4 /Fd$(GDAL_ROOT)\gdal$(VERSION).pdb  /DDEBUG

Then rebuild GDAL:

nmake -f makefile.vc clean
nmake -f makefile.vc MSVC_VER=1600 DEBUG=1

6. December 2009

Allegro5 a MSVC – knižnica pre vývoj hier

Allegro je jedna z mojich veľmi obľúbených knižníc. V Allegre som kedysi začínal písať prvé hry. Bežali ešte na starom DOSe a dávnych Linuxoch. Allegro bola jedna prvých z grafických knižníc, ktorá bežala pod DOSom, Windowsom aj Linuxom. Vďaka nej som vytvoril aj portál Games For Linux, aby sa hry pre Linux nestratili. 😉

Dnes už je knižnica Allegro súčasťou bežných linuxových distribúcii a používa ju napríklad hra Atomic Tanks.

Allegro je už na scéne dlhú dobu. Úplne prvotné implementácie vznikli pre Atari a následne boli prenesené na DOS. Nie všetky koncepty z tej doby boli dostatočne životaschopné. Allegro5 je výrazný krok dopredu. Redizajnovalo sa celé jadro. Výsledkom je málá, rýchla knižnica, ktorá je nezávislá na platforme. Ak by dnes niekto začínal s Allegrom, jednoznačne odporúčam verziu Allegro5 (4.9.x).

alex

Prečo použiť Allegro a nie napríklad DirectX? To je jednoduché. Allegro abstrahuje od API DirectX, takže svoju aplikáciu dokážete potom jednoducho preniesť na iný OS, či nebodaj iPhone.

Chvíľu som sa hral s poslednou verziou Allegra a MSVC pre Windows. Na rozbehnutie potrebujete niekoľko krokov.

  • nainštalované Visual Studio, stačí Express Edition, ktorá je zdarma k dispozícii
  • nainštalované DirectX SDK, pozor má 500 MB
  • nainštalovať program CMake, ktorý poslúži na vygenerovanie projektových súborov pre MSVC
  • stiahnuť a rozbaliť Allegro, najlepšie pomocou 7-zip
  • v adresári s Allegrom vytvorte si malý baťák a spustite ho
set INCLUDE=e:\software\Microsoft DirectX SDK (November 2008)\include;%INCLUDE%
set LIB=e:\software\Microsoft DirectX SDK (November 2008)\lib\x86;%LIB%
cmake  -G "Visual Studio 9 2008"
  • následne spustite Visual Studio a otvorte projekt
  • môžete spustiť build 🙂

Pekná Wiki sa nachádza na stránkach portálu Allegro.cc. Ďalšie informácie o Allegre nájdete v materiáloch z mojich prednášok.

  • Where’s the fish?

  • Translations

  • Further info

  • Twitter

    Follow @jurajmichalek on twitter.

  • Comments

  • Tags

  • Topics