質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
g++

g++はGNUコンパイラコレクション(gcc)のC++コンパイラーです。

コンパイラ

コンパイラは、プログラミング言語で記述したソースコードを、コンピュータの実行形式であるオブジェクトコードに変換するプログラムです。

コンパイルエラー

コンパイルのフェーズで生成されるエラーです。よく無効なシンタックスやタイプが含まれているとき発生します。

C++

C++はC言語をもとにしてつくられた最もよく使われるマルチパラダイムプログラミング言語の1つです。オブジェクト指向、ジェネリック、命令型など広く対応しており、多目的に使用されています。

Q&A

1回答

1643閲覧

macでc++を動作させようとしたが,NTL/ZZ.hなどのヘッダーファイルでエラーが発生しコンパイルできません。

field_flat

総合スコア16

g++

g++はGNUコンパイラコレクション(gcc)のC++コンパイラーです。

コンパイラ

コンパイラは、プログラミング言語で記述したソースコードを、コンピュータの実行形式であるオブジェクトコードに変換するプログラムです。

コンパイルエラー

コンパイルのフェーズで生成されるエラーです。よく無効なシンタックスやタイプが含まれているとき発生します。

C++

C++はC言語をもとにしてつくられた最もよく使われるマルチパラダイムプログラミング言語の1つです。オブジェクト指向、ジェネリック、命令型など広く対応しており、多目的に使用されています。

0グッド

0クリップ

投稿2020/06/03 13:21

macで初めてc++を動作させようとしています.
しかし, 下記エラーが発生しコンパイルができません.
エラー内容を見るとNTL/ZZ.hやSmartPtr.h, tools.h, vector.hでエラーが発生しているようですが,対応策が分からないため教えていただきたいです.

console

1In file included from DKSIDFT.cpp:1: 2In file included from /usr/local/include/NTL/ZZ.h:19: 3/usr/local/include/NTL/tools.h:663:18: warning: variadic templates are a C++11 extension [-Wc++11-extensions] 4 template<class... Args> 5 ^ 6/usr/local/include/NTL/tools.h:664:20: warning: rvalue references are a C++11 extension [-Wc++11-extensions] 7 DerivedNode(Args&&... args) : t(std::forward<Args>(args)...) { } 8 ^ 9/usr/local/include/NTL/tools.h:668:22: error: expected function body after function declarator 10delete_node(Node *p) noexcept { delete p; } 11 ^ 12/usr/local/include/NTL/tools.h:705:28: error: unknown type name 'delete_list' 13 static key_wrapper wkey(delete_list); 14 ^ 15/usr/local/include/NTL/tools.h:705:4: error: function declared in block scope cannot have 'static' storage class 16 static key_wrapper wkey(delete_list); 17 ^ 18/usr/local/include/NTL/tools.h:715:7: error: use of undeclared identifier 'delete_node' 19 delete_node(p); 20 ^ 21/usr/local/include/NTL/tools.h:1064:1: error: unknown type name 'constexpr' 22constexpr bool Relocate_aux_has_trivial_copy(T*) 23^ 24/usr/local/include/NTL/tools.h:1072:1: error: unknown type name 'constexpr' 25constexpr bool Relocate_aux_has_any_copy(T*) 26^ 27/usr/local/include/NTL/tools.h:1140:1: error: unknown type name 'constexpr' 28constexpr bool DeclareRelocatableType(T*) 29^ 30In file included from DKSIDFT.cpp:1: 31In file included from /usr/local/include/NTL/ZZ.h:20: 32/usr/local/include/NTL/vector.h:211:11: error: unknown type name 'constexpr' 33 static constexpr bool relocatable = DeclareRelocatableType((T*)0); 34 ^ 35/usr/local/include/NTL/vector.h:212:11: error: unknown type name 'constexpr' 36 static constexpr bool copyable = Relocate_aux_has_any_copy((T*)0); 37 ^ 38/usr/local/include/NTL/vector.h:248:11: warning: rvalue references are a C++11 extension [-Wc++11-extensions] 39 Vec(Vec&& a) NTL_FAKE_NOEXCEPT 40 ^ 41/usr/local/include/NTL/vector.h:248:16: error: expected ';' at end of declaration list 42 Vec(Vec&& a) NTL_FAKE_NOEXCEPT 43 ^ 44 ; 45/usr/local/include/NTL/vector.h:465:20: error: unknown type name 'constexpr' 46template <class T> NTL_DECLARE_RELOCATABLE((Vec<T>*)) 47 ^ 48/usr/local/include/NTL/tools.h:1163:36: note: expanded from macro 'NTL_DECLARE_RELOCATABLE' 49#define NTL_DECLARE_RELOCATABLE(x) NTL_DECLARE_RELOCATABLE_WHEN(x) \ 50 ^ 51/usr/local/include/NTL/tools.h:1045:41: note: expanded from macro 'NTL_DECLARE_RELOCATABLE_WHEN' 52#define NTL_DECLARE_RELOCATABLE_WHEN(x) \ 53 ^ 54In file included from DKSIDFT.cpp:1: 55In file included from /usr/local/include/NTL/ZZ.h:20: 56/usr/local/include/NTL/vector.h:838:14: error: out-of-line definition of 'kill' does not match any declaration in 'Vec<T>' 57void Vec<T>::kill() 58 ^~~~ 59In file included from DKSIDFT.cpp:1: 60In file included from /usr/local/include/NTL/ZZ.h:21: 61/usr/local/include/NTL/SmartPtr.h:296:21: warning: rvalue references are a C++11 extension [-Wc++11-extensions] 62 SmartPtr(SmartPtr&& other) noexcept : dp(other.dp), cp(other.cp) 63 ^ 64/usr/local/include/NTL/SmartPtr.h:296:30: error: expected ';' at end of declaration list 65 SmartPtr(SmartPtr&& other) noexcept : dp(other.dp), cp(other.cp) 66 ^ 67 ; 68/usr/local/include/NTL/SmartPtr.h:363:20: error: unknown type name 'constexpr' 69template <class T> NTL_DECLARE_RELOCATABLE((SmartPtr<T>*)) 70 ^ 71/usr/local/include/NTL/tools.h:1163:36: note: expanded from macro 'NTL_DECLARE_RELOCATABLE' 72#define NTL_DECLARE_RELOCATABLE(x) NTL_DECLARE_RELOCATABLE_WHEN(x) \ 73 ^ 74/usr/local/include/NTL/tools.h:1045:41: note: expanded from macro 'NTL_DECLARE_RELOCATABLE_WHEN' 75#define NTL_DECLARE_RELOCATABLE_WHEN(x) \ 76 ^ 77In file included from DKSIDFT.cpp:1: 78In file included from /usr/local/include/NTL/ZZ.h:21: 79/usr/local/include/NTL/SmartPtr.h:539:29: warning: rvalue references are a C++11 extension [-Wc++11-extensions] 80 CloneablePtr(CloneablePtr&& other) noexcept : dp(other.dp), cp(other.cp) 81 ^ 82/usr/local/include/NTL/SmartPtr.h:539:38: error: expected ';' at end of declaration list 83 CloneablePtr(CloneablePtr&& other) noexcept : dp(other.dp), cp(other.cp) 84 ^ 85 ; 86/usr/local/include/NTL/SmartPtr.h:616:19: error: unknown type name 'constexpr' 87template<class T> NTL_DECLARE_RELOCATABLE((CloneablePtr<T>*)) 88 ^ 89/usr/local/include/NTL/tools.h:1163:36: note: expanded from macro 'NTL_DECLARE_RELOCATABLE' 90#define NTL_DECLARE_RELOCATABLE(x) NTL_DECLARE_RELOCATABLE_WHEN(x) \ 91 ^ 92/usr/local/include/NTL/tools.h:1045:41: note: expanded from macro 'NTL_DECLARE_RELOCATABLE_WHEN' 93#define NTL_DECLARE_RELOCATABLE_WHEN(x) \ 94 ^ 95In file included from DKSIDFT.cpp:1: 96In file included from /usr/local/include/NTL/ZZ.h:21: 97/usr/local/include/NTL/SmartPtr.h:666:18: warning: variadic templates are a C++11 extension [-Wc++11-extensions] 98 template<class... Args> 99 ^ 100/usr/local/include/NTL/SmartPtr.h:667:21: warning: rvalue references are a C++11 extension [-Wc++11-extensions] 101 MakeSmartAux(Args&&... args) : d(std::forward<Args>(args)...) { } 102 ^ 103/usr/local/include/NTL/SmartPtr.h:670:24: warning: variadic templates are a C++11 extension [-Wc++11-extensions] 104template<class T, class... Args> 105 ^ 106/usr/local/include/NTL/SmartPtr.h:671:27: warning: rvalue references are a C++11 extension [-Wc++11-extensions] 107SmartPtr<T> MakeSmart(Args&&... args) 108 ^ 109/usr/local/include/NTL/SmartPtr.h:684:18: warning: variadic templates are a C++11 extension [-Wc++11-extensions] 110 template<class... Args> 111 ^ 112/usr/local/include/NTL/SmartPtr.h:685:25: warning: rvalue references are a C++11 extension [-Wc++11-extensions] 113 MakeCloneableAux(Args&&... args) : d(std::forward<Args>(args)...) { } 114 ^ 115/usr/local/include/NTL/SmartPtr.h:708:24: warning: variadic templates are a C++11 extension [-Wc++11-extensions] 116template<class T, class... Args> 117 ^ 118/usr/local/include/NTL/SmartPtr.h:709:16: warning: rvalue references are a C++11 extension [-Wc++11-extensions] 119T* MakeRaw(Args&&... args) { 120 ^ 121/usr/local/include/NTL/SmartPtr.h:718:24: warning: variadic templates are a C++11 extension [-Wc++11-extensions] 122template<class T, class... Args> 123 ^ 124/usr/local/include/NTL/SmartPtr.h:719:35: warning: rvalue references are a C++11 extension [-Wc++11-extensions] 125CloneablePtr<T> MakeCloneable(Args&&... args) 126 ^ 127/usr/local/include/NTL/SmartPtr.h:1082:23: warning: rvalue references are a C++11 extension [-Wc++11-extensions] 128 UniquePtr(UniquePtr&& other) noexcept : UniquePtr() 129 ^ 130/usr/local/include/NTL/SmartPtr.h:1082:32: error: expected ';' at end of declaration list 131 UniquePtr(UniquePtr&& other) noexcept : UniquePtr() 132 ^ 133 ; 134/usr/local/include/NTL/SmartPtr.h:1152:28: error: unknown type name 'constexpr' 135template<class T, class P> NTL_DECLARE_RELOCATABLE((UniquePtr<T,P>*)) 136 ^ 137/usr/local/include/NTL/tools.h:1163:36: note: expanded from macro 'NTL_DECLARE_RELOCATABLE' 138#define NTL_DECLARE_RELOCATABLE(x) NTL_DECLARE_RELOCATABLE_WHEN(x) \ 139 ^ 140/usr/local/include/NTL/tools.h:1045:41: note: expanded from macro 'NTL_DECLARE_RELOCATABLE_WHEN' 141#define NTL_DECLARE_RELOCATABLE_WHEN(x) \ 142 ^ 143In file included from DKSIDFT.cpp:1: 144In file included from /usr/local/include/NTL/ZZ.h:21: 145/usr/local/include/NTL/SmartPtr.h:1265:23: warning: rvalue references are a C++11 extension [-Wc++11-extensions] 146 CopiedPtr(CopiedPtr&& other) noexcept : CopiedPtr() 147 ^ 148/usr/local/include/NTL/SmartPtr.h:1265:32: error: expected ';' at end of declaration list 149 CopiedPtr(CopiedPtr&& other) noexcept : CopiedPtr() 150 ^ 151 ; 152fatal error: too many errors emitted, stopping now [-ferror-limit=] 15317 warnings and 20 errors generated.

