以下代码为什么无法导出函数

178 阅读1分钟

ExportDefine.h文件代码如下: #pragma once

#ifdef CADBASELib_20180328  //dll内部  #define  DLL_CADBASE_EXT_CLASS __declspec(dllexport)    #else       //dll外部  #define  DLL_CADBASE_EXT_CLASS __declspec(dllimport)

test.h代码如下: #pragma once #include "ExportDefine.h"   DLL_CADBASE_EXT_CLASS extern   double ABC123(double x1,double y1,double x2,double y2,double x3,double y3); #endif

test.cpp代码如下: #include "stdafx.h"

double ABC123(double x1,double y1,double x2,double y2,double x3,double y3) {  return 0 ; }

问题分析: test.cpp没有 #include "../include/CadBase/test.h",所以VS2010误认为ABC123 没使用,于是没编译。 解决方法: test.cpp  #include "../include/CadBase/test.h"