LoginSignup
7
11

More than 5 years have passed since last update.

3分で作る Windows Eclipse C/C++ 開発環境

Last updated at Posted at 2013-12-04

Eclipse CDT環境はWindowsのC/C++ソースコードリーディング・編集環境として優秀だと思うので共有。
ビルドは、別途Visual C++でプロジェクトがあるというのを想定している。
ビルドはできないけど、コードの補完とかコード間の参照とかはできる感じ。

必要なもの

  • Eclipse CDT (32bit)
  • MinGW (32bit)
  • CMake

別に32bitじゃなくてもいいけど、MinGWと合わせること。
バージョンは最近のならなんでもいいはず。

CMake

ソースコードのあるディレクトリに以下の内容をコピーして CMakeLists.txt を作る。

Project(MyProject)

cmake_minimum_required(VERSION 2.8)

 # あれば include_directories ()

file (GLOB SRCS */*.cpp)

add_executable (a.exe ${SRCS}) 

CMake (cmake-gui)を実行して、
source code と build the binaries の箇所をソースコードのあるディレクトリを指定、
Configure で「Eclipse CDT MinGW 」 を選択、Generate。
でEclipse CDT用の設定ファイルができる。

Eclipse CDT

Eclipse を立ちあげて、File → Import → Existing Code as Makefile Project。
Code Locationでさっきのソースコードのあるディレクトリを指定、
これでProject Nameも自動で埋まる。
注意するのは、Toolchain のとこで MinGW GCC を指定すること。
で、FInishで環境構築終わり。

インクルードディレクトリは?

gcc のオプションでいうところの -I の設定は、
プロジェクト でプロパティ→C/C++ Build → GCC C++ Compiler → Includes でディレクトリを追加できる。

7
11
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
7
11