2010-01-13 05:34:04     关于RT—Linux的问题

Document created by Aaronwu Employee on Aug 20, 2013
Version 1Show Document
  • View in full screen mode

2010-01-13 05:34:04     关于RT—Linux的问题

zhang zhihua (CHINA)

Message: 84533   

 

大家好,我的内核是linux2.6版本,我想在上面实现实时进程处理,但是我参照  docs.blackfin.uclinux.org/doku.php?id=linux-kernel:adeos&s[]=rt&s[]=pthread文档做了相关配置,但是我把应用编写完编译的时候提示像

 

宏RT_TASK  task1

 

函数rt_task_create()

 

等未定义,这些应该包含哪些头文件呢?是用bfin-uclinux-gcc这个编译器吗?还是我的编译环境或者Makefile文件有什么不对?

 

请大家帮我参考参考,怎么样才能让我的环境能通过呢,我的Makfile如下:

 

#

#Makefile

#2009-11-12 zhangzhh

#

CC =bfin-uclinux-gcc

#CC=gcc

LDLIBS += -lpthread

 

EXEC=main

OBJS=main.o

 

all:$(EXEC)

$(EXEC):$(OBJS)

 

$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)

 

romfs:

$(ROMFSINST) /BIN/$(EXEC)

 

.PHONY : clean

clean:

rm -f $(EXEC) *.elf *.gdb *.o *.bak *~

TranslateQuoteReplyEditDelete

 

 

2010-01-13 05:38:04     Re: 关于RT—Linux的问题

zhang zhihua (CHINA)

Message: 84534   

 

哦,不好意思,上次问个同样大的问题了...

 

出差忘了看了...

TranslateQuoteReplyEditDelete

 

 

2010-01-13 05:51:49     Re: 关于RT—Linux的问题

Yi Li (CHINA)

Message: 84535   

 

Hi,

 

编好xenomai后,header 和libaray 在 uclinux-dist/staging/usr/include, uclinux-dist/staging/usr/lib下面。

 

-Yi

QuoteReplyEditDelete

 

 

2010-01-13 06:02:46     Re: 关于RT—Linux的问题

zhang zhihua (CHINA)

Message: 84536   

 

Hi,Yi

 

我看到你上次给我回复的了,但是在我的uClinux-dist目录下没有staging目录,是不是我的xenomai没编对吗?

 

是不是就按照:  docs.blackfin.uclinux.org/doku.php?id=linux-kernel:adeos&s[]=rt&s[]=pthread文档上的配置就可以了?

TranslateQuoteReplyEditDelete

 

 

2010-01-13 06:42:01     Re: 关于RT—Linux的问题

zhang zhihua (CHINA)

Message: 84539   

 

而且在usr/include目录也没有native目录...

TranslateQuoteReplyEditDelete

 

 

2010-01-13 19:33:02     Re: 关于RT—Linux的问题

zhang zhihua (CHINA)

Message: 84550   

 

Hi,Yi

 

我重新做了一遍,现在有staging目录了,我试试看

TranslateQuoteReplyEditDelete

 

 

2010-01-13 19:59:43     Re: 关于RT—Linux的问题

zhang zhihua (CHINA)

Message: 84551   

 

Hi,

 

那个头文件怎么包含进去呢?

 

我做了下面这样一个简单程序,但是有问题,您能不能给我发一个简单的例程我参考参考啊?谢谢了...

 

#include<stdio.h>

 

#include<linux/sched.h>

 

#include<sys/types.h>

#include<sys/ioctl.h>

#include</home/uClinux-dist/staging/usr/include/native/task.h>

#include</home/uClinux-dist/staging/usr/include/nucleus/core.h>

#include</home/uClinux-dist/staging/usr/include/nucleus/thread.h>

#include</home/uClinux-dist/staging/usr/include/native/types.h>

 

int main()

{

 

printf("This is a test programe for the RT-Linux!\n");

}

 

但是编译的时候提示:

 

bfin-uclinux-gcc     -c -o main.o main.c

In file included from main.c:15:

/home/uClinux-dist/staging/usr/include/native/task.h:25:26: error: nucleus/core.h: No such file or directory

/home/uClinux-dist/staging/usr/include/native/task.h:26:28: error: nucleus/thread.h: No such file or directory

/home/uClinux-dist/staging/usr/include/native/task.h:27:26: error: native/types.h: No such file or directory

In file included from main.c:15:

/home/uClinux-dist/staging/usr/include/native/task.h:70: error: expected specifier-qualifier-list before ‘xnhandle_t’

/home/uClinux-dist/staging/usr/include/native/task.h:89: error: expected specifier-qualifier-list before ‘RTIME’

/home/uClinux-dist/staging/usr/include/native/task.h:232: error: expected declaration specifiers or ‘...’ before ‘RTIME’

/home/uClinux-dist/staging/usr/include/native/task.h: In function ‘rt_task_unbind’:

/home/uClinux-dist/staging/usr/include/native/task.h:237: error: ‘RT_TASK’ has no member named ‘opaque’

/home/uClinux-dist/staging/usr/include/native/task.h:237: error: ‘XN_NO_HANDLE’ undeclared (first use in this function)

/home/uClinux-dist/staging/usr/include/native/task.h:237: error: (Each undeclared identifier is reported only once

/home/uClinux-dist/staging/usr/include/native/task.h:237: error: for each function it appears in.)

