実現したいこと
matprotlib C++サイトからmatprotlib.hをダウンロードしてビジュアルスタジオC++で
サンプル図を作成しようとすると以下のエラーが表示される。
この対策方法は、パイソンバージョン(Python 3.13.7)のダウングレードしかないのでしょうか。
Python 3では、非推奨になったので、このような表示が出るようです。
matprotlib.hの修正方法をご存じの方がいましたら教えてください。
'PySys_SetArgv': deprecated in 3.11 Matplotlib_test C:\Users\misa_\test_mat\Matplotlib_test\matplotlibcpp.h 182
'Py_SetProgramName': deprecated in 3.11 Matplotlib_test C:\Users\misa_\test_mat\Matplotlib_test\matplotlibcpp.h 174
発生している問題・分からないこと
オリジナルのサイトからダウンロードしたmatplotlibcpp.h を使用してビルドするとエラー表示される
該当のソースコード
特になし
試したこと・調べたこと
- teratailやGoogle等で検索した
- ソースコードを自分なりに変更した
- 知人に聞いた
- その他
上記の詳細・結果
Python 3.13.7では、非推奨になったコードを使用している。
補足
特になし
pythonのバージョンを落すのが妥当だと思いますが、 3.13を使いたい理由があるのでしょうか。
ちなみに、pythonのマイナーバージョンを複数インストールして切り替えてつかうこともできます。
昨日作業した時点での最新バージョンだったからで特に意味はありません。
確認する気はないですがforkされたものがたくさんあって、例えば
https://github.com/amadeus84/matplotlib-cpp
とかはそのあたりを対応したものじゃないでしょうか?
コメントありがとうございます。試した結果以下のエラーが表示されました。
これは修正可能でしょうか。
外部シンボル "public: void __cdecl matplot::figure_type::show(void)" (?show@figure_type@matplot@@QEAAXXZ) は未解決です
外部シンボル "public: class std::shared_ptr<class matplot::line> __cdecl matplot::axes_type::plot(class std::vector<double,class std::allocator<double> > const &,class std::vector<double,class std::allocator<double> > const &,class std::basic_string_view<char,struct std::char_traits<char> >)" (?plot@axes_type@matplot@@QEAA?AV?$shared_ptr@Vline@matplot@@@std@@AEBV?$vector@NV?$allocator@N@std@@@4@0V?$basic_string_view@DU?$char_traits@D@std@@@4@@Z) は未解決です
外部シンボル "class std::shared_ptr<class matplot::figure_type> __cdecl matplot::gcf(void)" (?gcf@matplot@@YA?AV?$shared_ptr@Vfigure_type@matplot@@@std@@XZ) は未解決です
外部シンボル "class std::shared_ptr<class matplot::axes_type> __cdecl matplot::gca(void)" (?gca@matplot@@YA?AV?$shared_ptr@Vaxes_type@matplot@@@std@@XZ) は未解決です
ファイルは、現在のコード ページ (932) で表示できない文字を含んでいます。データの損失を防ぐために、ファイルを Unicode 形式で保存してください。
4 件の未解決の外部参照外部シンボル "public: void __cdecl matplot::figure_type::show(void)" (?show@figure_type@matplot@@QEAAXXZ) は未解決です
外部シンボル "public: class std::shared_ptr<class matplot::line> __cdecl matplot::axes_type::plot(class std::vector<double,class std::allocator<double> > const &,class std::vector<double,class std::allocator<double> > const &,class std::basic_string_view<char,struct std::char_traits<char> >)" (?plot@axes_type@matplot@@QEAA?AV?$shared_ptr@Vline@matplot@@@std@@AEBV?$vector@NV?$allocator@N@std@@@4@0V?$basic_string_view@DU?$char_traits@D@std@@@4@@Z) は未解決です
外部シンボル "class std::shared_ptr<class matplot::figure_type> __cdecl matplot::gcf(void)" (?gcf@matplot@@YA?AV?$shared_ptr@Vfigure_type@matplot@@@std@@XZ) は未解決です
外部シンボル "class std::shared_ptr<class matplot::axes_type> __cdecl matplot::gca(void)" (?gca@matplot@@YA?AV?$shared_ptr@Vaxes_type@matplot@@@std@@XZ) は未解決です
ファイルは、現在のコード ページ (932) で表示できない文字を含んでいます。データの損失を防ぐために、ファイルを Unicode 形式で保存してください。
4 件の未解決の外部参照
ソースコードは以下になります。
ソースコード事態の問題は見つかりませんと表示されています。
#include <matplot/matplot.h>
#include <vector>
#include <iostream>
namespace plt = matplot;
int main()
{
std::cout << "Hello World!\n";
std::vector<double> x(100), y(100);
for (int i = 0; i < 100; i++) {
x[i] = 1.0 * i / 100;
y[i] = x[i] * x[i];
}
plt::plot(x, y);
plt::show();
}
結局、誰の回答の方法でやることにしたのでしょうか?
ちなみに、提示されたソースは、私の回答の方法で正常にグラフ表示されています。
(プルリク版ヘッダーとMatplot++の両方とも、右肩上がりの曲線)
昔、このような回答をいただいたのを思い出したので、この方法を試してみました。
https://teratail.com/questions/mh9h0q549hd585
これで当時は動いたので同様の作業を行いました。
その結果エラーが表示されました。

回答5件
あなたの回答
tips
プレビュー