简体   繁体   English

将CMake / Visual Studio项目移植到Eclipse

[英]Porting CMake/Visual Studio projects to Eclipse

I recently purchased the OpenGL SuperBible 6th Edition to learn about OpenGL 4, which comes with a load of example code . 我最近购买了OpenGL SuperBible第6版,以了解OpenGL 4,它附带了大量示例代码 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. 作者通过提供Visual Studio 2010项目和CMake文件,尽最大努力使代码可在Windows / Linux上构建。

That being said, I would like to use this example code in Eclipse, as that is my preferred IDE. 话虽这么说,我想在Eclipse中使用这个示例代码,因为这是我首选的IDE。 I've got Eclipse CDT, Visual Studio 2012 Professional, MinGW and CMake on my machine. 我的机器上有Eclipse CDT,Visual Studio 2012 Professional,MinGW和CMake I thought that it would be simple enough to port the project into an Eclipse project, but so far, my attempts have been fruitless. 我认为将项目移植到Eclipse项目中会很简单,但到目前为止,我的尝试都没有结果。 Here's what I've done: 这就是我所做的:


First , I tried to make an Eclipse project from the CMake file. 首先 ,我尝试从CMake文件创建一个Eclipse项目。 Apparently, in CMake (which I'm not familiar with), you can run a command to generate Eclipse project files. 显然,在CMake(我不熟悉)中,您可以运行命令来生成Eclipse项目文件。 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文件是针对Linux的,所以我从项目的基本目录中运行以下命令:

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 ; 但是,当我将生成的项目导入Eclipse并随后构建它时,我得到了一堆未定义的引用错误 ; perhaps it's a Linux/Windows problem? 也许这是一个Linux / Windows问题?


Second , after that failed, I thought I might be able to convert the Visual Studio project to an Eclipse project. 其次 ,在失败之后,我想我可以将Visual Studio项目转换为Eclipse项目。 I Googled that, and got this tutorial from IBM , which described exporting a makefile from VS and then using that. 我用Google搜索,并从IBM获得了这个教程,该教程描述了从VS导出makefile然后使用它。 However, it is horribly outdated (the tutorial is from 2006; apparently VS dropped the "export makefile" option a while ago). 然而,它已经过时了(该教程是从2006年开始的;显然VS在不久前删除了“export makefile”选项)。 I can run the project just fine from VS, so I know that the code is all good. 我可以从VS运行该项目,所以我知道代码都很好。


So now, I'm at a loss. 所以现在,我很茫然。 Can anyone offer any insight on porting this project to Eclipse? 任何人都可以提供有关将此项目移植到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. 我想我可以手工导入代码,但是因为我还不熟悉这个代码(这就是我买这本书的原因!)我宁愿用最简单的方法来避免搞砸。

All linker issues related to lib/GLFW_r32.lib which is built with Visual Studio . 与使用Visual Studio构建的lib / GLFW_r32.lib相关的所有链接器问题。

Since MinGW and Visual Studio libs are incompatible there is no way to use lib/GLFW_r32.lib bundled with code examples. 由于MinGW和Visual Studio库不兼容 ,因此无法使用与代码示例捆绑在一起的lib / GLFW_r32.lib。

There are following options: 有以下选项:

  • Use Visual Studio as suggested in Readme 按照自述文件中的建议使用Visual Studio
  • Use MinGW library which provides OpenGL support instead (in this case you should modify CMakeLists.txt - see below) 使用提供OpenGL支持的MinGW库(在这种情况下,您应该修改CMakeLists.txt - 见下文)
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()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM