LoginSignup
4
1

More than 3 years have passed since last update.

AtCoderLibraryをCLionで使う

Last updated at Posted at 2020-09-13

はじめに

ac-libraryが出ました。

AtCoderでは、これからはデータ構造のライブラリを提供することで、少し難しめのデータ構造を使った問題がABCにも頻繁に出てくるようになるようです。

ac-libraryはC++で書かれたものであり、多言語のライブラリは有志がGitHub上で開発をしているようです。

ganariyaは普段CLionで使っているため、できればCLionでatcoderライブラリを使えるようにしたいと考えました。
(時間を見つけて 自分で実装したライブラリに移行したいですが 色々と忙しくできていない...)

CLionで使う

https://atcoder.github.io/ac-library/document_ja/
を参考にatcoderフォルダを用意します。

その後、CLionのプロジェクト直下にatcoderフォルダを移してください。
以下のような画像になればOKです。

スクリーンショット 2020-09-20 18.00.02.png

あとはCMakeLists.txtを開き

include_directories(.)

を最後の行などに追加すればOKです。
これまで通り実行ボタンを押すといい感じにCLionがやってくれます。

例)

cmake_minimum_required(VERSION 3.15)
project(CompetitiveProgramming)

set(CMAKE_CXX_STANDARD 17)

add_executable(CompetitiveProgramming main.cpp)

include_directories(.)

何が行われているのか

g++からはg++ main.cpp -std=c++14 -I .のコマンドでmain.cppをコンパイルできます。

この-Iオプションはg++ --helpで調べると

  -I <dir>                Add directory to include search path

上記のようにカレントパスにあるディレクトリ(atcoderを含む)をコンパイル時に入れている のだと考えられます。(正確な理解ではないため、詳しい人がおりましたら教えていただけると幸いです。)

4
1
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
4
1