LoginSignup
0
0

More than 3 years have passed since last update.

C++ 環境構築 Cmake (Mac)

Last updated at Posted at 2021-04-09

はじめに

MacでC++のopencv環境を構築する場合,g++でなくてcmakeを利用するようなので,その時行ったことをメモしました.

手順

1. cmakeのインストール

homebrewでcmakeをインストール.

$ brew install cmake

2. テスト環境の作成

以下のように,test.cppとCMakeLists.txtを作成.

.
├── CMakeLists.txt
└── test.cpp

test.cppにテスト用に以下のコードを記述.

#include <iostream>
using namespace std;

int main(){

    string name;
    cin >> name;
    cout << "Hello, " + name << endl;

}

CMakeLists.txtに以下を記述.(一例)

cmake_minimum_required(VERSION 2.8)
add_executable(Main test.cpp)

3. 動作確認

以下のコマンドを実行.

cmake .
make
./Main

実行して,標準入力でnameを入力した後,"Hello, name"が出力されればおけ.
なお,./Mainは,add_executable(Main test.cpp)のMain.

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0