获取对function_name的未定义引用

Getting Undefined reference to function_name

本文关键字:未定义 引用 name function 获取      更新时间:2023-10-16

我有一个用C编写的开源项目,并学习用C++包装它。 C 中使用的所有函数都在标头中定义,我已经将C++代码中的函数链接为静态库(具有包含和 lib 文件(。 现在,如果我尝试从我的 main 访问/使用函数,例如用 C 开源编写的 display(.cpp它会抛出未定义的引用错误。

注意:C 开源目录和包装器目录不在同一位置。刚刚复制了包含和库并链接到C++项目。

错误文本

CMakeFileswrapper.dir/objects.a(main.cpp.obj): In function `main':
G:/Development/wrapper/main.cpp:34: undefined reference to `IedConnection_create'
G:/Development/wrapper/main.cpp:36: undefined reference to `IedConnection_connect'

IedConnection_create 是一个用开源编写的函数,并在我的C++代码中包含相应的标头。

谁能帮我摆脱困境?谢谢

链接器找不到引用的符号。 在这里阅读: https://latedev.wordpress.com/2014/04/22/common-c-error-messages-2-unresolved-reference/