Reputation: 11
I want to use a getenv
function from C in my C++ project in Visual Studio 2012.
The code:
extern "C" System::SByte^ getenv(const System::SByte^ name);
and then in some function:
String^ h1 = "HOMEDRIVE";
const System::SByte^ c1 = dynamic_cast<const System::SByte^>(h1);
getenv(c1);
The error I get:
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
Upvotes: 1
Views: 1005
Reputation: 13003
I think for C++ project you can use getenv
from <cstdlib>
, not C++/CLI one.
Upvotes: 1