/home/uClinux-dist/staging/usr/include/native/task.h: At top level:

/home/uClinux-dist/staging/usr/include/native/task.h:274: error: expected declaration specifiers or ‘...’ before ‘RTIME’

/home/uClinux-dist/staging/usr/include/native/task.h:275: error: expected declaration specifiers or ‘...’ before ‘RTIME’

/home/uClinux-dist/staging/usr/include/native/task.h:282: error: expected ‘)’ before ‘delay’

/home/uClinux-dist/staging/usr/include/native/task.h:284: error: expected ‘)’ before ‘date’

/home/uClinux-dist/staging/usr/include/native/task.h:292: error: expected declaration specifiers or ‘...’ before ‘rt_sigset_t’

/home/uClinux-dist/staging/usr/include/native/task.h:301: error: expected declaration specifiers or ‘...’ before ‘RTIME’

/home/uClinux-dist/staging/usr/include/native/task.h:306: error: expected declaration specifiers or ‘...’ before ‘RTIME’

/home/uClinux-dist/staging/usr/include/native/task.h:309: error: expected declaration specifiers or ‘...’ before ‘RTIME’

In file included from main.c:18:

/home/uClinux-dist/staging/usr/include/native/types.h:27:27: error: nucleus/types.h: No such file or directory

In file included from main.c:18:

/home/uClinux-dist/staging/usr/include/native/types.h:65: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘rt_sigset_t’

/home/uClinux-dist/staging/usr/include/native/types.h:74: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘rt_isr_t’

/home/uClinux-dist/staging/usr/include/native/types.h:76: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘rt_iack_t’

make: *** [main.o] Error 1

TranslateQuoteReplyEditDelete

 

 

2010-01-13 23:48:58     Re: 关于RT—Linux的问题

Yi Li (CHINA)

Message: 84553   

 

Hi,

 

你可以用类似于这样的Makefile:

 

XENO_PATH = /home/test/uclinux-dist/staging/usr

CC =bfin-uclinux-gcc

CFLAGS = -I$(XENO_PATH)/include

LDFLAGS = -L$(XENO_PATH)/lib -Wl,-elf2flt

LDLIBS += -lpthread

 

EXEC=main

OBJS=main.o

 

all:$(EXEC)

$(EXEC):$(OBJS)

 

$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)

 

 

但是,如果你用posix-skin,你需要在LDFLAGS里添加: -Wl,@$(XENO_PATH)/lib/posix.wrappers,并连接到 libpthread_rt.a.

 

我建议你参考xenomai里面例子的编译过程, xenomai的例子在:2009r1/uclinux-dist/user/xenomai/xenomai-2.4.7/src/testsuite/

 

e.g, under uclinux-dist/, "make > user/xenomai_only > out".

 

关于怎么写Makefile,怎么使用gcc,你可以在网上查资料。

 

-Yi

QuoteReplyEditDelete

 

 

2010-01-14 01:12:48     Re: 关于RT—Linux的问题

zhang zhihua (CHINA)

Message: 84556   

 

thank you!

TranslateQuoteReplyEditDelete

 

 

2010-01-14 04:39:42     Re: 关于RT—Linux的问题

zhang zhihua (CHINA)

Message: 84575   

 

Hi,Yi

 

我编译的时候还是出现了下面的错误,怎么办?:

 

bfin-uclinux-gcc  -I/home/uClinux-dist/staging/usr/include -I/usr/include/   -c -o main.o main.c

bfin-uclinux-gcc  -I/home/uClinux-dist/staging/usr/include -I/usr/include/ -L/home/uClinux-dist/staging/usr/lib -Wl,-elf2flt -o main main.o  -lpthread

main.o: In function `_main':

main.c:(.text+0x78): undefined reference to `_rt_task_create'

collect2: ld returned 1 exit status

make: *** [main] Error 1

 

我编写的下程序如下:

 

#include<stdio.h>

#include<native/task.h>

#include<linux/sched.h>

/**************************************************************************************/

 

int udpserver()

{

return 0;

}

int main()

{

RT_TASK udpserver;

RT_TASK udpclient;

int ret;

ret=rt_task_create(&udpserver,"UDPserver",0,60,0);

printf("This is a test programe for the RT-Linux!\n");

}

 

Makfile是这样的:

 

#***********************************************

XENO_PATH = /home/uClinux-dist/staging/usr

CFLAGS = -I$(XENO_PATH)/include -I/usr/include/

LDFLAGS = -L$(XENO_PATH)/lib -Wl,-elf2flt

#***********************************************

CC =bfin-uclinux-gcc

#CC=gcc

LDLIBS += -lpthread

 

EXEC=main

OBJS=main.o

 

all:$(EXEC)

$(EXEC):$(OBJS)

$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)

 

# $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)

 

romfs:

$(ROMFSINST) /BIN/$(EXEC)

 

.PHONY : clean

clean:

rm -f $(EXEC) *.elf *.gdb *.o *.bak *~

TranslateQuoteReplyEditDelete

 

 

2010-01-14 04:52:44     Re: 关于RT—Linux的问题

Yi Li (CHINA)

Message: 84576   

 

需要 libnative.a。

 

-Yi

QuoteReplyEditDelete

 

 

2010-01-14 05:36:06     Re: 关于RT—Linux的问题

zhang zhihua (CHINA)

Message: 84578   

 

怎么弄呢?

Attachments

    Outcomes