gpt4 book ai didi

c++ - 尽管包含头文件和库,uuid 函数仍未定义

转载 作者:太空宇宙 更新时间:2023-11-04 12:50:34 25 4
gpt4 key购买 nike

为什么 uuid_generate_random 未定义?据我所知,我在编译时包含了 uuid 库。

有什么问题的建议吗?

me@me-vm:~/Projects/_Tests/test_cba$ make
g++ -o res main.cpp -Luuid -std=c++11
/tmp/ccRubbJa.o: In function `main':
main.cpp:(.text+0x30): undefined reference to 'uuid_generate_random'
collect2: error: ld returned 1 exit status
make: *** [all] Error 1

简单代码:

#include <iostream>
#include <uuid/uuid.h>

int main(int argc, char** argv) {

uuid_t id;
uuid_generate_random(id);

return 0;
}

最佳答案

使用错误的命令。使用下面

g++ -o res main.cpp -luuid -std=c++11

-L 用于提供库的位置

-l 用于提供名称库。

关于c++ - 尽管包含头文件和库,uuid 函数仍未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37319478/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com