Results 1 to 6 of 6

Thread: C++ and glut in MS Visual C++ 6.0

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2004

    C++ and glut in MS Visual C++ 6.0

    I think this is a beginners problem.

    I have a opengl book where the code examples are in C. I don't know C but I do know C++.

    The problem is that when I create a Win32 project in MS Visual C++ 6.0 the compiler seems to want WinMain() instead of just main.

    In the code examples they use: int main(int argc, char **argv).
    Well, if I write that I get an error message: berror LNK2001: unresolved external symbol _WinMain@16

    In the book they use the main parameters as arguments to glutInit() and other glut functions.

    I want to able to use glut instead of windows specific functions.

    What should I write to get the code working with C++?.

    If you don't understand, ask me questions.


    [This message has been edited by Chris.W (edited 02-18-2004).]

  2. #2
    Senior Member Regular Contributor
    Join Date
    Sep 2011

    Re: C++ and glut in MS Visual C++ 6.0

    Be sure to create a Win32 Console Application when using GLUT.

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Gastonia, NC, USA

    Re: C++ and glut in MS Visual C++ 6.0

    There is no problem with compiling a C program under C++.

    Winmain is used when compiling a windows based appication, but since glut is handling your windowing functions you need to compile it as a console program when creating the project.

  4. #4
    Junior Member Newbie
    Join Date
    Feb 2004
    Croatia, Split

    Re: C++ and glut in MS Visual C++ 6.0

    This problem is not a c or C++ problem.
    You choose to create Win 32 app, but book is writed for Win32 console app.
    Type this code there where you wrote main function. When you write this your program will work.

    int APIENTRY _tWinMain(HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPTSTR lpCmdLine,
    int nCmdShow)

  5. #5
    Member Contributor
    Join Date
    Sep 2003
    Jersey, Channel Islands

    Re: C++ and glut in MS Visual C++ 6.0

    I agree, the first thing you should do is create a win32 CONSOLE application, in the MS VC++ wizard for a new project.

    You will then be asked the type of application, where you can choose between empty project, hello world application or an application which supports MFC. The hello world application works for me most (all) of the times I'm using glut.

    Dev studio then will provide 3 files, one of which (nameOfApp.cpp) will have the main function. This will feel like home (C) for you. If you're thinking of writing cross-platform code, I'd suggest to work towards removing the other two files (stdafx.cpp, .h, or something, you'll only need to add the library includes above your main function, and change the setting of precompiled header files (in project setting, c++) to something other than 'using precompiled headers through stdafx.h, which I think is the default).

    You may find various tutorials useful, when it comes to setting and compilation options, as the book itself is focussed (and correctly I should think) to the OpenGL library itself. Note that there are a lot of examples/tutorials on how to use OpenGL (without glut) under Win32 and/or MFC, something I'd suggest you avoid for now, until you have your glut application up and running and you're ready to do some OpenGL.


  6. #6
    Junior Member Newbie
    Join Date
    Jan 2004

    Re: C++ and glut in MS Visual C++ 6.0

    Thank's this was helpful.

Similar Threads

  1. GLUT vs visual C++
    By coda in forum OpenGL: Basic Coding
    Replies: 11
    Last Post: 08-12-2003, 09:39 PM
  2. Visual C++.NET and GLUT
    By wliad in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 06-19-2003, 01:01 PM
  3. Visual C++ and Glut
    By GregH in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 10-22-2000, 01:23 PM
  4. Visual c++ 6.0 and glut?
    By LeprA in forum OpenGL: Basic Coding
    Replies: 11
    Last Post: 10-20-2000, 05:20 PM
  5. GLUT for Windows98 & Visual C++5
    By in forum OpenGL: User Software
    Replies: 3
    Last Post: 10-14-2000, 06:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean