Development of 32-bit and 64-bit program glut configuration method under win7+vs2010

Source: Internet
Author: User

Although the development of OpenGL for a period of time, the blogger is still considered a side dish, the recent toss glut configuration development 64-bit program, almost killing me. Write down my experience, for reference only, and to prevent the same mistakes from being committed later.

First, the GLUT library download.

32-bit version is very easy to find, a bunch of online, but the 64-bit version of the relatively difficult, more people said glut does not support the development of 64-bit, make a small dish once want to give up. Just as I was about to give up, a great God jumped up and said to me, Nani, who said no 64bit ....

Not much to say, directly to the URL: http://download.csdn.net/detail/knownall/6799947 This is glut3.7.6, which contains debug/release,32bit and 64bit.

Of course, you can choose to download the source code of their own compilation: http://download.csdn.net/detail/knownall/6799967 their own compiled should feel more cool, the side dishes is so do drip.

Two, 32-bit program configuration

Development environment: Win7 64bit flagship edition + VS2010

1, first to find the file location: decompression to get glut.h,glut32.lib,glut32.dll three files,

Glut.h to the X:\Program Files (x86) \microsoft Sdks\windows\v7.0a\include\gl folder, which also has opengl.h and glu.h, your folder may not be the same as this, your own system folder search opengl.h location on it;

Glut32.lib to: X:\Program Files (x86) \microsoft Sdks\windows\v7.0a\lib;

Glut32.dll put: x:\Windows\SysWOW64, here must be noted that in the 64bit operating system, 32bit of the DLL must be placed in this folder, otherwise prompted not to find.

2, a new empty Win32 Console application, add Glut.cpp, the following code to copy in, compiled run, a straight line came out. It was also necessary to include opengl.h and Glu.h, which are already contained in glut.h, so they are not required.

#include <GL/glut.h>
void init (void)
{
	glclearcolor (1.0,1.0,1.0,0.0);
	Glmatrixmode (gl_projection);
	Gluortho2d (0.0,200.0,0.0,100.0);
}

void line (void)
{
	glclear (gl_color_buffer_bit);
	glcolor3f (1.0,0.0,0.0);
	Glbegin (gl_lines);
	Glvertex2i (100,0);
	Glvertex2i (0,75);
	Glend ();

	Glflush ();
}

void Main (int argc, char **argv)
{
	glutinit (&ARGC,ARGV);
	Glutinitdisplaymode (glut_single| GLUT_RGB);
	Glutinitwindowposition (100,100);
	Glutinitwindowsize (400,300);
	Glutcreatewindow ("test");

	Init ();
	Glutdisplayfunc (line);
	Glutmainloop ();
}
Third, develop 64-bit program configuration

Development environment: Win7 64-bit flagship version + VS2010

1, the same is the first to find the file location: decompression to get glut.h,glut64.lib,glut64.dll three files,

Glut.h into X:\Program files (x86) \microsoft Sdks\windows\v7.0a\include\gl folder, which is the same as 32-bit;

Glut64.lib to: X:\Program Files (x86) \microsoft sdks\windows\v7.0a\lib\x64, (note ... Here is a x64;

Glut64.dll put: X:\Windows\System32, here must note that in the 64bit operating system, 64bit of the DLL must be placed in this folder, and we usually feel like a little different.

2, like 32-bit, build engineering, copy code, note that the following steps are different.

3, right click the solution Select Configuration Manager, the project configuration for x64, if not, need to create a new one.

4. Add a #include to the front of the <GL\glut.h> sentence: #define GLUT_BUILDING_LIB. You can, of course. Right-click Engineering--> Properties-->c\c++--> preprocessor--> Preprocessor definition add: glut_building_lib, the effect is the same. The reason is that there is a section of code inside the Glut.h

# if!defined (glut_building_lib) &&!defined (Glut_no_lib_pragma)
#  PRAGMA Comment (LIB, "Winmm.lib") /      * Link with Windows multimedia lib */
* To enable automatic SGI OpenGL for Windows Library usage for GLUT,
   Define GLUT_USE_SGI_OPENGL in your compile preprocessor options.  *
*  ifdef glut_use_sgi_opengl
#   pragma comment (lib, "Opengl.lib")/    * link with SGI OPENGL for Windows Lib
/#   pragma comment (lib, "Glu.lib")/       * link with SGI OpenGL Utility lib * *   pragma Comment (lib, "Glut.lib")/      * link with Win32 glut for SGI OpenGL Lib
*  else
#   pragma comment (  LIB, "Opengl32.lib")  /* Link with Microsoft OpenGL lib   /# pragma comment (lib, "Glu32.lib")     * Link With Microsoft OpenGL Utility Lib
/#   pragma comment (lib, "Glut32.lib")    * link with Win32 GLUT Lib */
  #  endif
# endif
That is, the glut library by default is loaded with 32-bit libraries, so adding a predefined can no longer load.

5, the 4th step to the default load Lib file are removed, how to do it, you need to right-click on the project--> Properties--> linker--> Input--> Additional dependencies added: Opengl32.lib,glu32.lib,glut64.lib; Here are some questions to ask why OpenGL and Glu are 32-bit libraries. OpenGL and Glu are all things in the system, and there's nothing else to be found, and this 32 is available, waiting for the big God to tell us why.

6, finished, compiled, generated, executed, done. or the original formula, or the original taste haha ~


If you change a computer programming how to do, that computer does not match glut how to do. There is another way for people familiar with VS programming, which is a favorite way to put Glut.h,glut.lib into a folder in the engineering directory,

For example: Side dishes in the same directory glut.vcxproj new folder corner OpenGL, and then glut.h,glut32.lib,glut64.lib all put in, and then a small change glut.cpp:

#pragma comment (lib, "Opengl32.lib")
#pragma comment (lib, "Glu32.lib")
#pragma comment (lib, "opengl\\ Glut64.lib ")

So the question of Lib is done, and then the Glut32.dll,glut64.dll to the directory where the generated files, no matter where you take the program, no need to move the file, once and for all.


Resources:

Http://www.cnkinect.com/thread-15138-1-1.html

http://hi.baidu.com/cj326/item/5ea83e1c16b1b36970d5e848

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.