简体   繁体   中英

unresolved external symbol error even though the function exists char*

I have two projects in one solution in Visual Studio. One of the projects (application) depends on another (library). The library has a method:

int foo(_TCHAR*);

It is properly defined in header and implemented. In the application I call the method like this:

int bar(_TCHAR* str) {
  return foo(str);
}

The error I am getting is

error LNK2001: unresolved external symbol "public: int __cdecl foo(char *)"

The method signature is exactly the same and the same type of variable is being used.

The reason behind the linker not being able to match the methods is the mismatched Character Set option in projects General Properties page.

The library project had this option set to Use Unicode Character Set and the application to Use Multi-Byte Character Set .

Unifying the Character Set in both projects fixed this error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM