0

Visual C++ 2005 Express Edition を使用していますが、次のリンカ エラーが発生します。

19>mylib1.lib(mylibsource1.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::exception::_Raise(void)const " (__imp_?_Raise@exception@std@@QBEXXZ) referenced in function "protected: static void __cdecl std::vector<class mytype,class std::allocator<class mytype> >::_Xlen(void)" (?_Xlen@?$vector@Vmytype@@V?$allocator@Vmytype@@@std@@@std@@KAXXZ)
19>mylib2.lib(mylibsource2.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall std::exception::_Raise(void)const " (__imp_?_Raise@exception@std@@QBEXXZ)
19>mylib1.lib(mylibsource1.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall std::exception::exception(char const *,int)" (__imp_??0exception@std@@QAE@PBDH@Z) referenced in function "public: __thiscall std::logic_error::logic_error(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0logic_error@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z)
19>mylib2.lib(mylibsource2.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::exception::exception(char const *,int)" (__imp_??0exception@std@@QAE@PBDH@Z)

生成されたコードで例外をオフにし、ベクター ヘッダー ファイルをインクルードする前に使用しています。

#define _HAS_EXCEPTIONS 0

いくつかのGoogleの結果はいくつかのものを示しましたが、「ああ!」はありませんでした。私のために働いた解決策。

編集:

前述のように、「_HAS_EXCEPTIONS 0」自体は例外をオフにしません。少なくともベクターヘッダーファイルでは、C++の「スロー」を呼び出す代わりに、例外オブジェクトで_Raiseを呼び出します。私の場合、正しいライブラリを含めていないため、例外オブジェクトの _Raise 関数にリンクできません。ただし、そのライブラリが何であるかは明らかではありません。

4

2 に答える 2

1

次の行を追加します。

#define _STATIC_CPPLIB

ベクターヘッダーを含める前に、うまくいくようです。

于 2008-10-31T16:15:35.403 に答える
0

#define the _HAS_EXCEPTIONS 03 番目のエラーは、が に影響しないことを明確にしています。現在、含めることができます (当然のことながら、コードを共有すると実行可能ファイルのサイズが小さくなる可能性があります)。含める前に定義すると、エラーが発生する理由が説明されます。この種の定義は、プロジェクト設定で行う必要があります。

_HAS_EXCEPTIONS は、Visual Studio ではサポートされていない機能であることに注意してください。例外自体はオフになりません。

于 2008-10-30T09:44:59.673 に答える