C++ 错误LNK2028:未解析的令牌(0A00000D)";“外部”;";无效
我在一个解决方案中有两个项目(使用VS 2013)。 第一个项目-mtriangle。包含C代码。C++ 错误LNK2028:未解析的令牌(0A00000D)";“外部”;";无效,c++,c,visual-studio,linker,C++,C,Visual Studio,Linker,我在一个解决方案中有两个项目(使用VS 2013)。 第一个项目-mtriangle。包含C代码。 第二个项目-GeoGui。包含Windows窗体项目(使用C++) 我尝试在GeoGui中使用mtriangle中的函数 我有以下代码: 项目mtriangle 三角形.h #ifdef __cplusplus extern "C" { #endif __declspec(dllexport) void trimain(char *, struct triangulateio *, st
第二个项目-GeoGui。包含Windows窗体项目(使用C++) 我尝试在GeoGui中使用mtriangle中的函数 我有以下代码: 项目mtriangle 三角形.h
#ifdef __cplusplus
extern "C" {
#endif
__declspec(dllexport) void trimain(char *, struct triangulateio *, struct triangulateio *, struct triangulateio *);
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
extern "C" {
#endif
void trifree(VOID *memptr);
#ifdef __cplusplus
}
#endif
#pragma once
extern "C"
{
#include "triangle.h"
}
...
private: System::Void dlgFileOpen_FileOk(System::Object^ sender, System::ComponentModel::CancelEventArgs^ e) {
struct triangulateio *in;
struct triangulateio *out;
struct triangulateio *voronoi;
trimain("p", in,out,voronoi);
}
triangle.c
void trimain(char *triswitches, struct triangulateio *in,
struct triangulateio *out, struct triangulateio *vorout)
{
// Implementation here, will be provided if need
}
项目GeoGui
mainForm.h
#ifdef __cplusplus
extern "C" {
#endif
__declspec(dllexport) void trimain(char *, struct triangulateio *, struct triangulateio *, struct triangulateio *);
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
extern "C" {
#endif
void trifree(VOID *memptr);
#ifdef __cplusplus
}
#endif
#pragma once
extern "C"
{
#include "triangle.h"
}
...
private: System::Void dlgFileOpen_FileOk(System::Object^ sender, System::ComponentModel::CancelEventArgs^ e) {
struct triangulateio *in;
struct triangulateio *out;
struct triangulateio *voronoi;
trimain("p", in,out,voronoi);
}
尝试生成解决方案时,出现错误消息:
Error 13 error LNK2028: unresolved token (0A00000D) "extern "C" void __cdecl trimain(char *,struct triangulateio *,struct triangulateio *,struct triangulateio *)" (?trimain@@$$J0YAXPADPAUtriangulateio@@11@Z) referenced in function "private: void __clrcall GeoGUI::mainForm::dlgFileOpen_FileOk(class System::Object ^,class System::ComponentModel::CancelEventArgs ^)" (?dlgFileOpen_FileOk@mainForm@GeoGUI@@$$FA$AAMXP$AAVObject@System@@P$AAVCancelEventArgs@ComponentModel@4@@Z) C:\Users\Administrator\Documents\Visual Studio 2013\Projects\mtriangle\GeoGUI\GeoGUI.obj GeoGUI
Error 14 error LNK2019: unresolved external symbol "extern "C" void __cdecl trimain(char *,struct triangulateio *,struct triangulateio *,struct triangulateio *)" (?trimain@@$$J0YAXPADPAUtriangulateio@@11@Z) referenced in function "private: void __clrcall GeoGUI::mainForm::dlgFileOpen_FileOk(class System::Object ^,class System::ComponentModel::CancelEventArgs ^)" (?dlgFileOpen_FileOk@mainForm@GeoGUI@@$$FA$AAMXP$AAVObject@System@@P$AAVCancelEventArgs@ComponentModel@4@@Z) C:\Users\Administrator\Documents\Visual Studio 2013\Projects\mtriangle\GeoGUI\GeoGUI.obj GeoGUI
请你告诉我,我做错了什么
谢谢大家!
我读了这篇文章
特别是本节:
符号在C程序中定义,并用C++代码编写。
它建议采取以下措施:
如果整个库包含在头文件中(并且编译为
C代码);包括以下内容:
但正如我在上面的示例中指出的,我已经做到了:
> extern "C" {
> #include "triangle.h"
> }
这是不同的 这里的问题是太多的
Extern“C”
,我不确定这是否在所示的答案线程中。Extern“C”
在头文件和周围的#include
?保留一个,放下另一个。是的,我已经做了。同样的错误。你能包含一个我们可以尝试和构建的自包含、完整的复制吗?这里的问题是太多的Extern“C”
,我不确定这是否在所示的回答线程中。Extern“C”
在头文件和周围#include
?保留一个,放下另一个。是的,我已经做了。同样的错误。你能包括一个独立的,完整的,我们可以尝试建立的复制吗?