使用c DLL导入c++项目
Using c DLL into c++ project
所以我有一个问题。我读了很多书,但似乎都不适合我。
我有这个C库,我用file:
做了一个项目//send.h
#ifndef SEND_H
#define SEND_H
#ifdef __cplusplus
extern "C" {
#endif
static int Send_Sample(void);
#ifdef __cplusplus
}
#endif
#endif /* SEND_H */
还有
//send.c
#include "thatLibrary.h"
static int Send_Sample(void)
{ return 0; }
所以我创建项目作为空DLL,然后我建立了它,它的ok。但是当我做了另一个项目,并引用了这个项目时,我做了
#include "send.h"
这个include正在工作,他看到。h文件,但是当我构建另一个项目时,它说:
Error C2129 static function 'int Send_Sample(void)' declared but not defined AzureEventHubClient c:usersv-vlvesidocumentsgithubazureeventhubclibraryazureeventhubclientsource.cpp 9
有人知道如何解决这个问题吗?
谢谢!
'static'关键字实际上防止从DLL导出函数。您还必须使用dllimport和dllexport。
您可以参考前面的答案来了解如何检测您的代码:使用dlexport
相关文章:
- 使用C++库在Android项目中修改gradle中的cmake参数,用于插入指令的测试
- 无法在 CLion 中构建 C++ 项目
- 运行同一解决方案的另一个项目的项目
- CMake-按正确顺序将项目与C运行时对象文件链接
- 如何在选项卡视图Qt中设置一个新项目,并保存以前的项目
- 欧拉项目#8答案是大以获得有效答案
- 从链接列表c++中删除一个项目
- CMake项目Boost库错误:Boost/config/compiler/gcc.hpp:165:10:致命错误:cs
- 既然存在危险,为什么项目要使用-I include开关
- cmake在我的项目中所需的所有静态库都不成功
- QT通过C++添加映射QML项目
- 我的项目不会像"undefined reference to `grpc::g_core_codegen_interface'"那样使用未定义的引用错误进行编译
- 在linux上调试巨大的C++项目
- 在其他文件中创建类时在 c++ 项目中不起作用
- 使外部项目可用于find_package CMake
- 在子目录中使用target_sources()命令时用于单元测试(qtest)的项目结构
- 使用外部SDK工具链文件在VisualStudio上生成项目编译错误
- 如何维护资源管理器项目视图中当前可见的项目列表
- 错误-我无法在VS2019中打开新的Qt项目
- 你能检查一下为什么在这个代码中从链接列表中删除项目不起作用吗