在dll中找不到名为*的入口点
问题描述:
我在头文件中有一个C ++项目,其定义如下:
I have a C++ project with the following definition in the header file:
typedef enum /* Set operation type */
{
GPC_DIFF, /* Difference */
GPC_INT, /* Intersection */
GPC_XOR, /* Exclusive or */
GPC_UNION /* Union */
} gpc_op;
typedef struct /* Polygon vertex structure */
{
double x; /* Vertex x component */
double y; /* vertex y component */
} gpc_vertex;
typedef struct /* Vertex list structure */
{
int num_vertices; /* Number of vertices in list */
gpc_vertex *vertex; /* Vertex array pointer */
} gpc_vertex_list;
typedef struct /* Polygon set structure */
{
int num_contours; /* Number of contours in polygon */
int *hole; /* Hole / external contour flags */
gpc_vertex_list *contour; /* Contour array pointer */
} gpc_polygon;
void gpc_polygon_clip (gpc_op set_operation,
gpc_polygon *subject_polygon,
gpc_polygon *clip_polygon,
gpc_polygon *result_polygon);
我在VS 2008中编译它.它可以编译!到目前为止一切顺利.
And I compile it in VS 2008. It can compile! So far so good.
接下来,我想从.Net调用C ++ dll,然后执行标准的PInvoke:
Next I want to call the C++ dll from .Net, and I do a standard PInvoke:
[DllImport("gpc.dll")]
private static extern void gpc_polygon_clip([In] GpcOperation set_operation,
[In] ref gpc_polygon subject_polygon,
[In] ref gpc_polygon clip_polygon,
[In, Out] ref gpc_polygon result_polygon);
但是,当我运行代码时,出现无法在DLL'gpc.dll'中找到入口点名称*".
But when I run the code, I get an "unable to find an entry point name * in DLL 'gpc.dll'".
我认为我的C ++ vcproj设置一定是错误的,因为似乎未导出定义.知道如何解决这个问题吗?
I think my C++ vcproj setting must be wrong, because it seems that the definition is not exported. Any idea how to fix this?
答
extern "C" __declspec(dllexport) void gpc_polygon_clip (gpc_opset_operation,
gpc_polygon *subject_polygon,
gpc_polygon *clip_polygon,
gpc_polygon *result_polygon);
在c ++ vc项目中尝试以上操作.
try out above in c++ vc project.