Can I compile .c files as C++ files without renaming them? - visual-studio-2005

SVN is giving me some trouble with a few .c files that I had to rename in my branch because they received some C++ extensions. I could get around this trouble by somehow telling Visual Studio to treat all those files as C++ code, even if they have a .c extension.
Is there a way to do this?

You have to set to "compile as C++" when right-clicking a file -> properties->c++->advanced. The trick is to not do it on the project, but for each individual file instead.
Ofc you can select multiple files when doing it, so it doesn't take you ages.

Related

Borland C++ 5.0 Makefile generation

I am using Borland C++ 3.1 and Borland C++ 5.0a to compile my projects. To speed up the process I decided to use a batch file to make all the projects with make utilities. There is a way to convert BC3 .prj files to .mak file with PRJ2MAK.exe, but, as far as I know, in BC5 projects it should be done through manual pressing of "Project -> Generate makefile" buttons in IDE. Is there any way to convert .ide files to .mak files in CMD?
In BC5 bin folder there should be an "idetomak" utility. At least BC5.02 has it.
Note that for some complex projects the generated .mak file may not be fully compatible. In that case you may instead run BC5 ide from the command line, telling it to build the .ide project

How to follow symlinks in visual studio and cmake in windows?

When building a c++ project in Visual Studio (2008 in this case), the compiler checks for each source file if there is already an .obj file and only rebuilds the .obj file if any of the input files, which are headers and a source file, are newer than the .obj.
This fails if any of the input files are symlinks because Visual Studio doesnt follow symlinks and only looks at the change date of the symlink itself.
E.g. Test.cpp (symlink 15:30) points to ../Common/Source/Test.cpp (changed 16:38) should produce
Test.obj (changed 15:31). Unfortunately VS wont follow symlinks and doesnt see that the original file was updated.
GNU make and gcc can follow symlinks, is there an equivalent in Visual Studio or is there another option for Windows? The change date of a symlink should also reflect the change date of the original file, IMHO, since a symlink cant be changed in Windows anyway.

How to add header file of MITK in my CPP program of VS 2010?

I have compiled and build using CMAke and VS 2010. But now I want to try some basic program using MITk library, but I can't find where is the header file, DLL, Lib file? Same as like in OpenCv when we compile and build it, then in install folder we have bin folder that contain DLL file, Lib folder contain lib file and include folder contain header file of CPP program.
So, where is the header file of MITK build library ?
If anybody have idea then suggest to me.
It seems you want to use MITK as a toolkit. As the documentation suggests, you can (must?) use cmake. The generated VS2010 .sln file will handle all the include and library files for you. Use the .bat file if there's one.
There's probably a way to use it without cmake, but I'm pretty sure it's a bad idea.

How to get absolute paths in cmake generated project files

I am using cmake to generate project files for a C++ project that needs to be compiled under Visual Studio 6 and 2010. The files are generated OK for both projects and I can build the projects without a problems.
However, the 2010 vxproj files contain relative paths to the cpp files and when I use Jenkins to build the files the log contains relative paths that Jenkins can not use to find the source files.
I see this:
..\..\source\moduleA\file1.cpp(74): warning C4800: 'BOOL' : forcing value to bool 'true' or 'false' (performance warning)
While it should have been either source/moduleA/file.cpp or D:\jenkins\jobs\workspace\source\moduleA\file.cpp for Jenkins to be able to find the file.
Of course, I can make a parser to parse the log file and remove the ..\...\ but I am hoping to find a more elegant solution.
In the end I found a compiler option that can fix this. You can add the /FC flag for Visual Studio 2010. Not sure if it works for VC6. To add it use this:
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /FC")

Compiling OpenCV

I opened up the solution file in the [InstallDir]\_make\opencv.vs2005 and modified one of the .cpp files in the highgui library.
While compiling, Visual Studio throws the error -
Unable to start progam
C:/Users/../AppData/Local/Temp/opencv.build/cv_Debug.Win32/cv.dll
The system cannot find the file specified.
I think I am missing something in it. What is the stepped procedure to change and recompile OpenCV library using Visual Studio.
I would appreciate any help!
Thank You..
Unless you downloaded the visual-studio specific version of the open cv distribution files, you need to follow the instructions on the OpenCV wiki, that is
download cmake
have cmake generate makefiles/solutions
build using the generated files
I guess you want to customize a function. You can do this, without recompiling OpenCV from scratch. You can simply copy the .cpp source file locally in your current working directory, and add it(click n drag or add existing file) in the "Source Files" in your project. You might need to copy some other headers as well. You will find everything in the opencv archive. (opencv/modules/highgui/src)

Resources