Visual C++

Pages: 12
Does the free version of Visual C++ have only command line compiling?

I think visual studio is the IDE but I couldn't find a free version of that. I'm not a student so I know I don't qualify for any discounts or anything else. If anybody knows of a free or cheaper version let me know please :)

I was mainly trying to figure out how to compile boost on my own (i already have the nuwen mingw with it precompiled and can run regex programs but I still want to figure out how to compile boost myself)

Everytime I follow the instructions to compile boost I get errors that cl is not recognized command and it says using msvc at when it starts compiling. (which makes me believe that you can only build boost with microsoft visual studio)

I wasn't able to find a way to set the boost-build program to gcc or g++ when compiling boost. Another thing I noticed is every time I want to compile from the command line with mingw I have to run the set_distro_paths.bat before I can do any command line compiling.

Is there a way to have that .bat run automatically when I open a command prompt?

Any help is appreciated and thanks again!
Last edited on
Garion wrote:
Does the free version of Visual C++ have only command line compiling?
No version of VC++ has support for command-line compilation.

VC++ Express Edition is free.

You can build boost with other compilers but you must specify that when running b2, with either toolchain=gcc or toolchain=mingw or toolchain=clang, etc

As for set_distro_paths, you can completely ignore it and just add C:/MinGW/bin to your system PATH variable.
Last edited on
Ok, I managed to figure out how to change my system path variable and now I can compile from the command line without running set_distro_paths.bat when I open the command prompt.

I'm still little fuzzy on how that works though. How does the environmental variable know to look into the directory C:\MinGW\bin when I type in a line like

gcc helloworld.c -o helloworld


The system path variable seems to have a string of directories each separated by a semi colon.

Is there a tutorial somewhere I can go to read about these system commands for setting directories and how they function?

Going to try my luck at building boost now :)
> No version of VC++ has support for command-line compilation.

In every versions of VC++, the compiler is a pure command-line tool.
Use cl instead of g++.

For instance, to compile, link and run my_program.cc:
> cl <compiler-options> my_program.cc <linker-options> && my_program.exe

http://msdn.microsoft.com/en-us/library/ms235639.aspx
When you execute gcc from command line Windows just searches the system path for a program called gcc.exe and then executes it.


Also here's a link the the free version of visual studio: http://www.visualstudio.com/downloads/download-visual-studio-vs#d-express-windows-desktop
I think i got boost compiling now. My computer has been going at it for like 10 minutes already.

I basically did the
bootstrap.bat mingw
in the
tools\build\v2
directory.

Next it asked me where to install boost.build. I was a bit confused by this as I had downloaded an zip file and unpacked boost.build into a folder and the install steps had nothing to do with this other download.

so I ran
b2 install --prefix="Root Directory of Boost"
and it created a folder in the root directory called "Share" with a "Boost-build" folder and about 300 or so files in it.

Then I added this new Boost-build\bin folder to my system path variable.

Then I tried to invoke b2 to that Boost-build folder which was in the share folder and I got errors.

So I tried to invoke b2 to the other boost-build zip I had downloaded separately.

b2 ^
More? --build-dir="C:\build-boost"^
More? --build-type=complete gcc stage



Then I went to my root boost directory and typed this

bjam toolset=gcc


and now my computer is doing all sorts of compiling (I hope).

I'll let you know if it works when it finishes.

edit.. yah I think it's working now.

I updated my IDE's boost global variable to the folder that I compiled boost in my self (I know, I got a lot of hard drive space so I had nuwen's mingw and the other version I was messing with installed)

Regex programs seem to be compiling and running fine. I made sure by changing the code a bit and recompiling.

Hopefully I can now figure out how all these steps work together. I'm kind of interested in reading about how to build my own libraries also.

I'll download a version of Visual C++ and give it a shot too. It can't hurt to learn how another IDE works I suppose.

Thanks again for the advice :)
Last edited on
> I'll download a version of Visual C++ and give it a shot too.
> It can't hurt to learn how another IDE works I suppose.

Most people consider the Microsoft IDE to be the best that there is.

