Managed c++ use unmanaged c++ static member cause link error

  • Thread starter Thread starter Stevenmbiz
  • Start date Start date
S

Stevenmbiz

Guest
I'm using managed c++/cli to wrap a C++ class with a static string member to save current project directory location, like the following:

namespace Core {

class Application {

public:

static string ProjectPath;



}

}


and I've initialized it at the top of the cpp file:

string Application::ProjectPath = "D:\Documents\Path";


When trying to access this static var in my cli wrapper class, like the following:

namespace Wrapper {

...

void Application::ProjectPath::set(String^ path) {

Core::Application::ProjectPath = to_string(path); // <-- cause a link error!

...

}


it caused 2 link errors said: error LNK2020: unresolved token (0A000BBD) "public: static char const *

and error LNK2001: unresolved external symbol.


Any clue for this?

Continue reading...
 
Back
Top