123456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_ =============================================== =============================================== CodeBlocks and GLUT Installation: =============================================== =============================================== This is my first quarter using Code::Blocks, the open-source cross-platform IDE we'll use for all projects in EECS110 and EECS351, but Chris Riesbeck has been using it in his classes for a while. Several students figured out these methods with me to get CodeBlocks, GLUT, and openGL working together, and everyone succeeded on every kind of computer. =============================================================== STEP 1: Get CodeBlocks installed and running on your machine (see instructions below) ================================================================ To Install CodeBlocks C/C++ IDE: --For MacOS:----------------------------- Install Apple's XCode dev. kit on your machine first, because it has a GCC compiler you'll need for CodeBlocks. --1) Xcode is free, it's on your MacOS installation disk, and also available for free download from Apple's website (HUGE download--780MB). --2) BE SURE you get the right version of Xcode! Is your OS 32 bit, or 64 bit? SnowLeopard, Tiger, or something else? Read instructions; the most recent version of Xcode available on the apple website will not work with macs that run Tiger! (For example, in Jan 2010 a student with a mac 10.4.11 from 2007 could not install Xcode version 3.2.1; instead she succeeded by installing Xcode version 2.5.) --3) Go to the CodeBlocks website, and install the latest version for MacOS. (Jan 2010: Patch 2) --4) NO_SPACES: BE SURE you don't have any spaces in folder names or filenames for your work with CodeBlocks. If you do, you'll get strange 'file not found' errors when you compile. --For Windows XP:--------------------------------- Go the CodeBlocks site, read carefully, and install. --As usual, UAC can interfere, so be sure you're logged in as Administrator before you attempt installation. --Also, be sure you install the CodeBlocks version that includes mingw, because that gives you the GCC compiler you'll need. --If you've used CodeBlocks in Dr. Riesbeck's classes: I don't require Cygwin and do-it-yourself makefiles, as CodeBlocks' built-in project-management works fine for us. If you WANT to mess around with makefiles (Not recommended; needless complication for our class) see his online web-guidance: http://www.cs.northwestern.edu/~riesbeck/programming/c++/ --For Windows Vista, Win7:--------------------------- Here's a proven step-by-step method from student Elizabeth Casano, who writes: ----------------------------------------------------- Okay, this should work for both Windows Vista and 7 users. It's a little weird but trust me. 1. First, get rid of anything you've installed already (i.e. Codeblocks, MinGW). This makes sure we all start on the same page. 2. Go to the CodeBlocks website and download the latest, such as 'codeblocks-8.02mingw-setup.exe' (yes--the one that DOES have MinGW). 3. Install it. It will ask to install to 'C:\Program Files\CodeBlocks.' Don't change this location. 4. Go back to the CodeBlocks page where you find the downloads, and click the link to the MinGW website in the note beneath the Windows download options. 5. On the MinGW site, find the Downloads link among the lefthand menus. 6. On the new page, hit the big green 'Download Now' button to download the latest version of MinGW. 7. Install it. It will ask to install to the location 'C:\MinGW.' Don't change that. 8. Once it has installed, go to 'C:\' (your hard disk drive--it's under Computer) and cut the MingGW folder. Paste it into the folder Program Files. 9. Open CodeBlocks and start a new project. Go up to the Settings tab and click 'Compiler and debugger...' 10. Find and click the Toolchain Executables tab. Where it says 'Compiler's installation directory,' click the button '...' 11. Find the CodeBlocks folder, and select the MinGW folder that it contains. Press Ok, and then Ok in the Compiler and debugger settings window. 12. Now try to build and run your program (i.e. main.c). It ought to work! ASIDE: I don't know why you can't just install 'codeblocks-8.02-setup.exe' from CodeBlocks and MinGW from MinGW and then make it work, but for some reason I have to have everything exactly as described above (with two versions of MinGW on my computer, but using the one that comes with CodeBlocks). --Elizabeth Casano ----------------------------------- ASIDE from Instructor: After getting Elizabeth Casano's method to work, try this: in step 8-10, specify your C:\MinGW directory instead of the MinGW you find in the C:\Program Files\CodeBlocks directory. The later version in C:\MinGW purportedly works better with MS Vista and Win7. ============================== ADDITIONAL CODEBLOCKS INSTALL HINTS: ============================== 1) In MacOS, be sure you don't have any spaces in your file and folder names. (This seems to be a problem on Tiger only). This is often the problem when you get error messages such as 'invalid file' or 'file not found' in CodeBlocks 2) If CodeBlocks installs but when you try to build the default 'hello world' program, you get an 'invalid compiler' error, CodeBlocks probably has an invalid path to the gcc compiler on your machine (found either in C:\mingw, C:\Program Files\CodeBlocks\MinGW, or C:\cygwin on Windows, or in Xcode on MacOS). You can fix this easily: --At the top of CodeBlocks window, select the menu item 'Settings' --> `Compiler and Debugger...' and it will open a pop-up window with more controls. --Within this window, click on the 'Toolchain Executables' tab near the top. Within that tab, press the `Auto-Detect' button; it search for your gcc compiler. If it finds one, hit OK and you'll have a 'valid compiler' to build your programs. --OR you could enter the file path yourself in the edit boxes shown. =========================================================== STEP 2: Once you get CodeBlocks installed, test it: =========================================================== --create a new project; --choose console project; --choose your desktop as the file location, --follow the wizard, and compile and run the default program ("hello world") --it should run without any errors or warnings, as shown in class. If it doesn't, fix your CodeBlocks installation before continuing with Step 3; ask for help. --HINT: when creating your own CodeBlocks projects from scratch, set the compiler to "show all warnings"; it ensures that the compiler will point out every potential trouble spot in the new code you write. Here' how: --At top of CodeBlocks window, pick menu item 'Settings --> Compiler and Debugger..." --At top of the pop-up window that appears, choose the 'Compiler Settings' tab (usually chosen for you already), --Within that tab, look a little lower, and select the 'Compiler Flags' tab (it's also usually already chosen), --Within the long list of checkboxes, near the top you'll find two: --CHECK the box for: 'Enable all Compiler Warnings(overrides every other setting) [-Wall] --and CHECK the box for: 'Enable Standard Compiler Warnings [-W]. The default settings for CodeBlocks ignore minor flaws, so that code written by others won't fill your screen with suggestions for improvements to code you shouldn't change. I *WANT* you to see these compiler warnings to help learn good habits in C. ============================================================ STEP 3: put GLUT on your machine where CodeBlocks can use it: ============================================================ Here's my explanation, updated with what several students and I learned yesterday and today (2010.01.14) getting CodeBlocks and GLUT to work on man different types of student machines: Apple MacOS: =========================== Do nothing; you have GLUT installed already as part of Xcode (that you installed before CodeBlocks). Done! Windows XP, Vista, Win7: =========================== 1) Download glut library binary from Nat Robin's web site: http://www.xmission.com/~nate/glut.html The zip file (glut-3.7.6-bin.zip (117 KB) contains: glut32.dll, glut.h. 2)Put glut32.dll in the directory where windows keeps all its 32-bit DLLs on your system, -For XP and 32-bit Vista/Win 7: C:\WINDOWS\system32 (some older installs use C:\WINNT\system32) -For 64-bit Vista and Win7: C:\WINDOWS\SysWOW64 (where it keeps all 32-bit DLLs run by 64-bit system) UBUNTU Linux: ================= -Ubuntu 8.10: use the installer, get/install packages for -OpenGL -GLUT (requires freeGLUT), and -libXxf86vm-dev (not sure why (or if) it's needed) Non-Ubuntu Linux: LET CODEBLOCKS DO IT: -------------------- CodeBlocks has a wizard for GLUT projects you can use if all else fails. Start a new project, select 'GLUT project', follow directions. You'll get error messages that tell you about missing packages (openGL, GLU, freeGlut or GLUT). Install them; set paths within CodeBlocks. Once the default program compiles, it will show you a beautiful bit of animated openGL code. Did it work? then add our source-code files to the project, remove the default 'main.cpp' file, and compile. That should work; if it does, skip all the stuff below; you're done! =========================================== STEP 4: RUN YOUR FIRST GLUT/OpenGL PROGRAM =========================================== Now download the ZIP file of 'starter code' for a graphics project; I've posted at least one on Blackboard. Extract it; it will make a project folder (e.g. firstGraphics) that contains your complete CodeBlocks project. Inside that folder, click on the colorful hollow-square icon; the file named .workspace. It will start your CodeBlocks project. Hit the CodeBlocks 'build and run'--it should work for windows XP. IF IT DOESN'T WORK FOR YOU: You'll need to correct the CodeBlocks settings for libraries, then save your workspace to keep those settings. --At the top of CodeBlocks window, --go to the menu item 'Project'-->Build Options... --at the top of the pop-up window, click 'Linker Settings' tab, --and you should see: FOR WINDOWS: -lglut32 -lglu32 -lopengl32 FOR MacOS: at the upper left, you'll see two words; 'default' and (e.g. glutStart) --Select , then you should see: -framework GLUT -framework OpenGL -framework Cocoa If you don't, type that into the right-side white window area. **DON'T** cut-and-paste it! sometimes cut-and-paste carries along hidden characters that confuse CodeBlocks. It looks OK on-screen, but CodeBlocks gets confused and won't work. --THEN select 'default' and you should see nothing. If you see anything such as -lglut32, -lglu32, -lopen32, delete it; hit the 'clear' button. FOR UBUNTU: at the upper left, you (may) see two words: 'default' and (e.g. glutStart) --Select , then you should see: GLU glut GL If you don't, type that into the right-side white window area. **DON'T** cut-and-paste it! sometimes cut-and-paste carries along hidden characters that confuse CodeBlocks. It looks OK on-screen, but CodeBlocks gets confused and won't work. --THEN select 'default' and you should see nothing. If you see anything such as -lglut32, -lglu32, -lopen32, delete it; hit the 'clear' button. --HINT: To clear 'linker options' press 'clear' button. --HINT: DON'T CUT-AND-PASTE these text strings from a website! otherwise you often get unprinted characters that mess up CodeBlocks settings. Instead, just type in the text yourself. --HINT: 'File not Found' errors? --Check for spaces in your project's filenames and paths --Search: does the word 'introGlutLib' have exactly the same capitalization for each letter as the filenames in your project directory (introGlutLib.c, introGlutLib.h)? On some operating systems CodeBlocks won't find files with matched spelling but mismatched upper/lower case. ================================================================== Regards, -Jack Tumblin