This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Simple compile




Sergei Gavrikov-4 wrote:
> 
> On Wed, Apr 08, 2009 at 12:21:27AM -0700, grahamlab wrote:
>> 
>> Hello everyone
>> I am new to ecos and am trying to compile a simple program that uses the
>> sleep function
>> My code include <unistd.h> but when I compile i get this error
>> 
>> hello.cpp:34: error: âsleepâ was not declared in this scope
>> 
>> I am compiling using the following command
>> 
>> arm-eabi-g++ -c -I ../DevBoardFast_install/include/ -I
>> /opt/ecos/ecos-3.0/packages/isoinfra/v3_0/include/  -Wall -Wpointer-arith
>> -Wstrict-prototypes -Wundef -Woverloaded-virtual -Wno-write-strings
>> -mcpu=cortex-m3 -mthumb -g -O2 -ffunction-sections -fdata-sections
>> -fno-rtti
>> -fno-exceptions  hello.cpp
>> 
>> The code looks like this
>> 
>> #include <unistd.h>
>> #include <stdio.h>
>> 
>> int main(int argc, char** argv)
>> {
>>     sleep(10);
>>     printf("Hello main\n");
>> }
>> 
>> Please tell me why this does not compile
>> 
>> Thanks
>> 
>> Graham
> 
> Graham,
> 
> To have sleep() you have to add posix package to default template. Do
> you really need in the bloat posix stuff? The eCos has own "sleep" --
> cyg_thread_delay(). Please, start to read eCos documentation. So, a
> solution is
> 
> ecosconfig add posix
> 
> IMHO, you have to prepare a good Makefile to play with eCos. Why do you
> use C++ ?!. There are good examples under eCos `examples' directory. Try
> the examples, first. Those build_Makefile, build_Make.params are nice
> script-helpers to get a test farm. build_Make.params is most important
> then. It rebuilds actual GCC flags for project. Every time when you
> rebuild eCos, run build_Make.params (U.T.S.L.) in a project directory.
> 
> Just a demo about that eCos can do all for you
> 
> i. build eCos
> 
> ecosconfig new stm3210e
> ecosconfig add posix
> ecosconfig tree
> make -s
> 
> ii. Stand up a test farm
> 
> mkdir test
> cd test
> cp $ECOS_REPOSITORY/../examples/build_Make.params .
> DST=test SRCS=test.c $ECOS_REPOSITORY/../examples/build_Makefile ..
> echo -ne 'clean:\n\trm -f test.o test\n' >> Makefile
> 
> cat >test.c<<EOF
> #include <stdio.h>
> #include <unistd.h>
> 
> int
> main(void)
> {
>     sleep(10);
>     printf("Test done\n");
>     return 0;
> }
> EOF
> 
> make -s
> 
> I've got
> 
> ls
> Makefile  Make.params  test  test.c  test.o
> 
> And there is sleep there
> 
> arm-eabi-nm test | grep sleep
> 68009d98 T _ZN10Cyg_Thread5sleepEv
> 6800c2a4 T nanosleep
> 6800c358 T sleep
> 
> But, eCos source can look as (no need posix package to compile it)
> 
> #include <stdio.h>
> #include <cyg/kernel/kapi.h>
> 
> int
> main(void)
> {
>     while (true) {
> 	cyg_thread_delay(100);
> 	printf("I'm still alive\n");
>     }
>     return 0;
> }
> 
> 
> This week read these manuals:
> http://ecos.sourceware.org/docs.html
> 
> 
> Sergei
> 
> -- 
> Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
> and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
> 
> 
> 
Hi Sergei
Thanks for the advice and for taking the time
I have build the test environment as you said and it all works perfectly.
I was wondering if I can do somethin similar using the config tool, but it
appears not as the filenames do no match up to those expected by
build_make.params and build_makefile. The config tool does not produce a
makefile either.

Graham
-- 
View this message in context: http://www.nabble.com/Simple-compile-tp22944738p22948006.html
Sent from the Sourceware - ecos-discuss mailing list archive at Nabble.com.


--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]