0

So.. I'm looking to start learning C++. I've touched on it before and I've touched on Lua before. I'm just bored with PHP/Javascript.

I might be "noobish" with this question, but since my laptop is 64bit, does that mean I have to install a 64bit compiler? If so, Could you point me to one?

If I don't need a 64bit compiler, why is 32bit / 64bit thrown around so often when I read websites?

I'm sorry as I never really knew why things happened, like the technical reason, I just knew what I had to do to make things work ( Regarding PHP/javascript).

Thanks.

AlanPHP
  • 188
  • 2
  • 3
  • 14
  • 4
    It depends on your platform. If you're on Windows, you should probably just download Visual C++ Express. If you're on Linux, then you probably already have an appropriate compiler installed (GCC). – Oliver Charlesworth Jun 23 '12 at 15:33
  • 2
    32 bit compilers will generate executables that work on both a 32 and 64 bit OS, so they're the more flexible choice. And I should add that most of the time a single compiler can do both depending on how you configure it. – Mark Ransom Jun 23 '12 at 15:36
  • I'm running Windows. Does a 32bit compiler work with a 64bit computer? – AlanPHP Jun 23 '12 at 15:37
  • [MingW](http://nuwen.net/mingw.html) distributed by Stephan Lavavej is a *very* easy-to-install GCC distribution for any Windows. – Kerrek SB Jun 23 '12 at 15:41

3 Answers3

1

You can run a 32-bit compiler on a 64-bit machine, but you won't be able to compile native 64-bit executables or libraries with it. The terms are used a lot because 64-bit has benefits over 32-bit that can only be taken advantage of with a 64-bit compiler, such as an extended address space. Unless your application uses huge amounts of memory, though, it probably doesn't matter as much.

Since you're on Windows, your best bet is Visual C++ Express Edition. It's free, but doesn't include a 64-bit compiler by default. You can still add one, if you want to, but you'll need to install the Windows SDK, as explained here.

Community
  • 1
  • 1
David Brown
  • 35,411
  • 11
  • 83
  • 132
  • "You can run a 32-bit compiler on a 64-bit machine, but you won't be able to compile native 64-bit executables or libraries with it." - why would the compiler being 32-bit limit its ability to generate the right format / opcodes etc in the object image it creates for a 64-bit program or library? I can't see any relationship. – Tony Delroy Jun 23 '12 at 16:36
  • You're right, there's nothing keeping a 32-bit compiler from generating 64-bit binaries. My bad! – David Brown Jun 23 '12 at 16:45
1

If you are using Linux, I highly recommend you gcc and clang. In Windows, i think the best compiler is Visual Studio.

Note: 32-bit compilers compile both in 32 and in 64-bit mashines, so you needn't worry.

Rontogiannis Aristofanis
  • 8,883
  • 8
  • 41
  • 58
  • 4
    Visual Studio is not a compiler, it's an IDE. You can get MSVC (the compiler) without Visual Studio (the IDE) in for example the Windows SDK v7.1. – rubenvb Jun 23 '12 at 15:49
  • 1
    64-bit machines can run 32-bit code through virtualization. That is NOT the same thing as compiling to 64-bit. There are costs for running 32-bit on a 64-bit machine. – Cdaragorn Oct 29 '14 at 21:53
1

As you probably know on 64 bit versions of Windows you can execute both 64 bit and 32 bit applications. For this reason it doesn't really matter whether the compiler of your choice is a 32 bit or a 64 bit application.

What is more interesting is whether the compiler of your choice can generate both 32 bit and 64 executables or only one kind of them. The former are more versatile while the latter may take full advantage of a 64 bit architecture.

In your place I'd download Microsoft's Visual C++ Express, a free integrated environment which contains all you need to get started.

Note this compiler will only let you build 32 bit executables, but for a begginner like you say you are it shouldn't really matter.

Nicola Musatti
  • 17,834
  • 2
  • 46
  • 55