OpenGL Project Settings in Visual C++

Started by
10 comments, last by taesen00 17 years, 7 months ago
I'm using Microsoft Visual C++ Express for my compiler and IDE. When I downloaded Lesson02 from nehe.gamedev.net, I can compile and everything runs fine. If I modify the source, Lesson2.cpp, it works too. However, if I make a new project, and copy & paste the same source into a new .cpp file, I get the following errors: For reference, here's what I did to make the project: 1. Made Win32 Console Project 2. Empty project 3. Added my source (first through Solution Explorer, then by Copy & Paste -- didn't matter, result was the same). 4. Project Properties - All Configurations, Linker->Input->Additional Dependencies: opengl32.lib glu32.lib glut32.lib 5. Still in Project Properties, Command Line->Additional Properties: /SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup 6. Apply, OK 7. Build and errors! I would imagine the problem is with the project since it's giving me errors while linking, and the code worked in it's native project. Any ideas? [Edited by - taesen00 on February 13, 2007 11:27:20 AM]
Advertisement
You have to turn of Unicode.
Configuration Properties->General->Character Set
By default the Express editions use Unicode character set. So either you will have to link to Unicode libs. Or you will have to change the Character set to Multi-byte.

Try this.
Go to the Project menu -> Properties.
In "Configuration properties" select "Default".
Look for the option "Character set" and change it to "Use Multi-Byte Character Set"
++ My::Game ++
Okay, did all that and it took care of most of the errors. Thanks. There are two more that need to be handled:



Also, out of curiousity, why do I need the multi-byte character set?

[Edited by - taesen00 on February 13, 2007 11:08:44 AM]

Unicode represents each character with 2 Bytes so a 46 Byte field would actually contin 23 characters. Now you are using char[46] which indicates, you are having 46 characters in 46 bytes. That's why you have to use Multi-Byte.

As for your linker error:

Did you excplicitly link msvcrtd.lib? I didn't do it and it works fine.
I'd also suggest setting

Properties->Configuration Properties->General->Use of MFC to "Use Standard Windows Libraries"

Properties->Configuration Properties-> C/C++ -> Code Generation -> Runtime Library to "Multi-threaded DLL"

Also pay attention to the fact that you're using the 8.0 CRT libs, which means you have to provide msvcp80.dll, msvcr80.dll and Microsoft.VC80.CRT.manifest to your application root (these files are realease only) in order to get it running on another machine which doesn't have VC++ Express or Visual Studio 2005 installed on it. Just google those files, you should find plenty of info on that problem.
If I was helpful, feel free to rate me up ;)If I wasn't and you feel to rate me down, please let me know why!
You have to create a 'windows application' not a console app. Difference is that entry point is WinMain and not _tmain.

With Unicode you can display non-western characters so it's better for localized language. You can also call MessageBoxA or put #undef UNICODE before the #includes to turn it off.

[edit]
@Lord_Evil
if you set runtime library to "Multi-threaded" (no DLL) then you don't need the redist files on the other box.
---Current pet project: ProjectM
___tmainCRTStartup is the entry point for an console application. NeHe example must be a windows application using WinMain.
Go to Properties -> Linker -> System.
Change the "SubSystem" to "Not Set" or "Windows".

Sheesh.. I cant understand why MS doesn't use "Not Set" in the first place. There is always a confusion on this.

You dont have to use MBCS, NeHe example use it. You can change it if you want.
About Unicode and MBCS, read up this and google for more if you want more info. Also there is a lot of info in MSDN.
++ My::Game ++
Got it working. Thanks again. I followed all your suggestions, and still had a few errors. From there, I undid Step #5 in my original post and that cleared it up.

They don't make it easy to set up a project do they?

I have to teach this stuff next year. The OpenGL part will be fairly easy, but I think getting high school students to set this up at home will be a headache. Any ideas to make the process easier?
Yes I know mrMagnetic. But when you don't use the DLLs you would run into problems when using objects (especially deleting them) which were created in one of your application DLLs in just another DLL as happened in my project.
This is because multiple copies of the CRT don't work on the same heap. Using the DLLs just means using the same CRT copy and heap in your project.
If I was helpful, feel free to rate me up ;)If I wasn't and you feel to rate me down, please let me know why!
Quote:Original post by taesen00
Got it working. Thanks again. I followed all your suggestions, and still had a few errors. From there, I undid Step #5 in my original post and that cleared it up.

They don't make it easy to set up a project do they?

I have to teach this stuff next year. The OpenGL part will be fairly easy, but I think getting high school students to set this up at home will be a headache. Any ideas to make the process easier?


Yeah, make an empty project template. They can then just add files to it and not worry about settings.

Or maybe write down step-by-step instructions on setup of the project.

In any case, if you wanted to teach high school students about OpenGL, NeHe's tutorials may not be your best option. Read the opening page first few pars of the tutorials. NeHe himself says his tutorials are not meant for beginners. It think the examples from the "Red book" and "OpenGL Superbible" are probably what you are looking for in such a case. They are easy to setup and the code is easier to understand (unlike the above). I don't want to take sides on which book is the best, but the Superbible is what helped me get started on OpenGL. I also found "Beginning OpenGL game programming" an amazing book. Too bad it wasn't around when I started on OpenGL.

NeHe's tutorials are meant for people who alread have their hands dirty with programming and to some extent OpenGL. They are a great reference, and when you have understood OpenGL basics, they are almost invaluable.

[Edited by - _neutrin0_ on September 21, 2006 3:43:48 AM]
++ My::Game ++

This topic is closed to new replies.

Advertisement