我在解决方案中有3个项目:CppProject1(C ++),CProject(C)和CppProject2(C ++)
CProject依赖于CppProject1
CppProject2依赖于CProject。
CppProject2 -> CProject -> CppProject1
我想要实现的是从CProject调用C ++方法。
CppProject1包含以下文件:
///c_wrapper.h
#ifndef _C_WRAPPER_H__
#define _C_WRAPPER_H__
#ifdef __cplusplus
#define EXTERNC extern "C"
#else
#define EXTERNC
#endif
EXTERNC void findMarkers(int width, int height, unsigned char* dataPtr);
#endif
///c_wrapper.cpp
#include "c_wrapper.h"
void findMarkers(int width, int height, unsigned char* dataPtr) {
//nothing
}
如果我编译并链接CProject(CProject -> CppProject1
)一切正常。
如果我尝试编译并链接CppProject2(CppProject2 -> CProject -> CppProject1
),我会得到
LNK2001: unresolved external symbol _findMarkers