使用cmake在Windows上的c ++ [英] Using cmake on windows for c++

查看:259
本文介绍了使用cmake在Windows上的c ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

连续5天,我一直在试图设置我的电脑用c ++环境编程的库,如sdl,glm,opengl。它对我们来说重要的是能够在演示文稿的unix机器上运行它,所以im运行与cmake。
i终于得到它的工作与cmake-gui,我甚至不必再尝试任何IDE。



我指定了我的文件夹项目和在哪里建立二进制文件,我得到一个文件夹CMakeFiles以及一个txtCMakeCache,一个CMAKE文件cmake_install.cmake和一个文件Makefile。也在我的文件夹CMakeFiles有很多其他文件夹,如CMakeTmp,CompilerIdC,CompilerIdCXX等,在这两个文件夹编译器*每个都有一个.exe不工作!所以我想要的可执行文件在哪里?



我打开cmd并导航到我的文件夹,并试图写make,因为我们应该根据intruction。唉,它没有工作非常好。希望你能分享你的智慧,帮助像我这样的新手。



那么,编译包含额外库的项目需要什么?到目前为止,我有一个编译器,Mingw32,最新的CMake和使用cmake-gui提取二进制文件,但获得makefile。

编辑:
hrrm。是只有我得到这些类型的问题吗?我可以补充说,我看看彻底大约10教程和90%的步骤是类似的(如果编译VS VS我第一次尝试):




  • 下载最新的SDL

  • 在例如C:\SDL上创建一个文件夹,包含两个文件夹include和lib

  • 复制库从下载的SDL

  • 新建VS项目,打开VC ++目录并在例如C:\SDL上添加lib / incl文件夹

  • 添加到链接器SDL.lib和SDLmain.lib(我确保它们已链接,这里没有问题)

  • 将系统更改为WINDOWS(如果不需要两个窗口,则可选)
  • $ b $
  • 将SDL.dll文件(我从最新的SDL文件)放到我的C:\windows \system32(64SysWoW)
    以及我的项目文件中。



所以我真正想要的是让CMake工作,因为它我需要从sdl添加任何额外的库到我的编译器mingw32和/或cmake?

解决方案

你几乎在Visual Studio。选择Visual Studio作为目标。在Visual Studio中打开生成的项目,构建它。 (就像你所做的一样)。然后,而不是试图运行BUILD_ALL,运行一个真正的项目,创建一个可执行文件,它也应该在该列表中。



如果您仍然收到错误,请详细发布,包括您在错误之前所做的操作。注意:仔细配置的跨平台CMake项目(也称为CMakeLists.txt)不应该要求使用VC ++目录。它应该自动工作,特别是与众所周知的库,如SDL。


for around 5 consecutive days i have been trying to set up my computer with the c++ environment for programming with libraries such as sdl,glm,opengl. its important for us to be able to run it on unix machines on presentations so im running with cmake. i finally got it to work with the cmake-gui, i wont even bother trying anymore with any IDE.

i specified my folder project and where to build the binaries, i got a folder "CMakeFiles" along with a txt "CMakeCache", a CMAKE file "cmake_install.cmake" and a file "Makefile". also in my folder "CMakeFiles" there are lots of other folders such as "CMakeTmp", "CompilerIdC", "CompilerIdCXX etc" and in both folders "Compiler*" has each an .exe which doesnt work! so where is my wanted executable?

i opened cmd and navigated to my folder and tried to write "make" as we are supposed to do according to the intruction. alas, it didnt work very well. hoping you could share your wisdom and help a newbie like me!

so what exactly is needed for compiling projects containing additional libraries? so far i have a compiler, Mingw32, the latest CMake and using the cmake-gui for extracting the binaries but gets makefiles.

EDIT: hrrm. is it only me who gets these kind of problems? i can add that i have look thorough about 10 tutorials and 90% of the steps are similar (if compiling with VS which i tried at first):

  • Download latest SDL
  • Make a folder on e.g C:\SDL with two folders, include and lib
  • Copy the libs and includes from the downloaded SDL
  • Make new VS project, open VC++ directories and add lib/incl folder on e.g C:\SDL
  • Add to linker SDL.lib and SDLmain.lib (i made sure they got linked, no problem here)
  • Change system to WINDOWS (optional if you dont want two windows)
  • Added include to "additional libraries"
  • Put the SDL.dll file (which i got from the latest SDL) in my C:\windows\system32(64SysWoW) and also in my project file.

so what i am actually looking for is gettning the CMake to work, since it generates and builds sources successfully (with the gui) and i feel im closing in. do i need to add any additional libraries from sdl to my compiler mingw32 and/or cmake?

解决方案

You were almost there with Visual Studio. Select Visual Studio as target. Open the generated project in Visual Studio, build it. (just like you alread did). Then, instead of trying to run BUILD_ALL, run a real project that creates an executable, it should also be in that list. Just right click it and 'play' it.

If you still get errors, post them in detail including what you did before the error. Note: a carefully configured cross platform CMake project (aka the CMakeLists.txt) should not require any fiddling with VC++ directories. It should work automagically, especially with well known libs such as SDL.

这篇关于使用cmake在Windows上的c ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