Tuesday, March 15, 2016

When startx from terminal does not work...

If startx from your terminal does not work, try  
 
sudo start lightdm
 
OR  
 
sudo service lightdm start 


Source
http://askubuntu.com

Sunday, March 6, 2016

Google Test in Visual Studio

This post is for those who just need "a refresh" of the steps required to set google test with Visual Studio. If you are a newbie, please refer the excellent references at the bottom of this post.

Some simple actions will allow you to use the popular Google Test Framework in Visual Studio.
In a summary you will need to perform these steps:

1) Download the latest version of google test
2) Open and Compile in Visual Studio the TWO Visual Studio solutions you'll find in googletest/msvc: gtest.sln (static libraries) and gtest-md.sln (dynamic libraries)
NOTE: Before open gtest.sln and gtest-md.sln remember to unlock these files (right click and unblock).
3) Neglect the warnings in Visual Studio and
With the DEBUG  configuration  Build -> Build Solution
With the Release configuration : Build -> Build Solution

These steps will create the gtest libraries in msvc/gtest/Debug  msvc/gtest/Release.
Debug:
gtest_maind.lib
gtestd.lib

Release:
gtest_main.lib
gtest.lib

NOTE the extra "d" in the Debug libraries (e.g. gtestd.lib vs gtest.lib)

4) To create a test project to support an existing project of yours you'll need to make the following changes in your test project:
  • Be sure your Runtime Library is the same in BOTH project AND it is consistent with the google test libraries you are using: e.g. if you compiled gtest.sln YOU need to set a multi-thread runtime environment : /MT and /MTd , for release and debug solution, respectively.  This is set in General Properties -> C/C++ -> Code Generation. Distinguish between Release and Debug
  • In  General Properties set correctly Include Directories and Libraries Directories
  • In  General Properties -> Linker -> Input-> Additional Dependencies  add the previously generated google test libraries at point 3. Distinguish between Release and Debug.
  •  Make your test project dependent on your NON-test project. Select your test project from the solution explorer. Right Click -> Build Dependencies -> Project Dependencies : Your NON-Test project should be listed among the available projects.

That's it.

NOTE:
You have some linker errors like "Linker error LNK2038: mismatch detected for 'RuntimeLibrary'..."
Be sure that:
  • Runtime Libraries match between your TEST and NON-Test projects
  • The gtest library you are linking is consistent with the runtime Library you chose:  /MT  and /MTd require gtest_main.lib/gtest_maind.lib (static libraries) and  gtest.lib/gtestd.lib (static libraries) while /MD and /MDd require gtest.lib /gtestd.lib (dynamic versions) and gtest_main-md.lib / gtest_main-mdd.lib (dynamic versions).



References:

Saturday, March 5, 2016

How to compile C/C++ programs from command line with Visual Studio

On the subject "compiling from command line with Visual Studio" the Microsoft's page is pretty well done, with some hello world examples for the typical cases (C, C++, .NET etc): https://msdn.microsoft.com/en-us/library/f35ctcxw.aspx

Short version:

Run the command (this will basically open the cmd.exe and the correct environment variables):

Start -> Visual Studio 2015 ->  Visual Studio Tools -> Developer Command Prompt for VS2015

Move to the directory where your C file is located and run the command:


cl <your_C_file>

if you want to compile a C++ program instead:


cl /EHsc <your_C++_file>


That's it.

On the Microsoft's page, you can find many more options.