以下,利用しているg++コンパイラ情報です.

$ g++ --version Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1 Apple clang version 11.0.3 (clang-1103.0.32.62) Target: x86_64-apple-darwin19.4.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

なおソースコードについては,著作権に関する事情から掲載することができません.

よろしくお願いいたします.

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

cateye

2020/06/03 13:26

エラーに成るファイル(.h)はその場所に有りますか?
field_flat

2020/06/03 13:30 編集

cateye さん ご回答ありがとうございます. > エラーに成るファイル(.h)はその場所に有りますか? こちらは以下の通り,存在しているかと思われます. ``` /usr/local/include/NTL$ ls ALL_FEATURES.h HAVE_COPY_TRAITS2.h ZZX.h mach_desc.h pair_lzz_pEX_long.h vec_ulong.h BasicThreadPool.h HAVE_FMA.h ZZXFactoring.h mat_GF2.h pair_lzz_pX_long.h vec_vec_GF2.h ConfigLog.h HAVE_LL_TYPE.h ZZ_limbs.h mat_GF2E.h pd_FFT.h vec_vec_GF2E.h FFT.h HAVE_MACOS_TIME.h ZZ_p.h mat_RR.h quad_float.h vec_vec_RR.h FFT_impl.h HAVE_PCLMUL.h ZZ_pE.h mat_ZZ.h sp_arith.h vec_vec_ZZ.h FacVec.h HAVE_POSIX_TIME.h ZZ_pEX.h mat_ZZ_p.h thread.h vec_vec_ZZ_p.h GF2.h HAVE_SSSE3.h ZZ_pEXFactoring.h mat_ZZ_pE.h tools.h vec_vec_ZZ_pE.h GF2E.h HNF.h ZZ_pX.h mat_lzz_p.h vec_GF2.h vec_vec_long.h GF2EX.h LLL.h ZZ_pXFactoring.h mat_lzz_pE.h vec_GF2E.h vec_vec_lzz_p.h GF2EXFactoring.h Lazy.h config.h mat_poly_ZZ.h vec_GF2XVec.h vec_vec_lzz_pE.h GF2X.h LazyTable.h ctools.h mat_poly_ZZ_p.h vec_RR.h vec_vec_ulong.h GF2XFactoring.h MatPrime.h fileio.h mat_poly_lzz_p.h vec_ZZ.h vec_xdouble.h GF2XVec.h PD.h gmp_aux.h matrix.h vec_ZZVec.h vector.h HAVE_ALIGNED_ARRAY.h PackageInfo.h lip.h new.h vec_ZZ_p.h version.h HAVE_AVX.h REPORT_ALL_FEATURES.h lzz_p.h pair.h vec_ZZ_pE.h xdouble.h HAVE_AVX2.h RR.h lzz_pE.h pair_GF2EX_long.h vec_double.h HAVE_AVX512F.h SmartPtr.h lzz_pEX.h pair_GF2X_long.h vec_long.h HAVE_BUILTIN_CLZL.h WordVector.h lzz_pEXFactoring.h pair_ZZX_long.h vec_lzz_p.h HAVE_CHRONO_TIME.h ZZ.h lzz_pX.h pair_ZZ_pEX_long.h vec_lzz_pE.h HAVE_COPY_TRAITS1.h ZZVec.h lzz_pXFactoring.h pair_ZZ_pX_long.h vec_quad_float.h ```
field_flat

