对"uuid_generate"的未定义引用,即使我使用 -luuid
undefined reference to 'uuid_generate' even though I use -luuid
My test.cpp
#include <uuid/uuid.h>
#include <iostream>
int main(int argc, char *argv[])
{
uuid_t id;
uuid_generate(id);
char *string = new char[100];
uuid_unparse(id, string);
std::cout << string << std::endl;
return 0;
}
我使用的是Ubuntu 14
我正在运行test.cpp作为…
g++ -luuid test.cpp
和输出
test.cpp:(.text+0x26): undefined reference to `uuid_generate'
test.cpp:(.text+0x47): undefined reference to `uuid_unparse'
collect2: error: ld returned 1 exit status
我的c++版本:
Target: x86_64-linux-gnu
gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1)
和我已经安装了uid-dev。
sudo apt-get install uuid uuid-dev
uuid is already the newest version.
uuid-dev is already the newest version.
链接库的顺序很重要,您需要在引用的模块后添加-luuid
:
g++ test.cpp -luuid
除非您正在使用分组选项(-Wl,--start-group
, -Wl,--end-group
)。
相关文章:
- 编译C++时未定义的引用
- vscode g++链路故障:体系结构x86_64的未定义符号
- 如何修复此错误:未定义对"距离(浮点数,浮点数,浮点数,浮点数,浮点数)"的引用
- 我的项目不会像"undefined reference to `grpc::g_core_codegen_interface'"那样使用未定义的引用错误进行编译
- 不知道某个东西是否被忽略会引入未定义的行为吗
- 对C宏的未定义引用,但在定义它时会出现重新定义错误
- 未定义的引用在哪里
- 编译时的 CImg 库返回对"__imp_SetDIBitsToDevice"的未定义引用
- 对Py_Initialize()的未定义引用
- c++11评估顺序(未定义的行为)
- 使用mysql c++连接器的未定义引用
- 从python调用openMP共享库时,未定义opnMP函数
- 在 Mac 上使用 CMAKE 将 FFTW 和 FFTWPP 链接到项目中时未定义的符号
- Cmake 链接问题:未定义对 Button::mousePressEvent(QGraphicsSceneMouseE
- 未定义的引用 .. 使用 OpenCV 编译 C++ 代码时,从命令行
- 具有外部"c"和程序集的未定义函数
- 此增量后语句是否会导致未定义的行为?
- 尝试调用 .h 文件中定义的变量时出现变量未定义错误
- 在C++中使用内联方法时出现未定义的符号错误
- 对"uuid_generate"的未定义引用,即使我使用 -luuid