I am currently working on a platform indepedent project and we have frenquently come across the following problem:
When the Windows guys work on code that is not called by any other part of the code base it will not be compiled and will therefore not trigger compile errors. Once this code is uploaded to a svn server and Linux programmers pull and compile this code they will get build errors. It seems their compiler compiles everything that is included in the code base whereas Visual Studio will only compile used code.
Is there any way to force Visual Studio to compile even unused code as long as it belongs to the project I am currently working on? Or just every code file belonging to the solution would be helpful as well.
EDIT:
Forgot to mention, in case it is relevant:
We are using: Visual Studio 2008 prof. ed.
C++
cmake to create the solution
Windows 7 x64
Thanks for your time!
Regards,
Jan
How about working with preprocessor definitions? I do also work on a cross-plattform project. There are some UNIX methods I cannot use and there are some Win API calls UNIX cannot use. So we have something like that:
void DoSomething()
{
#ifdef WIN
// do Windows specific code
#else
// do UNIX specific code
#endif
}
Related
I have a VxWorks project that compiles under Toronado on my Win7 machine. I am trying to convert the same project to compile in my Visual Studio 2010. I don't need it to complete to where it creates a .o/out file but at least get through all the defines/includes and etc. so I can use Visual Studio's IDE for definition jumping and etc..
I'm at a point where I'm getting a 'undeclared identifier' for "_interrupt" which is included in several include files from the ..\tornado\target\config\ folder.
I'd appreciate any suggestions
Thanks
I would like to comment on this but don't have enough points.
I do the same thing using eclipse instead of visual studio, I don't do anything special to make it work.
It sounds like you are trying to do the link even though you don't want to. Make sure when you create your project you set it up to create a library not an executable, it should do the compile then but no linking.
I have a large solution made from a combination of c++ and c# projects, most of which output dll's. We also have an executable which depends on the outputs from those projects. Our entire solution is currently built in VS2005. For numerous reasons we have to target v80 for our builds, but we've finally found time to move to the 2010 IDE.
When we build in 2010, our solution all compiles fine, but we get an access violation when running the app. This exception occurs in a number of scenarios, but always at the same point in code - It also shows as an "exception encountered during a user callback". If we edit out the line of code where the exception throws, it simply moves to somewhere else, which makes sense. The scenario's in which we have the issue are as follows:
All dll's and exe built in 2010 against the v80 toolset.
All dll's build in 2005, exe built in 2010 against the v80 toolset.
Notably though, if we use the dll's built in 2010 (against v80) but the exe built in 2005, everything works fine.
My question then is: What is the difference between the output from a build in 2005 and the output from a build in 2010 using the v80 toolset?
The above is probably dependent on whether it is possible to exactly match the commandline arguments for the build (ie, c++ and linker configuration) as it may be we haven't quite got those right. If needed I can link the settings from 2005 and those from 2010.
Any help would be much appreciated.
UPDATE:
I've recently created a very simple application in 2005, consisting of a dll and exe. The dll has a function static __declspec(dllexport) int add(int a, int b). The exe is a simple console application which calls the add function from the dll.
I then ported this to VS2010 and set it to the v80 toolset. Building this produces a dll with the same size as the original, the exe however is 4KB bigger. I'm using dumpbin to try and find out why, but I don't know it too well at the minute. If anyone else can identify in this simple case why the exe's are different sizes, this may help solve my overall problem
Solved this now, the issue was caused by DEP being turned on by default. I can confirm for anyone else though that the output from the builds should and will match exactly if you use the same compiler and linker settings.
Assume I have source code for a lib/tool that works on gcc compiler. Can I use the same code and compile it in visual studio. will that be possible at all? If it is possible, how do I do it?
if you are just using all the standard C/C++ library like stdio.h, stdlib.h, etc. it should work fine. Pure console program should work fine. If you used some GUI related library (especially if you are porting over from unix to window) then it might not work.
To do so, you can simply just create a new project in visual studio and add the existing source code into the project workspace. Compile it, if you encounter any error, just post here or try solve if you know how
It depends on your code, GCC support a variant of C (C99) which Visual Studio doesn't support yet.
If your trying to compile a Unix program on Windows you best bet will be to use Cygwin.
Check this question for pointers on using Cygwin in Visual Studio.
I am pretty new to programming. I would like to download an open source project and build it in my Microsoft Visual Studio 2008. In fact, I tried to import and build the application WinSCP:
https://sourceforge.net/projects/winscp/
But I didn’t work. Please can somebody help me and tell me which files do I have to download (from sourceforge) and how to import these into Microsoft Visual Studio in order to build the application. Thank you a lot. David
WinSCP seems to be written in Borland C++ Builder or whatever it's called today. It's not a standard C++ program and wouldn't compile in any other compiler because it uses special features only present in BCB. (It uses Delphi-style components, VCL and thus the __property keyword.)
Unfortunately, a lot of Open Source projects have very poor support for Microsoft's development tools. One project that comes to mind as being not too big and having workable MSVC project files is FreeType2, but that's a library and not an application, which probably makes it not very interesting for toying around with.
In support forum of winscp, they say, that you can't compile this project in Visual Studio.
Winscp appears to be a CPP project using a makefile instead of a sln file. VS uses SLN and *proj files to control builds and such. A good way to start would be to open VS, create a new console project (and solution) and go through some tutorials online.
If you really want to just see how a large project works in VS, grab something like IronRuby or IronPython or even something like the Witty twitter client.
In the general case, it is not possible to pour the C++ sources of a program into Visual Studio and expect it to work. C++ programming environments are far too different between operating systems for that. If you have a open-source program which builds and runs fine on Linux (for example), it may need several weeks (or months) or programming effort to make it run on Windows.
Any suggestions on how one could go about setting up a build system that would compile one or two libraries against a couple of different platforms/targets.
The main project is in Visual Studio.
For example, I have a library:
nav.lib
It compiles on Windows and Linux with a few tweaks.
The executable that uses the library, win_nav.lib, only compiles on Windows at the moment with OpenGL.
I'm porting this code to the iPhone. Although I know I can't compile and link the entire library on windows I would like to try to compile the graphics code with OpenGL includes and OpenGLES includes. (Perhaps I can test out my opengles code on the windows machine as well?)
I plan to change my graphics file to include based on preprocessor flags:
#ifdef USE_OPEN_GL_FULL
#include <opengl/gl.h>
#else
#include <opengles/gl.h>
#endif
So, how would you go about doing this?
Using a couple of different scripts or different projects in Visual Studio?
This is what "Solution Configurations" are for. By default Visual Studio creates Release and Debug configurations, but you can add your own custom configurations too. The Project options are different for each configuration, so just set your #define in the configuration that needs it.
When you are running your automated build you just set the /build parameter to the name of the configuration you want to compile with.
Within VS you can use the Configuration Manager to target different builds and use different libraries within your code.