H-T-6221 / cplus_sample

C++ sample code
0 stars 0 forks source link

20241003_Error_cmake_command_not_found #7

Open H-T-6221 opened 4 days ago

H-T-6221 commented 4 days ago

cmakeでビルドする際にエラー発生 cmakeをインストールし、JenkinsのPluginを有効にした後で実行したがcmake: command not foundとなった。 コマンドプロンプトでcmakeを実行してみたところ、エラーが発生していた。

C:\work\開発\repository\cplus_sample\02_docker\03_http_com\build>cmake ..
-- Building for: NMake Makefiles
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

CMake Error at CMakeLists.txt:4 (project):
  Running

   'nmake' '-?'

  failed with:

   no such file or directory

CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!

CMakeLists.txt

cmake_minimum_required(VERSION 3.2 FATAL_ERROR)

# set the project name and version
project(SampleSrc CXX)

add_subdirectory(client)
add_subdirectory(server)
H-T-6221 commented 4 days ago

make, g++のインストールをしたが、エラーが解消されていない。

make https://qiita.com/ryuso/items/cf0c1d83544103cacf05

g++ https://sourceforge.net/projects/mingw/

↓のエラーはCMakeLists.txtにパスを設定することで解消された。

CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
set( CMAKE_CXX_COMPILER "/pathto/g++" )
set( CMAKE_C_COMPILER "/pathto/gcc" )
H-T-6221 commented 3 days ago

根本さんからコメントをいただいた。

windowsのcmakeで`no such file or directory`が出ているのですね。
`no such file or directory`は以下の原因が考えれるようですね。
 存在しないファイル、ディレクトリ名などを指定する、タイポするなどパス指定を間違った場合等に発生します。
 また、アプリケーションによっては改行コードがwindowsのCR+LFの場合に発生する場合もあります。
既に確認されていると思いますが、パスの指定や、改行コードなど見直してみてください。
H-T-6221 commented 3 days ago

コメントいただいた内容を試してみた。 パスの指定 buildフォルダでcmake ..を実施した。 ディレクトリ構成

C:.
├─build
├─CMakeLists.txt
├─client
└─server

また、改行コードはLF→CR+LFに変更したが、同様のエラーが発生した。 ※LFでも同様のエラー