提示コマンドですがいくつかわからないコマンドがあるのですがこれについて知りたいです。以下のフラグはそれぞれどういう意味をしているのでしょうか?調べましたが-O2
までしか出てこなくてわかりません
1,「 ` 」の意味
2,「 \ 」の意味
コマンドA
`Magick++-config --cppflags --cxxflags --ldflags --libs`
コマンドB
c++ `Magick++-config --cxxflags --cppflags` -O2 -o demo demo.cpp \ `Magick++-config --ldflags --libs`
ImageMagick: https://imagemagick.org/script/magick++.php
g++: https://kaworu.jpn.org/cpp/g++
-O2: https://kaworu.jpn.org/cpp/g%2B%2B_%E6%9C%80%E9%81%A9%E5%8C%96%E3%82%AA%E3%83%97%E3%82%B7%E3%83%A7%E3%83%B3#.E6.A6.82.E8.A6.81
コンパイルコマンド
g++ -O2 -o test Main.cpp `Magick++-config --cppflags --cxxflags --ldflags --libs`
Magick++-config --cppflags --cxxflags --ldflags --libs
は実行できますでしょうか?
(前後に「`」を付けない)
上記が実行された結果が文字列として、
g++ -O2 -o test Main.cpp
の後ろ(右)に追加されます
参考
https://www.server-memo.net/shellscript/quart.html#i-4
の「1.3 バッククォート」
【追記】
https://jhalfmoon.com/dbc/2022/04/07/%E3%83%88%E3%83%9B%E3%83%9B%E3%81%AA%E7%96%91%E5%95%8F48-termux%E3%80%81pkg-config%E3%81%A7magick%E5%91%BC%E3%81%B6cpp%E3%82%92%E3%83%93%E3%83%AB%E3%83%89/
を見ると、「Magick++-config」の処理は「pkg-config」が請け負ってるみたいなので、「pkg-config」の「Magick++.pc」とかを調べたら、g++のオプションとして何が必要か分かるかも
> 「 ` 」を使わない版のコマンド
最初に書いたように
Magick++-config --cppflags --cxxflags --ldflags --libs
です
あるいは、下記でもいいかも
pkg-config --cppflags --cxxflags --ldflags --libs Magick++
参考
https://www.chihayafuru.jp/tech/index.php/archives/3753
存在しています
一様確認を取りたいのですが Magick++-config --cppflags --cxxflags --ldflags --libsの実行結果を右に追加という意味なのでしょうか?
> Magick++-config --cppflags --cxxflags --ldflags --libsの実行結果を右に追加
が、
> g++ -O2 -o test Main.cpp `Magick++-config --cppflags --cxxflags --ldflags --libs`
の場合なら、そうです
g++ -O2 -o test Main.cpp
の「Main.cpp」の右に、半角スペースを挟んで追加してみてください
【追記】
「`Magick++-config --cppflags --cxxflags --ldflags --libs`」が、「Magick++-config --cppflags --cxxflags --ldflags --libs」の実行結果で置き換わる、と言う方が正確です
> 2,「 \ 」の意味
makefile内に
> c++ `Magick++-config --cxxflags --cppflags` -O2 -o demo demo.cpp \
`Magick++-config --ldflags --libs`
と書かれてるのでしたら、行が長いと読みにくいので、2行以上に分けて書くためです
参考
https://runebook.dev/ja/docs/gnu_make/splitting-lines
回答1件
あなたの回答
tips
プレビュー