2020/06/03 13:32

hoshi-takanori さん ご回答ありがとうございます. リンクありがとうございます!! 一度ダウンロードして,ちゃんと挙動するか確認してみます.
CHERRY

2020/06/03 21:21

いただいたソースということですが、元々は、どのような環境で動作していたのでしょうか? また、ソースコードを提供いただいた方には、エラーが出た場合、どのようにすれば良いか相談・質問できないのでしょうか?
field_flat

2020/06/04 11:33

CHERRYさん ご回答ありがとうございます. > いただいたソースということですが、元々は、どのような環境で動作していたのでしょうか? > また、ソースコードを提供いただいた方には、エラーが出た場合、どのようにすれば良いか相談・質問できないのでしょうか? こちらですが,今直接提供者の方に確認を依頼しています. その間に自分でもやれることをやっておこうと思います.
SHOMI

2020/06/04 16:08

可変引数テンプレートやconstexpr、右辺値参照で怒られまくっているのでまずはコンパイルオプションに-std=c11をつけてみては?
guest

回答1

0

MacならHomebrewを導入してみてはいかがでしょう。
NTLパッケージもあります。

~ $ brew info ntl
ntl: stable 11.4.3 (bottled)
C++ number theory library
https://www.shoup.net/ntl

インストールしてみました

~ $ brew install ntl

ヘッダファイルもインストールされるみたいです。

~ $ ls /usr/local/include/NTL/zz.h
/usr/local/include/NTL/zz.h

~ $ ls /usr/local/include/NTL/SmartPtr.h
/usr/local/include/NTL/SmartPtr.h

投稿2020/06/03 13:30

technocore

総合スコア7200

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

field_flat

2020/06/03 13:36

technocoreさん ご回答ありがとうございます. ご指摘の通りNTLパッケージをHomebrewからインストールしてみました. ヘッダファイルもちゃんとインストールできていることが確認できましたが,依然として同じエラーが発生している状況ですね... この場合,考えられるエラー原因はどこにありそうでしょうか...?
technocore

2020/06/03 13:50

失礼しました。「ファイルが見つからない」エラーと勘違いしてました。 ソースコードが見られたらこちらでも動作確認できるのですけどね。 >error: expected ';' at end of declaration list やたらとこのエラーが出ていますが書き間違いしていませんか?
field_flat

2020/06/03 15:31

technocoreさん ご返信ありがとうございます. > やたらとこのエラーが出ていますが書き間違いしていませんか? このエラー部分がヘッダーファイルで発生しておりまして... ソースコードに関しては他人からいただいたもので,実際に論文でも使用されているプログラムなので,おそらくソースコードには問題がないと考えております.(共有できずに申し訳ございません) そもそもヘッダーファイル(ライブラリ)でエラーが発生することは考えられるのでしょうか...? よろしければご回答いただけると幸いです.よろしくお願いいたします.
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問