3

I recently purchased the OpenGL SuperBible 6th Edition to learn about OpenGL 4, which comes with a load of example code. The authors made a best-effort attempt to make the code buildable on Windows/Linux by providing a Visual Studio 2010 project and a CMake file.

That being said, I would like to use this example code in Eclipse, as that is my preferred IDE. I've got Eclipse CDT, Visual Studio 2012 Professional, MinGW and CMake on my machine. I thought that it would be simple enough to port the project into an Eclipse project, but so far, my attempts have been fruitless. Here's what I've done:


First, I tried to make an Eclipse project from the CMake file. Apparently, in CMake (which I'm not familiar with), you can run a command to generate Eclipse project files. From the description, I got the idea that the CMake file was intended for Linux, So I ran the below command from within the base directory of the project:

cmake -G "Eclipse CDT4 - Unix Makefiles" ./

Which on first inspection, seemed to work. However, when I imported the generated project into Eclipse and subsequently built it, I got a bunch of undefined reference errors; perhaps it's a Linux/Windows problem?


Second, after that failed, I thought I might be able to convert the Visual Studio project to an Eclipse project. I Googled that, and got this tutorial from IBM, which described exporting a makefile from VS and then using that. However, it is horribly outdated (the tutorial is from 2006; apparently VS dropped the "export makefile" option a while ago). I can run the project just fine from VS, so I know that the code is all good.


So now, I'm at a loss. Can anyone offer any insight on porting this project to Eclipse? I suppose I could import the code by hand, but as I'm not really familiar with this code yet (that's why I bought the book!) I'd prefer to use the simplest method to avoid screwing something up.

1 Answer 1

2

All linker issues related to lib/GLFW_r32.lib which is built with Visual Studio.

Since MinGW and Visual Studio libs are incompatible there is no way to use lib/GLFW_r32.lib bundled with code examples.

There are following options:

  • Use Visual Studio as suggested in Readme
  • Use MinGW library which provides OpenGL support instead (in this case you should modify CMakeLists.txt - see below)
    if(WIN32)
        if(MINGW)
            // Add mingw specific lib for OpenGL
            set(COMMON_LIBS mingw-specific libs here...)
        else(MINGW)
            // Visual Studio specific
            set(COMMON_LIBS sb6 optimized GLFW_r32 debug GLFW_d32)
        endif(MINGW)
    elif (UNIX)
        set(COMMON_LIBS sb6 glfw ${GLFW_LIBRARIES} GL rt dl)
    else()
        set(COMMON_LIBS sb6)
    endif()

Not the answer you're looking for? Browse other questions tagged or ask your own question.