Compiling OpenGL Programs Using Visual Studio on Lab Windows Machines

Reference URL: (http://www.cs.uiowa.edu/~cwyman/classes/common/howto/compileVS.html)

Compiling OpenGL Programs Using Visual Studio on Lab Windows Machines (e.g., MLH 301):

The hardest part about compiling any program using Visual Studio is figuring out how to navigate the myriad of options. Once you figure out what is important for your project and what you should leave as default, everything is easy.

Remember, the key things you need to do are:

  • Tell Visual Studio where your code resides (or will reside).
  • Tell Visual Studio which code files to compile.
  • Tell Visual Studio what libraries you need.
  • Tell Visual Studio where to find those libraries.

The instructions below will get you through the initial step of setting up a project. Even if you have used Visual Studio before for other classes, I encourage you to read all the steps, as some selections will differ from those needed in prior courses.

These instructions work for Visual Studio 2008, though they are mostly similar for other versions:

  1. Open Visual Studio 2008.
    • If this is your first time, I encourage you to select "Visual C++" as the default configuration.
  2. Once it has completely opened (which may take some time) select from the menu "File" followed by "New" followed by "Project".
  3. In the New Project dialog box:
    • Type a name for your project and a location where you want your project directory.
    • For the project type, select "Visual C++" then "Win32" then "Win32 Console Application"
    • Click "Ok"
  4. In the Win32 Application Wizard dialog box:
    • Click "Application Settings"
    • De-select "precompiled header" (unless you know what they are)
    • Select "empty project"
    • Keep the application type as "Console application"
    • Click "Finish"
  5. You will now return to the main Visual Studio window, where a subwindow entitled "Solution Explorer" will appear. This contains information about "Solution < myTestProject >" (where < myTestProject > is whatever you named your project). Visual Studio should also have created a project directory where it will store the files. Open up the directory "< myTestProject >" and its subdirectory (also called "< myTestProject >"). There you should see a file called < myTestProject >.vcproj (or labeled "VC++ Project"). Copy any code you would like to use into this subdirectory. If there are a lot of files, you may wish to arrange them in an organized fashion.
  6. Back in the Visual Studio subwindow (the "Solution Explorer"), you should see folders labeled "Header Files" and "Source Files."
    • Right click on "Source Files," select "Add," select "Existing File" and then select the C/C++ file you wish to use (e.g., my "glut_template.c" file). Alternately, create a new file and start typing in code from scratch.
    • Right click on "Header Files," select "Add," select "Existing File" and then select the header file you wish to use (e.g., my "glut_template.h" file).
    • If you find it easier, you can drag and drop files directly onto the solution explorer.
  7. Right click on the BOLD name of your project in the "Solution Explorer."
    • Select "Properties" (all the way at the bottom of the pop-up menu)
    • Click the plus (+) next to "Linker" to see more linker options
      • Click on "Input" and add an entry to "Additional Dependencies." This entry should be "opengl32.lib glu32.lib glut32.lib" (without the quotes).
    • Click "OK" to confirm your changes and close the properties dialog.
  8. Double click on any of the listed code files to open them and begin editing.
  9. Once you have finised coding, press "F7" to compile (or build) your project.
  10. Your executable will be in the "Debug" subdirectory of the project's directory. If your executable requires no command-line parameters, you can run it directly from inside Visual Studio by pressing "F5."

If you change the project from a "Debug" to a "Release" build (which I would not recommend during this class), you may need to repeat your changes to the solution's properties page as the Debug and Release builds (by default) have separate properties.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值