Sunday, July 26, 2009

How do you compile using visual studios?

when using the c++ visual studio express, how do to you build the exe file? (in other wordshow do you compile?) when I compile, it says 0 built, 1 error. How is the error avoided? I know that my source code is corret becuase I used another compiler and it gave me an exe. file correctly. (nothing works: build, debug, rebuild...etc..) thanks

How do you compile using visual studios?
The cleanest way according to my experiences is to simply wrap the cl.exe and link.exe and handle the custom builds there. Few things to take into consideration are:





1. Decide whether you want to use "permanent" wrapping or try do swap in and out the wrappers when required. Permanent wrapping could use the command line parameter or some registry/file key of a user to determine when to use the custom call. When reverting back to the original cl.exe and link.exe, be sure that your environment (environment variables, paths and stuff like that) are intact of what they were when your wrapper was called.





By intact I mean, that the Visual Studio relevant info is proper (see below on the wrapping). At least when starting the process with .NET libraries, the environment passed over from the wrapper by default.





2. Depending of the 3rd party tools, it is likely that you have to clean up and reformat the command line tool output. You likely can get rid of the 90% of the issues with simple .NET regexping, by formatting the warning/error and alike messages to the Visual Studio format.





Note: some portions of VS command line tools use environment variables for communicating with Visual Studio for various matters. I don't recall on top of my head, what the variables are, but you'll find them by examining the environment variables that are passed to the cl.exe for example. If you don't remove these (or reroute to your own), some messages will bypass the standard output and thus you cannot reformat them.
Reply:if it says you have an error - you have an error. find the error and fix it and then you'll be able to build. good luck!
Reply:What is the error message/code?





Does your program have multi files (like more than one cpp and h file)? If so, you need to create a new project before compiling, you cannot just open directly the .cpp or .h files and try to compile, it won't establish the link between files.





Good luck


No comments:

Post a Comment