我想在Visual Studio 2012的C ++项目中使用C中的getenv
函数。
代码:
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