質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
CMake

CMakeはクロスプラットフォームで作動するオープンソースのビルドシステムです。コマンドライン又は組み込まれた開発環境で使うことができる元のmakefileとプロジェクトファイルを生成します。

Visual Studio

Microsoft Visual StudioはMicrosoftによる統合開発環境(IDE)です。多種多様なプログラミング言語に対応しています。

OpenCV

OpenCV(オープンソースコンピュータービジョン)は、1999年にインテルが開発・公開したオープンソースのコンピュータビジョン向けのクロスプラットフォームライブラリです。

Q&A

解決済

1回答

3777閲覧

CMakeを使用してVSでopencvをコンパイルするときに発生したエラーの対処

pomupomu_purin

総合スコア14

CMake

CMakeはクロスプラットフォームで作動するオープンソースのビルドシステムです。コマンドライン又は組み込まれた開発環境で使うことができる元のmakefileとプロジェクトファイルを生成します。

Visual Studio

Microsoft Visual StudioはMicrosoftによる統合開発環境(IDE)です。多種多様なプログラミング言語に対応しています。

OpenCV

OpenCV(オープンソースコンピュータービジョン)は、1999年にインテルが開発・公開したオープンソースのコンピュータビジョン向けのクロスプラットフォームライブラリです。

0グッド

0クリップ

投稿2021/06/03 09:21

CMake を使用して、Visual Studio 2019 でopenCVを動かす環境を用意したいのですが、cmake-guiにて、以下のエラーが出てしまいました。私のできる範囲での対処では解決できませんでした。どなたか解決策を提示していただけたら幸いです。

追加情報が必要であれば、お申し付けください。どうかよろしくお願いします。

・環境

Windows 10
Visual Studio Enterprise 2019(Version 16.10.0)
Cmake 3.20.3
OpenCV 4.5.2

