Question:
How to compile 64 bit program on 64 bit machine with notepad?
2012-06-21 08:04:22 UTC
I JUST started learning C, I have the book "programming in C" by Stephen G. Kochran. The first lesson is a very basic code pretty much stating the whole " Hello World" but when I save .exe in notepad and try to open it says that the compiled program is 32 bit. I can't find anything in options to change the way it saves and I want to use the most basic compiler for this as I am learning from the ground up. Please correct me if something doesn't make sense, thanks.
Three answers:
jplatt39
2012-06-21 09:16:57 UTC
Notepad is a text editor. This is a command-line port of GCC to windows:



http://mingw-w64.sourceforge.net/



To compile open a command window, make sure the %PATH% variable includes pointers to the bin include and lib folders cd to the folder your source code is in and type "gcc -o .c" The documentation includes ways to change the path variable and to step through the program for debugging add a -g switch to compilation then type "gdb " type l, which should list the first ten or so lines of your program, set a break point, type r to run it to the breakpoint then when it gets there type s to step through it one line at a time.
husoski
2012-06-21 18:05:06 UTC
Notepad...well, you *could* use it as a text editor. There are better text editors for programmers, though. Notepad++ (http://notepad-plus-plus.org/) and Notepad2 (http://www.flos-freeware.ch/notepad2.html) are free Windows choices. I use a shareware editor, TextPad. (free to try, US$27 to buy, nice features, but does not handle Unicode, google it. )



But...



I mostly use those for Python and small Java progs. For C and C++, I almost always use an Integrated Development Environment (IDE), mostly for the built-in debugger. For Windows-only, I use Visual C++. The Express versions have nearly all the C/C++ tools from the full version (no icon editor, win32 target only). Don't worry about 32-bit vs 64-bit mode yet...just learn the C first. For pure C++ with no Windows extras, be sure to start every project as an Empty Project, and not a Console Application or Win32 Application. (http://www.microsoft.com/visualstudio/en-us/products/2010-editions/express)



For anything that might run anyplace else, I use Code::Blocks as an IDE and GNU C/C++ compilers. I recommend the MinGW port of the GNU tools. You can get both in a bundle, I think, but I think it's best to install separately...MinGW first, then Code::Blocks. You can also use Eclipse or NetBeans with GNU tools, including MinGW on windows. One thing missing from the C::B editor, though, is a good source code reformatter. There's a very basic one that will be alien to most C/C++ programmers. (I keep putting off writing one...I wonder for how long?)



MinGW: http://www.mingw.org/wiki/Getting_Started

Code::Blocks: http://www.codeblocks.org/downloads/binaries



There is a MinGW-w64 project, generating 64-bit binaries, that claims to be stable at release 2.0, and also lists Code::Blocks as supported. (I haven't used it.) Unless you have a specific need for large memory support, I'd suggest sticking with the 32-bit model. That has the 64-bit data types, and runs on both 32 and 64-bit systems. A 64-bit binary only runs on 64-bit OSes.



MinGW-w64: http://mingw-w64.sourceforge.net/
Kyle
2012-06-21 15:18:06 UTC
HAHAHA. I used to think the same thing a year or two ago when I was an ultra-n00b. Notepad is a text editor. It does not compile. It is a dumb idea to use it for C. But, if you really want to use it, you can write your code in it, then save it as .c , then compile it with MinGW, MSVC, Borland, or Mars. Once your program is compiled, you must link it. Linking it transforms it from a .o file (or .obj for MSVC) without its libraries to the final .exe. There is really no point to a 64 bit hello world. If you really want to juice performance from your console apps (lol), then you could use OpenCL to leverage cores and threading and parallel computing in general. Whenever you want to use a serious tool: http://www.codeblocks.org or http://www.microsoft.com/visualstudio/en-us . I recommend the first, as it is free, open source, doesn't take an hour to download, and much more straightforward because it doesn't have ten million confusing features.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...