Run C++ analysis with VS solution file - c++

I want to analyse a more complex C++-Project with SonarQube (v4.4) and the Cxx-Plugin v0.9.1 (Community C++).
It includes many sub-projects in different directories.
I got a VS2005 solution file (*.sln) which referes to the relevent *.vcproj files or alternativ mwc + mpc files.
I was now wondering, what the best way to do this analysis is.
Sure, I could write a sonar-project.properties file manually with all directories.
But isn't there a possibilty to run the analysis using the given workspace / project files I got? I could think of e.g. Sonar-Runner readout information from that files to create modules with given direcotry (and maybe automatically includes the defined addionaly includes).
I found Plug-Ins like "Analysis Bootstrapper for Visual Studio Projects Plugin" or the .Net-Plug-In, but obviously they don't support vcproj files.
Thanks for any help and best regards

Visual Studio comes with C++ static code analysis, but for 2005/2008 you need the team edition. 2010/2012 it is available in the premium edition. It is now available in the 2013 professional edition.
Otherwise I would look here

Related

External C++ source files in android studio?

Here is the drill. I have a cross-platform project written mostly in C++ (more on this later) that runs on windows, android and ios.
Is there any way in which android studio can be configured to have a custom directory that contains all the native C++ code ? By custom, I mean external to the main folder in which the android studio project resides in.
I'm guessing you can see where I'm getting at... I have a cross-platform project that can be opened from 3 different IDE's... visual studio, android studio and xcode and I want to be able to write / edit / compile the code from all of them.
Let's say I have the following main hierarchy:
projectDir
src (C++ source files .cpp)
include (C++ headers .h)
_visualStudio (visual studio project)
_xcode (xcode project)
_androidStudio (android studio project)
assets (resources .png etc)
others...
This is what I want to achieve, but I am unable to figure out how can I configure an android studio project to be able to accept external source files, but most importantly to be able to see and edit them from the android studio IDE. Basically I want to tell android studio... "Look, this is the path for the native files, treat them as if they belong to the project".
I know this is possible from visual studio and from xcode because I already did that, but up until now I used my own build system for android and I had no need for android studio. Is there any way to achieve this ? Perhaps some kind of symbolic folder links ?
The thing is I want to keep only a single copy of my shared resources (src, include and assets should only be in one place, but should be available for android studio as well).
So far the only solution is to keep them inside android studio project directory, and change visual studio paths to look for them there, but I find this very nonprofessional.
EDIT:
Is there any addFileToProject (as in visual studio) in android studio in which the file can be outside the project ?
After a bit of more digging I found that it is actually possible.
You just have to create a directory junction like this (inside app/src/main/cpp where the files would normally be).
mklink \J linkName linkDestination(can be outside the project)
Android studio will be able to see the containing folder as it's own (it sees it as a link, but you can double click it to expand the contents). You can also edit source files inside it with the only mention that you have to add these files within CMakeLists.txt or whatever build file you are using in order to have intellisense (you get a sync warning from android studio if the files aren't referenced anywhere in the build files).
Later edit... if you are using junctions for Java / Kotlin files in an android studio project, make sure to set the source sets through the junctions as well... in order to avoid visual errors like 'duplicated class'.

how to set configuration of log4cpp for visual studio 2008

i want to use log4cpp library in my code for logging. But,for windows platform i dont know how to configure the library. I am using Visual Studio 2008.
Any help will be appreciated.
Use the workspace and project files in subdirectory msvc8. (You may need to adjust include/log4cpp/config-win32.h and the project files to your particular needs).
You may also opt for compilation of source using cygwin and call exported functions from library.

Can I compile a Visual C++ project on Linux using xbuild?

