1

我想getenv在 Visual Studio 2012 的 C++ 项目中使用 C 中的函数。

编码:

extern "C" System::SByte^ getenv(const System::SByte^ name);

然后在某些功能中:

String^ h1 = "HOMEDRIVE";
const System::SByte^ c1 = dynamic_cast<const System::SByte^>(h1);
getenv(c1);

我得到的错误:

Error   11  error LNK2019: unresolved external symbol "extern "C" class System::SByte ^ __clrcall getenv(class System::SByte const ^)" (?getenv@@$$J0YMP$AAVSByte@System@@P$ABV12@@Z) referenced in function "public: void __clrcall Kameleon::Form1::createConfig(void)" (?createConfig@Form1@Kameleon@@$$FQ$AAMXXZ)   C:\Users\Michal\Desktop\Kameleon\Kameleon\Kameleon\Kameleon.obj Kameleon
4

1 回答 1

1

我认为对于 C++ 项目,您可以使用getenvfrom<cstdlib>,而不是 C++/CLI one。

于 2013-05-14T19:27:54.517 回答