More than the IDE, the real programming advantage with Microsoft C++ (over GNU) is that it comes with a much better C++ standard library.
Last edited on
^ What JLBorges said. We use MSBuild a lot at work so it was stuck in my head.

I second the Visual Studio recommendation, it is one of the most powerful IDEs available and its debugger is VERY powerful.
Last edited on
JLBorges wrote:
> No version of VC++ has support for command-line compilation.

In every versions of VC++, the compiler is a pure command-line tool.
Use cl instead of g++.
I meant that no version of the IDE has inbuilt support for directly typing the command line - you can only alter the command line through the property pages. Perhaps I should have been more clear.
Wow, 5 GB?

What the heck do they even have on that thing. Guess I'll leave my computer on over night.
I meant that no version of the IDE has inbuilt support for directly typing the command line - you can only alter the command line through the property pages. Perhaps I should have been more clear.

I'm still not sure what you mean.

VC++ comes with a batch file (vcvars32.bat) to initialize the command line so you can use it directly to compile with cl and link.

It takes a little bit of setup to make things work. I have a little directory (named "bin") in my user account that I initialize automatically in the path when I start a command prompt. In that, I have a little batch file that reads like this:

cl.bat
@echo off
call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\vcvars32.bat"
cl.exe %*

So if I type "cl foo.cpp" then the batch file automatically sets up the MS environment and passes off to the real cl. After that, the real cl's executable is in the PATH ahead of my little bin directory, so the real cl gets called directly every subsequent time I type "cl bar.cpp".

@Duoas: I very much doubt you clicked on a button or selected a menu option within the IDE to access that batch file.
> @Duoas: I very much doubt you clicked on a button or selected a menu option
> within the IDE to access that batch file.

The Command window is used to execute commands or aliases directly in the Visual Studio integrated development environment (IDE). You can execute both menu commands and commands that do not appear on any menu. To display the Command window, choose Other Windows from the View menu, and select Command Window.
http://msdn.microsoft.com/en-us/library/c785s0kz.aspx


With Duoas' batch file setting an alias (in the command window) would be convenient:
> Alias cl Shell /c /o cl.bat

And then:
> cl <compiler-options> my_program.cc <linker-options> && my_program.exe


Not that any of this talk about the Visual Studio IDE - buttons, menu options, command window etc. - is even relevant to the validity of the original bland assertion:
No version of VC++ has support for command-line compilation.
Again I should be more specific - the command window does not allow you to type shell commands directly. As you've shown you have to use the "Shell" command. I guess it really depends on where you draw the line - I draw it such that the VC++ command window is not a command line interface, but you may draw it differently. But I think we're taking this too far :p
Last edited on
> But I think we're taking this too far

Yes. Starting from about here: http://www.cplusplus.com/forum/general/121552/#msg662504

The Visual Studio IDE is not the Visual C++ compiler.

The Visual C++ compiler has always been a pure command line tool; that it can be invoked from within IDEs - Visual Studio, CODEBlocks, CodeLite - does not change its nature.

The Intel compiler too is a pure command line tool; that it can be invoked from within Visual Studio IDE does not even remotely imply: "No version of the Intel C++ has support for command-line compilation".
Whoops. When I say VC++ I always refer to the IDE. I use MSVC to refer to the compiler. Sorry :(
Ah, yes. I don't tend to do much from the IDE itself.

When I say command-line, I mean straight-up cmd.exe Windows Console shell.
I noticed that when I was playing with Visual Studio.

I think that's visual basic. I've been meaning to learn that so I can make my desktop app's have buttons and drop down menu's and other stuff. I'll mess around with it some either way.

Can you make Visual Basic and C++ work together in a program? That's what I was going to read about soon.

Still working on learning about libraries and how to make them work in C++.

Ideally I'd like to be able to do something like

1
2
#include <iostream>
#include <mycustomlibrary> 


I'm still not sure that's possible though, everything I read about still says I have to include header files. It'd be nice to just do one include and not mess around with header files.
BASIC is commonly known for the quote sating that anyone who learns BASIC is mentally scared beyond repair - I guess it gets this rap because of how goto was commonly used in it. I might avoid it unless you're being hired to port basic to a newer language.
Pages: 12