PDA

View Full Version : Getting my C++ Compiler to compile in all directories


AtreideS
08-11-2003, 06:30 AM
Hi,
I've just installed the Borland C/C++ Compiler 5.5. It runs fine except I have to have all the files I want to compile in the directory c:\Borland\BCC55\Bin (where the Compiler is installed).
How can I change it so that I can compile from any directory? In the past I've installed the Java SDK, and I remember at the beginning it could only compile from the installation directory. However, there was a setting that I changed which allowed it too compile everywhere. So I'm pretty sure there will be a similar setting for this C/C++ Compiler.
So far I've installed it correctly, following the Borland instructions, and the compiler is working fine... except you have to be in the Bin directory for the Command Prompt to recognise commands such as "BCC32 helloWorld.c"
Is it possible to do what I'm after?

Hope I haven't made that too confusing.... :)

Thanks.

Smerdyakov
08-11-2003, 12:31 PM
The command prompt needs to be told where to look for executables to run. If you haven't added the Borland bin directory to the PATH environment variable (or probably some different thing for post-98 Windowses), then it won't know where to find them. Thus, you need to add it! (In fact, you can user bcc from any directory already, but you just have to type out the full path to the executable each time.)

sans-hubris
08-11-2003, 04:06 PM
Do you need to use Borland for something, or are you just trying to learn C++? There are a number of really good and free C++ IDE out there, the most well known and respected being Dev-C++ (http://www.bloodshed.net/devcpp.html). 4.01 is the stable version, but my experience has shown me that the beta 5 works fairly well, and is rather stable, although, admittedly I have only used the beta briefly.

AtreideS
08-12-2003, 06:20 AM
Thankyou both for your replies.
Smerdyakov: Yes I have set the Path Environment Variable, but for some reason it's only allowing me to compile in this one directory. I will double check everything again. Thanks.

sans-hubris: I am just starting learning C++ at uni, and I wanted to have a similar setup to what I have to work with at uni. There we use Linux, with the text editor Vim, and some Unix based compiler (GCC I'm guessing?).
Anyway, I wanted to use GVIM for my coding, and then just compile in a Command Prompt window (as I've been doing for Java). The Borland Compiler seemed like a good option, however is there a better compiler I could be using that runs well on Windows XP? I'm not really looking for a IDE (although Dev++ does look quite nice). I'm just happy with a simple compiler to work along side GVIM (my text editor).
Thanks. Your input is most welcome.:)

AtreideS
08-12-2003, 06:26 AM
Oh I am such a goose.:P
I just rechecked the Enviroment Variables, and I simply placed the Borland Compiler line at the front (ahead of the Java SDK), and it's fixed the problem. Somehow I'm guessing it doesn't like to be last in the Path list. Anyway, it's all working fine now. Thankyou very much for your help.:)

jamessan
08-12-2003, 08:38 AM
If you truly want to mirror the setup you're using at the university but in Windows XP, try Cygwin (http://www.cygwin.com). It's a free Posix environment for Windows. It has, among other things, vim, gcc and gdb (debugger).

sans-hubris
08-13-2003, 05:00 AM
Originally posted by AtreideS

sans-hubris: I am just starting learning C++ at uni, and I wanted to have a similar setup to what I have to work with at uni. There we use Linux, with the text editor Vim, and some Unix based compiler (GCC I'm guessing?).
Anyway, I wanted to use GVIM for my coding, and then just compile in a Command Prompt window (as I've been doing for Java). The Borland Compiler seemed like a good option, however is there a better compiler I could be using that runs well on Windows XP? I'm not really looking for a IDE (although Dev++ does look quite nice). I'm just happy with a simple compiler to work along side GVIM (my text editor).
Thanks. Your input is most welcome.:)
jamessan makes a good suggestion, however, Cygwin is rather large, sometimes unwieldy, and a tad slow. Also, any applications that you compile under Cygwin are tied to Cygwin. However, it will allow you to work in an environment that is similar to your Linux environment at your university (including GCC.) I can almost guarantee that the compiler you use at your uni is GCC. It's the standard for Linux.

If you want something a little more lightweight than Cygwin, but still mostly be the same environment, I highly recommend you go get MinGW and MSYS (http://www.mingw.org/). Combined, they're only partial POSIX implementations, but should largely be enough to keep you on familiar grounds. MinGW is GCC for Windows, and it's what Dev-C++ uses (although, it can use Cygwin's GCC.) Applications compiled with MinGW are not tied to MinGW and can be run independently. You can even write Windows applications with it.

I'm more concerned that you're trying to use Borland's compiler when your uni uses Linux, and most likely GCC (I'd be surprised if they're not.) It's important that you use the same compiler and libraries on your computer. Doing so will save you a lot of headaches with portability. Your professors may not realize it (or at least mine don't), not all compilers are made equal, nor do any of them completely implement the C++ standard, and what each one does implement varies with each compiler. My personal experience is that Borland comes out with some of the worst compilers I've worked with. I had an easier time porting code between MS Visual C++ and GCC than Borland and GCC.

In the end, though, if you have some spare resources (especially a spare computer, or even an extra hard drive), I would recommend getting some experience on Linux on your own. This means going out and installing Linux on those spare resources. SuSe, Mandrake, and Lycoris are all great distributions with which to start out. While you could downloard their ISOs somewhere on the internet, I would recommend buying them instead. There is usually stuff you get with the boxed version that you don't get from the downloaded ISO.

AtreideS
08-13-2003, 08:01 AM
Thankyou once again for your advice. Installing Linux would be a great idea, and I will certainly consider it in the future.
I'm more concerned that you're trying to use Borland's compiler when your uni uses Linux, and most likely GCC (I'd be surprised if they're not.) It's important that you use the same compiler and libraries on your computer. Doing so will save you a lot of headaches with portability. Your professors may not realize it (or at least mine don't), not all compilers are made equal, nor do any of them completely implement the C++ standard, and what each one does implement varies with each compiler. My personal experience is that Borland comes out with some of the worst compilers I've worked with. I had an easier time porting code between MS Visual C++ and GCC than Borland and GCC.


I will certainly look at the other alternatives to Borland in the future, if (or when I guess:)) I come across a portability issue. For today however, I'd much rather just get stuck into some basic C and C++ programming and worry about all that a bit further down the track. I'm guessing that most problems will arise with more advanced programs than the ones I will be creating in the next few weeks, so it's not an immediate problem for me to deal with. But thankyou for your suggestions, and I will certainly take them onboard.

I guess I've been a bit spoilt in learning Java first, where the majority of people use the Sun Java SDK, and portability problems aren't so prevalent.

Thanks.:)