第一次使用 OpenGL:我应该如何配置 Visual Studio Express 2015 来构建和 运行 OpenGL 项目?
First time OpenGL: How should I configure Visual Studio Express 2015 to build and run an OpenGL project?
我是 OpenGL 的新手,正在学习一些初学者教程
here
我非常仔细地按照第一个教程中的步骤进行操作并完全按照描述进行,但是我在 CMake 中遇到错误:no_cmake_c_compiler found and no_cmake_cxx_compiler 找到。我用谷歌搜索了这些错误,但直到现在我都找不到解决这个问题的非常明确的步骤。
所以我决定自己下载教程的源代码,并尝试在没有 CMake 的情况下将它们构建为 VS Express 2015 中的新项目。但是,我似乎迷失在项目配置以及 header 和源文件。有人可以告诉我应该如何进行吗?
您可以简单地告诉 cmake 编译器在哪里。当您第一次单击配置时,您会看到一个对话框,您可以在其中 select 生成器。您首先为 Visual Studio 版本选择生成器。其次你 select "Specify native compilers" 然后点击下一步。在下面的对话框中,您需要浏览 C 和 C++ 编译器。 Select "C:\Program Files (x86)\Microsoft Visual Studio \VC\bin\cl.exe" 两者。 (如果您的机器上隐藏了文件结尾,请小心。还有一个名为 cl.exe.config 的文件。)
点击完成,它应该可以工作了。
更新: 尝试使用 CMake 3.4.2 后,输出为:
对我来说现在看起来好多了,但是当我进入包含二进制文件的文件夹时,那里没有 Tutorials.sln 文件。
The C compiler identification is MSVC 19.0.23506.0
The CXX compiler identification is MSVC 19.0.23506.0
Check for working C compiler using: Visual Studio 14 2015 Win64
Check for working C compiler using: Visual Studio 14 2015 Win64 -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working CXX compiler using: Visual Studio 14 2015 Win64
Check for working CXX compiler using: Visual Studio 14 2015 Win64 -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
Found OpenGL: opengl32
Looking for pthread.h
Looking for pthread.h - not found
Found Threads: TRUE
Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
Using Win32 for window creation
Using WGL for context creation
Looking for sys/types.h
Looking for sys/types.h - found
Looking for stdint.h
Looking for stdint.h - found
Looking for stddef.h
Looking for stddef.h - found
Check size of off64_t
Check size of off64_t - failed
Looking for fseeko
Looking for fseeko - not found
Looking for unistd.h
Looking for unistd.h - not found
Configuring done
--------------------------------------------
--------------------------------------------
*Older:* This is what I get from CMake as Output:
> The C compiler identification is unknown The CXX compiler
> identification is unknown Check for working C compiler using: Visual
> Studio 14 2015 Win64 Check for working C compiler using: Visual Studio
> 14 2015 Win64 -- broken CMake Error at C:/Program Files
> (x86)/CMake/share/cmake-3.4/Modules/CMakeTestCCompiler.cmake:61
> (message): The C compiler "C:/Program Files (x86)/Microsoft Visual
> Studio
> 14.0/VC/bin/cl.exe" is not able to compile a simple test program.
>
> It fails with the following output:
>
> Change Dir: C:/Users/Antonia/CMakeBuild/CMakeFiles/CMakeTmp
>
>
>
> Run Build Command:"C:/Program Files
> (x86)/MSBuild/14.0/bin/MSBuild.exe" "cmTC_f5d7b.vcxproj"
> "/p:Configuration=Debug" "/p:VisualStudioVersion=14.0"
>
> Microsoft (R) Build Engine version 14.0.24723.2
>
>
> Copyright (C) Microsoft Corporation. All rights reserved.
>
>
>
>
>
> Build started 16.1.2016 �. 14:41:13.
>
>
> The target "BeforeGenerateProjectPriFile" listed in a BeforeTargets
> attribute at "C:\Program Files
> (x86)\MSBuild\Microsoft\NuGet\Microsoft.NuGet.targets (186,61)" does
> not exist in the project, and will be ignored.
>
>
> Project
> "C:\Users\Antonia\CMakeBuild\CMakeFiles\CMakeTmp\cmTC_f5d7b.vcxproj"
> on node 1 (default targets).
>
>
> PrepareForBuild:
>
>
> Creating directory "cmTC_f5d7b.dir\Debug\".
>
> Creating directory "C:\Users\Antonia\CMakeBuild\CMakeFiles\CMakeTmp\Debug\".
>
> Creating directory "cmTC_f5d7b.dir\Debug\cmTC_f5d7b.tlog\".
>
>
> InitializeBuildStatus:
>
>
> Creating "cmTC_f5d7b.dir\Debug\cmTC_f5d7b.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
>
>
> ClCompile:
>
>
> C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64\CL.exe /c /W1 /WX- /O2 /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /MD /GS /fp:precise /Zc:wchar_t
> /Zc:forScope /Zc:inline /Fo"cmTC_f5d7b.dir\Debug\"
> /Fd"cmTC_f5d7b.dir\Debug\vc140.pdb" /Gd /TC /errorReport:queue
> C:\Users\Antonia\CMakeBuild\CMakeFiles\CMakeTmp\testCCompiler.c
>
> Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23506 for x64
>
> Copyright (C) Microsoft Corporation. All rights reserved.
>
>
>
> cl /c /W1 /WX- /O2 /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline
> /Fo"cmTC_f5d7b.dir\Debug\" /Fd"cmTC_f5d7b.dir\Debug\vc140.pdb" /Gd
> /TC /errorReport:queue
> C:\Users\Antonia\CMakeBuild\CMakeFiles\CMakeTmp\testCCompiler.c
>
>
>
> testCCompiler.c
>
>
> Link:
>
>
> C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64\link.exe /ERRORREPORT:QUEUE /OUT:"C:\Users\Antonia\CMakeBuild\CMakeFiles\CMakeTmp\Debug\cmTC_f5d7b.exe"
> /INCREMENTAL /NOLOGO /MANIFEST /MANIFESTUAC:"level='asInvoker'
> uiAccess='false'" /manifest:embed
> /PDB:"C:/Users/Antonia/CMakeBuild/CMakeFiles/CMakeTmp/Debug/cmTC_f5d7b.pdb"
> /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT
> /IMPLIB:"C:/Users/Antonia/CMakeBuild/CMakeFiles/CMakeTmp/Debug/cmTC_f5d7b.lib"
> /MACHINE:X64 cmTC_f5d7b.dir\Debug\testCCompiler.obj
>
>
> LINK : fatal error LNK1104: cannot open file 'kernel32.lib'
> [C:\Users\Antonia\CMakeBuild\CMakeFiles\CMakeTmp\cmTC_f5d7b.vcxproj]
>
>
> Done Building Project
> "C:\Users\Antonia\CMakeBuild\CMakeFiles\CMakeTmp\cmTC_f5d7b.vcxproj"
> (default targets) -- FAILED.
>
>
>
>
>
> Build FAILED.
>
>
>
>
>
> "C:\Users\Antonia\CMakeBuild\CMakeFiles\CMakeTmp\cmTC_f5d7b.vcxproj"
> (default target) (1) ->
>
>
> (Link target) ->
>
>
> LINK : fatal error LNK1104: cannot open file 'kernel32.lib' [C:\Users\Antonia\CMakeBuild\CMakeFiles\CMakeTmp\cmTC_f5d7b.vcxproj]
>
>
>
>
>
> 0 Warning(s)
>
> 1 Error(s)
>
>
>
>
>
> Time Elapsed 00:00:00.81
>
>
>
>
>
>
> CMake will not be able to correctly generate this project. Call
> Stack (most recent call first): CMakeLists.txt:3 (project)
>
>
> Configuring incomplete, errors occurred! See also
> "C:/Users/Antonia/CMakeBuild/CMakeFiles/CMakeOutput.log". See also
> "C:/Users/Antonia/CMakeBuild/CMakeFiles/CMakeError.log".
我在尝试使用新版本 (3.4.2) 时发现了错误 - 我在配置后错过了单击生成...现在我在 VS 中有了项目和源文件。非常感谢您建议我尝试使用 CMake 3.4.2 :)
我是 OpenGL 的新手,正在学习一些初学者教程 here
我非常仔细地按照第一个教程中的步骤进行操作并完全按照描述进行,但是我在 CMake 中遇到错误:no_cmake_c_compiler found and no_cmake_cxx_compiler 找到。我用谷歌搜索了这些错误,但直到现在我都找不到解决这个问题的非常明确的步骤。
所以我决定自己下载教程的源代码,并尝试在没有 CMake 的情况下将它们构建为 VS Express 2015 中的新项目。但是,我似乎迷失在项目配置以及 header 和源文件。有人可以告诉我应该如何进行吗?
您可以简单地告诉 cmake 编译器在哪里。当您第一次单击配置时,您会看到一个对话框,您可以在其中 select 生成器。您首先为 Visual Studio 版本选择生成器。其次你 select "Specify native compilers" 然后点击下一步。在下面的对话框中,您需要浏览 C 和 C++ 编译器。 Select "C:\Program Files (x86)\Microsoft Visual Studio \VC\bin\cl.exe" 两者。 (如果您的机器上隐藏了文件结尾,请小心。还有一个名为 cl.exe.config 的文件。)
点击完成,它应该可以工作了。
更新: 尝试使用 CMake 3.4.2 后,输出为:
对我来说现在看起来好多了,但是当我进入包含二进制文件的文件夹时,那里没有 Tutorials.sln 文件。
The C compiler identification is MSVC 19.0.23506.0
The CXX compiler identification is MSVC 19.0.23506.0
Check for working C compiler using: Visual Studio 14 2015 Win64
Check for working C compiler using: Visual Studio 14 2015 Win64 -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working CXX compiler using: Visual Studio 14 2015 Win64
Check for working CXX compiler using: Visual Studio 14 2015 Win64 -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
Found OpenGL: opengl32
Looking for pthread.h
Looking for pthread.h - not found
Found Threads: TRUE
Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
Using Win32 for window creation
Using WGL for context creation
Looking for sys/types.h
Looking for sys/types.h - found
Looking for stdint.h
Looking for stdint.h - found
Looking for stddef.h
Looking for stddef.h - found
Check size of off64_t
Check size of off64_t - failed
Looking for fseeko
Looking for fseeko - not found
Looking for unistd.h
Looking for unistd.h - not found
Configuring done
--------------------------------------------
--------------------------------------------
*Older:* This is what I get from CMake as Output:
> The C compiler identification is unknown The CXX compiler
> identification is unknown Check for working C compiler using: Visual
> Studio 14 2015 Win64 Check for working C compiler using: Visual Studio
> 14 2015 Win64 -- broken CMake Error at C:/Program Files
> (x86)/CMake/share/cmake-3.4/Modules/CMakeTestCCompiler.cmake:61
> (message): The C compiler "C:/Program Files (x86)/Microsoft Visual
> Studio
> 14.0/VC/bin/cl.exe" is not able to compile a simple test program.
>
> It fails with the following output:
>
> Change Dir: C:/Users/Antonia/CMakeBuild/CMakeFiles/CMakeTmp
>
>
>
> Run Build Command:"C:/Program Files
> (x86)/MSBuild/14.0/bin/MSBuild.exe" "cmTC_f5d7b.vcxproj"
> "/p:Configuration=Debug" "/p:VisualStudioVersion=14.0"
>
> Microsoft (R) Build Engine version 14.0.24723.2
>
>
> Copyright (C) Microsoft Corporation. All rights reserved.
>
>
>
>
>
> Build started 16.1.2016 �. 14:41:13.
>
>
> The target "BeforeGenerateProjectPriFile" listed in a BeforeTargets
> attribute at "C:\Program Files
> (x86)\MSBuild\Microsoft\NuGet\Microsoft.NuGet.targets (186,61)" does
> not exist in the project, and will be ignored.
>
>
> Project
> "C:\Users\Antonia\CMakeBuild\CMakeFiles\CMakeTmp\cmTC_f5d7b.vcxproj"
> on node 1 (default targets).
>
>
> PrepareForBuild:
>
>
> Creating directory "cmTC_f5d7b.dir\Debug\".
>
> Creating directory "C:\Users\Antonia\CMakeBuild\CMakeFiles\CMakeTmp\Debug\".
>
> Creating directory "cmTC_f5d7b.dir\Debug\cmTC_f5d7b.tlog\".
>
>
> InitializeBuildStatus:
>
>
> Creating "cmTC_f5d7b.dir\Debug\cmTC_f5d7b.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
>
>
> ClCompile:
>
>
> C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64\CL.exe /c /W1 /WX- /O2 /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /MD /GS /fp:precise /Zc:wchar_t
> /Zc:forScope /Zc:inline /Fo"cmTC_f5d7b.dir\Debug\"
> /Fd"cmTC_f5d7b.dir\Debug\vc140.pdb" /Gd /TC /errorReport:queue
> C:\Users\Antonia\CMakeBuild\CMakeFiles\CMakeTmp\testCCompiler.c
>
> Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23506 for x64
>
> Copyright (C) Microsoft Corporation. All rights reserved.
>
>
>
> cl /c /W1 /WX- /O2 /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline
> /Fo"cmTC_f5d7b.dir\Debug\" /Fd"cmTC_f5d7b.dir\Debug\vc140.pdb" /Gd
> /TC /errorReport:queue
> C:\Users\Antonia\CMakeBuild\CMakeFiles\CMakeTmp\testCCompiler.c
>
>
>
> testCCompiler.c
>
>
> Link:
>
>
> C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64\link.exe /ERRORREPORT:QUEUE /OUT:"C:\Users\Antonia\CMakeBuild\CMakeFiles\CMakeTmp\Debug\cmTC_f5d7b.exe"
> /INCREMENTAL /NOLOGO /MANIFEST /MANIFESTUAC:"level='asInvoker'
> uiAccess='false'" /manifest:embed
> /PDB:"C:/Users/Antonia/CMakeBuild/CMakeFiles/CMakeTmp/Debug/cmTC_f5d7b.pdb"
> /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT
> /IMPLIB:"C:/Users/Antonia/CMakeBuild/CMakeFiles/CMakeTmp/Debug/cmTC_f5d7b.lib"
> /MACHINE:X64 cmTC_f5d7b.dir\Debug\testCCompiler.obj
>
>
> LINK : fatal error LNK1104: cannot open file 'kernel32.lib'
> [C:\Users\Antonia\CMakeBuild\CMakeFiles\CMakeTmp\cmTC_f5d7b.vcxproj]
>
>
> Done Building Project
> "C:\Users\Antonia\CMakeBuild\CMakeFiles\CMakeTmp\cmTC_f5d7b.vcxproj"
> (default targets) -- FAILED.
>
>
>
>
>
> Build FAILED.
>
>
>
>
>
> "C:\Users\Antonia\CMakeBuild\CMakeFiles\CMakeTmp\cmTC_f5d7b.vcxproj"
> (default target) (1) ->
>
>
> (Link target) ->
>
>
> LINK : fatal error LNK1104: cannot open file 'kernel32.lib' [C:\Users\Antonia\CMakeBuild\CMakeFiles\CMakeTmp\cmTC_f5d7b.vcxproj]
>
>
>
>
>
> 0 Warning(s)
>
> 1 Error(s)
>
>
>
>
>
> Time Elapsed 00:00:00.81
>
>
>
>
>
>
> CMake will not be able to correctly generate this project. Call
> Stack (most recent call first): CMakeLists.txt:3 (project)
>
>
> Configuring incomplete, errors occurred! See also
> "C:/Users/Antonia/CMakeBuild/CMakeFiles/CMakeOutput.log". See also
> "C:/Users/Antonia/CMakeBuild/CMakeFiles/CMakeError.log".
我在尝试使用新版本 (3.4.2) 时发现了错误 - 我在配置后错过了单击生成...现在我在 VS 中有了项目和源文件。非常感谢您建议我尝试使用 CMake 3.4.2 :)