I have an existing project that I compile on both Windows using Visual C++ 2008, and Debian Linux. This project uses a standard Visual C++ .vcproj file, and some .cpp and .h files. It does not rely on any Windows specific stuff. Just plain C++.
It compiles and run well on Linux, using a home made tool that reads the .vcproj file to generate a Makefile which is used with make to compile and link all files using g++.
The trouble is that with Visual C++ 2010 (and 2012), the format of the project files have changed. Even the name has been changed from .vcproj to .vcxproj. My home made tool cannot read this new project file to generate the Makefile.
Instead of upgrading the home made tool to support new project files, I was wondering if xbuild would be able to compile my Linux executable?
I tried first to compile my own (VC++2008) project, but xbuild complains that my project is a VS2003 project, which is not supported by xbuild. However when googling on this matter, I find that xbuild is supposed to support VS2005 project files. There are also some references to mdtool to support these old project files, but I seems to be integrated into xbuild now.
Furthermore, I tried to compile a Visual C++ 2010 example (HuoChess) got from the MSDN site. The result is
/Microsoft.Cpp.Default.props: Project file could not be imported, it was being
imported by [...] /HuoChessConsole/HuoChessConsole.vcxproj: Imported project:
"//Microsoft.Cpp.Default.props" does not exist.`
Now, this looks like the project file wants some Microsoft definitions of rules for the Cpp compiler. Should I fake these definitions to use gcc instead? How can I do this?
Is what I want to do ever possible with xbuild?
There is a project GCCBuild which you can use to build vcxproj projects in Linux. It simply uses same vcxproj but uses GCC to compile and build. There are multiple examples there too.
PS. I am the author of that project.

Using a DLL with unmanaged code in Visual Studio 2010?

I'm fairly new to C++ and an trying to figure out to use the TagLib library for a project I am working on. I'm working with unmanaged C++ in Visual Studio 2010 on Windows 7 64bit. I've never used an external library before so I'm very confused on how to go about this.
From this blog entry I got the libtaglib.a and taglib.dll files. I ran across this SO question on how to use TagLib, but it deals with QT Creator, not Visual Studio and I'm not knowledgeable enough about the subject to understand what is being said to translate it into what needs done for Visual Studio.
So, some questions:
Is it even possible to do this with unmanaged code?
What exactly is the function of a .a file?
Most importantly, how do I go about using the taglib.dll in my program??
I've been all over Google looking for a way to do this, but my major problem is that everything I run across is over my head. Please let me know if more info is required. Any help is very much appreciated! Thanks!
I seem to have gotten it working successfully. Here's a rough outline of what I did:
1.) I used CMake to generate the Visual Studio solution.
2.) I attempted to build the tag project in the VS solution, but it failed.
3.) I made the corrections to a few source files as outlined here: http://old.nabble.com/taglib-fails-to-compile-with-MS-VC%2B%2B-2010-td29185593.html
4.) I built the tag project again in release mode. This time it was successful.
5.) I copied the resulting dll, def, and lib files to the same directory as the source files for my project.
6.) I copied the header files from the taglib source to a subdirectory in my project (not sure if this entirely good practice)
7.) In my project settings, I set the subdirectory with the header files as an additional include directory.
8.) I added the dll, exp, and lib files to my project by just going to Add>Existing Item.
9.) I added some code from the taglib examples and built it. Everything worked so I think I got it.
One caveat I ran into, since the DLL was built in release mode, my project had to be run in release mode or it would crash. I'm guessing that if I replaced the DLL with one built in debug mode I could run my program in debug mode, but I have not tried this.
You cannot use libraries specific to GCC (you can tell because they have .a extensions) with Visual Studio. You will have to build the library from source in order to use it with MSVC. Once you have done that it's a simple matter of adding the .lib generated from the build process to your project and things should work out of the box. (Note that it's a .lib you need whether you're compiling for dynamic linking or not -- doesn't matter in msvc land)
EDIT -- after looking at TagLib itself --
In order to compile TagLib you'll need to get the CMake build system, and TagLib itself, and have CMake build you a visual studio solution. Using that solution you'll be able to build the .libs and .dlls you need. Note that because TagLib is a KDE library, you'll probably need to also build some QT bits in order for everything work work successfully. However, I don't have specific experience with the library so I'm not going to be all that helpful here.
Yo do not have to recompile the source (to create the .lib file) if you have the .dll file. With dumpbin /exports and lib (both came with Visual Studio) yo can create a lib that you can link with your application. In this link you can see a nice explanation: http://www.coderetard.com/2009/01/21/generate-a-lib-from-a-dll-with-visual-studio/
But as Billy Said, probably you would need other parts of QT to use this library.

Cross-platform svn management (Makefiles & Visual Studio)

I'm working on a little game called freegemas, it's an open source version of the classic Bejeweled written in C++ and using gosu as the graphic API. I've been developing it under Ubuntu Linux as usual, but the other day I wanted to give it a try and I compiled it on Windows using Visual Studio 2005 (which I had never used before). The program worked flawlessly.
To compile it on Windows I manually copied all the source and header files to a new project on MSVC, but I would like to adapt the SVN so I don't have to recreate the project every time I want to compile it.
Therefore, the question would be: What's the best way of organizing the svn so I can have, on the one hand, a Makefile to compile the project in Linux, and, on the other side, the MSVC project's files? Right now I've got a simple folder called trunk with all header, source and resource files on it.
I've never used Visual Studio before, so I don't know which files are the most important either. Maybe some of those files are auto-generated and do not need to be svn-versioned.
Thanks in advance.
You could just keep the project files in a seperate directory "winbuild" or similar. Still, to maintain them would require manual interaction (ie adding every new file manually). The only files you would need to upload to svn are the *.vcproj (for MSVC 2005/2008) and *.vcxproj (MSVC 2010).
Alternatively, you could opt for a cross-platform solution like CMake, which could generate makefiles and Visual Studio project files from a common CMakeLists.txt, which is the only "project file" that would have to be maintained (instead of your makefile). Especially for a simple (?) project like yours (some headers+sources). There would be no need to include any makefiles or vcproj files at all, just the CMakelists.txt file would suffice.
There are others like CMake (SCons, boost.jam, jam, premake, etc.)
It should be feasable, but requires some testing and trial-and-error.