c - 使用 QtCreator [mac os] 找不到 -lrt 的库

标签 c macos compiler-construction qt4 compilation

我在使用它使用选项“-lrt”构建的 QT 时遇到了一些麻烦

我正在使用 mac os 10.6 和 QT Creator 1.2.1,heeeeeeelp !

这是完整的构建命令:

g++ -headerpad_max_install_names -o AMiningCoreTest main.o tokenizer.o DictionnaryToolBox.o mysql.o btree.o BTreeDataTable.o tcaccess.o -L/Library/Frameworks -L/usr/lib/mysql -lmysqlclient -L/usr/local/lib/ -ltokyocabinet -lz -lbz2 -lrt -lpthread -lm -lc

最后是

ld: library not found for -lrt collect2: ld returned 1 exit status

最佳答案

链接器找不到 librt,它可能是 Posix 实时扩展库。我认为这在 OSX 上不可用。谷歌搜索给出了这个来自 Apple developer lists

列表中的问题

I'm trying to build a simulator developed in my university (on Linux) and I get error by the linker that seems unable to find librt.a - in the code is used for clock_gettime() and I would like to know if there's a port of such library, or some other similar function that allows me to compile even on Mac OS X.

Answer librt.a is the System V name of the library containing the POSIX Advanced Realtime [RT} Option functions. The specific function you are asking about is part of the [TMR] option. If Mac OS X supported it, it would be in libSystem.B,dylib, not librt.a. The function in question is not supported by Mac OS X.

Your code should check to see whether optional to implement things above and beyond the UNIX standard are implemented in the target OS, and if they aren't, use a different interface.

关于c - 使用 QtCreator [mac os] 找不到 -lrt 的库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58897110/

相关文章:

c - 从优化为循环不变的循环中的结构指针取消引用成员吗?

c - 为什么函数的参数是寄存器类型

c - 预处理器替换中乘以分数的问题(#define)

在C中逐个字符地比较两个字符串

linux - 如何使用 xargs 复制名称中包含空格和引号的文件?

macos - lldb python 错误

ruby-on-rails - RVM : failure in installing latest version of ruby on Mac OSX El Capitan

compiler-construction - 理解结构等价

c - 在 C 中提取子字符串

c - scanf() 不接受输入