因为要用到POSIX的定时器,编译时要动态链接librt(glibc的实时动态库)。
makefile链接时需要添加-lrt参数:
gcc -lrt a.o,b.o............. -o my_program
这个makefile在本地机器上运行得好好的,系统是Ubuntu 11.04 Desktop。
但是在服务器上就出现如下错误:
my_timer.o: In function `init_my_timer':
my_timer.c:(.text+0x1bb): undefined reference to `timer_create'
my_timer.o: In function `cancel_my_timer':
my_timer.c:(.text+0x220): undefined reference to `timer_settime'
my_timer.o: In function `start_my_timer':
my_timer.c:(.text+0x255): undefined reference to `timer_settime'
my_timer.o: In function `restart_my_timer':
my_timer.c:(.text+0x28a): undefined reference to `timer_settime'
collect2: ld returned 1 exit status
make: *** [my_program] Error 1
很明显是librt没有链接上!非常奇怪,服务器是Linux ubuntu-wfms-slaver-02 3.0.0-15-server
但是用 ldconfig -p 查看所有的动态库,看见是有librt的:
librt.so.1 (libc6,x86-64, OS ABI: Linux 2.6.15) => /lib/x86_64-linux-gnu/librt.so.1
librt.so (libc6,x86-64, OS ABI: Linux 2.6.15) => /usr/lib/x86_64-linux-gnu/librt.so
对这个问题非常不解!
偶然尝试将 -lrt 参数放在最后面:
gcc a.o,b.o............. -o my_program -lrt
结果就成功了~ 不太明白为什么参数的位置会有影响。
分享到:
相关推荐
学习32位单片机的基础例程,主要针对初学者对TIMER的编程学习
C51 Timer 0 的使用 Timer_0_mode_0_timer_gate_hard
C51 TIMER 0的使用 Timer_0_mode_0_timer_gate_soft
timer_signal 实例
本文主要介绍了MSP430单片机Timer_B和Timer_A的异同
设计一个挂载在 APB 总线上的计数器,按照 APB 的时序给计数器赋值,主机通过地址对计数器进行配置,通过数据输入端口给计数器...该设计还设置了一个计数完成信号,当计数器满足模式配置后的计数要求时,会将该信号拉高
关于计时器 verilog语言,采用arm架构的m3,可以直接应用于soc
自1996年MSP430十六位单片机问世以来,它的低功耗性能及丰富的片内资源受到各方面的好评,本文针对MSP430F13x及MSP43014X 系列单片机中的定时器进行介绍,利用定时器A(Timer_A)和定时器B(Timer_B)中的捕获比较寄存器...
msp430f149的timer b的使用示例,下载验证通过
wm-timer,it s a code for mfc c++ time counter
Linux内核
c# ScheduleTimer_src 自定义 c# ScheduleTimer_src
verilog实现计时器timer,可直接用于芯片开发中。
timer get base and rate for Linux v2.13.6.
java多线程定时器
用图形界面实现Timer,可以设置时间段,可以关闭和启动Timer用任意键完成。
this document use for new student to study program LPC 2103 , it s writen by vietnamese languge . it show that how to understand about Timer and Interupt in chip LPC2103
Add DAMA slave timeout timer to timer list for Linux v2.13.6.
S32K144定时器驱动,已调试通过,请放心使用
Timer_uCOSI