発生したエラー

Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19042. CMake Error at CMakeLists.txt:3 (project): Failed to run MSBuild command: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/MSBuild/Current/Bin/MSBuild.exe to get the value of VCTargetsPath: .NET Framework 向け Microsoft (R) Build Engine バージョン 16.10.0+4242f381a Copyright (C) Microsoft Corporation.All rights reserved. 2021/06/03 18:04:58 にビルドを開始しました。 ノード 1 上のプロジェクト "C:\pclStudy\opencv\build\CMakeFiles\3.20.3\VCTargetsPath.vcxproj" (既定のターゲット)。 InitializeBuildStatus: "x64\Debug\VCTargetsPath.tlog\unsuccessfulbuild" のタッチ タスクを実行しています。 C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB6003: 指定されたタスク実行可能ファイル "cmd.exe" を実行できませんでした。System.IO.IOException: 一時ファイルを作成できませんでした。一時ファイル フォルダーがいっぱいであるか、またはそのパスが正しくありません。パス 'C:\Users?R??]??\AppData\Local\Temp\tmpc9a53db88e7e4bf1bef6b5859a12bd35.exec.cmd' へのアクセスが拒否されました。 ---> System.UnauthorizedAccessException: パス 'C:\Users?R??]??\AppData\Local\Temp\tmpc9a53db88e7e4bf1bef6b5859a12bd35.exec.cmd' へのアクセスが拒否されました。 [C:\pclStudy\opencv\build\CMakeFiles\3.20.3\VCTargetsPath.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB6003: 場所 System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) [C:\pclStudy\opencv\build\CMakeFiles\3.20.3\VCTargetsPath.vcxproj] ------- 省略 ------- プロジェクト "C:\pclStudy\opencv\build\CMakeFiles\3.20.3\VCTargetsPath.vcxproj" (既定のターゲット) のビルドが終了しました -- 失敗。 ビルドに失敗しました。 "C:\pclStudy\opencv\build\CMakeFiles\3.20.3\VCTargetsPath.vcxproj" (既定のターゲット) (1) -> (PostBuildEvent ターゲット) -> C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB6003: 指定されたタスク実行可能ファイル "cmd.exe" を実行できませんでした。System.IO.IOException: 一時ファイルを作成できませんでした。一時ファイル フォルダーがいっぱいであるか、またはそのパスが正しくありません。パス 'C:\Users?R??]??\AppData\Local\Temp\tmpc9a53db88e7e4bf1bef6b5859a12bd35.exec.cmd' へのアクセスが拒否されました。 ---> System.UnauthorizedAccessException: パス 'C:\Users?R??]??\AppData\Local\Temp\tmpc9a53db88e7e4bf1bef6b5859a12bd35.exec.cmd' へのアクセスが拒否されました。 [C:\pclStudy\opencv\build\CMakeFiles\3.20.3\VCTargetsPath.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB6003: 場所 System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) [C:\pclStudy\opencv\build\CMakeFiles\3.20.3\VCTargetsPath.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB6003: 場所 System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) [C:\pclStudy\opencv\build\CMakeFiles\3.20.3\VCTargetsPath.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB6003: 場所 System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) [C:\pclStudy\opencv\build\CMakeFiles\3.20.3\VCTargetsPath.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB6003: 場所 System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost) [C:\pclStudy\opencv\build\CMakeFiles\3.20.3\VCTargetsPath.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB6003: 場所 System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost) [C:\pclStudy\opencv\build\CMakeFiles\3.20.3\VCTargetsPath.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB6003: 場所 System.IO.File.InternalWriteAllText(String path, String contents, Encoding encoding, Boolean checkHost) [C:\pclStudy\opencv\build\CMakeFiles\3.20.3\VCTargetsPath.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB6003: 場所 System.IO.File.WriteAllText(String path, String contents) [C:\pclStudy\opencv\build\CMakeFiles\3.20.3\VCTargetsPath.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB6003: 場所 Microsoft.Build.Shared.FileUtilities.GetTemporaryFile(String directory, String extension, Boolean createFile) [C:\pclStudy\opencv\build\CMakeFiles\3.20.3\VCTargetsPath.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB6003: --- 内部例外スタック トレースの終わり --- [C:\pclStudy\opencv\build\CMakeFiles\3.20.3\VCTargetsPath.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB6003: 場所 Microsoft.Build.Shared.FileUtilities.GetTemporaryFile(String directory, String extension, Boolean createFile) [C:\pclStudy\opencv\build\CMakeFiles\3.20.3\VCTargetsPath.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB6003: 場所 Microsoft.Build.Tasks.Exec.CreateTemporaryBatchFile() [C:\pclStudy\opencv\build\CMakeFiles\3.20.3\VCTargetsPath.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB6003: 場所 Microsoft.Build.Tasks.Exec.AddCommandLineCommands(CommandLineBuilderExtension commandLine) [C:\pclStudy\opencv\build\CMakeFiles\3.20.3\VCTargetsPath.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB6003: 場所 Microsoft.Build.Tasks.ToolTaskExtension.GenerateCommandLineCommands() [C:\pclStudy\opencv\build\CMakeFiles\3.20.3\VCTargetsPath.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(155,5): error MSB6003: 場所 Microsoft.Build.Utilities.ToolTask.Execute() [C:\pclStudy\opencv\build\CMakeFiles\3.20.3\VCTargetsPath.vcxproj] 0 個の警告 1 エラー 経過時間 00:00:00.58 Exit code: 1 Configuring incomplete, errors occurred! See also "C:/pclStudy/opencv/build/CMakeFiles/CMakeOutput.log".

試したこと

  1. VSの再インストール
  2. VS2017を指定してみる
  3. MSBuild.exe、Microsoft.CppCommon.targets が指定のパスに存在しているか確認
  4. CMakeのキャッシュを削除

確認したこと

  1. C++のコンパイラのインストール(→OK)
  2. CMake GUIで指定するコンパイラが合っているか(→OK)

補足

C:/pclStudy/pcl/build/CMakeFiles/CMakeOutput.log
の中身を確認したところ下記の記載のみでした。

The system is: Windows - 10.0.19042 - AMD64

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

jbpb0

2021/06/03 09:58

ユーザー名に日本語入ってませんか?
pomupomu_purin

2021/06/03 10:48

ユーザ名を日本語にしていました。 ローマ字に変更したところ解決致しました。 ご助言ありがとうございました!
pomupomu_purin

2021/06/03 10:49

良ければ、回答の方に投稿頂けないでしょうか。 自己解決ではなく、jbpb0様にご教示頂いたので。。
guest

回答1

0

ベストアンサー

'C:\Users?R??]??\AppData\Local\Temp\tmpc9a53db88e7e4bf1bef6b5859a12bd35.exec.cmd' へのアクセスが拒否されました。

ユーザー名が文字化けしてるようなので、それが原因の可能性があります

ユーザー名に日本語使ってたら、ユーザー名に日本語使ってないユーザーでやってみてください

投稿2021/06/03 21:58

編集2021/06/03 22:08
jbpb0

総合スコア7651

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

pomupomu_purin

2021/06/04 00:06

この度は、ご教示頂きありがとうございました。 大変参考になりました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問