Hello, Sergio.

I hadn't done that yet.
But I tried now just the way you said and my error message remains:

"gcc: cannot specify -o with -c or -S with multiple files
make: *** [sim-exe] Error 1"

Thank you once again for your help! :)

Best regards,
Pedro Nunes

On Thu, Jan 13, 2011 at 5:14 PM, Sergio Valcarcel <[email protected]>wrote:

> I imagined that you probably knew the link :-)
> But as you wrote LDFLAGS instead of PFLAGS I insisted.
>
> Anyway, it is weird... it works fine for me.
>
> My guess is that there could be anything wrong with the linker and my
> five cents would be to only include this 3 lines in the Makefile :
> > COMPONENT=FloodingC
> > include $(MAKERULES)
> > PFLAGS += path_to_C_source/source.c
>
> Did you modify your Makefile in such a way? I mean, removing all
> LDFLAGS and everything else and just keeping this 3 lines, and nothing
> else?
>
>
>
>
>
>
> On Thu, Jan 13, 2011 at 5:57 PM, Pedro Nunes <[email protected]> wrote:
> > Hello Sergio.
> > First of all, thank you for your help. However, I did also checked that
> > thread and tried it. It didn't work.
> > I think I'll just port my C functions to a nesC component.
> > Thank you anyway.
> > Regards,
> > Pedro Nunes
> >
> > On Wed, Jan 12, 2011 at 10:30 AM, Sergio Valcarcel <[email protected]
> >
> > wrote:
> >>
> >> Hi Pedro,
> >>
> >> in another mail-thread there are explained two ways of calling C
> >> functions from a nesC application. Check this:
> >>
> >>
> http://www.mail-archive.com/[email protected]/msg35149.html
> >>
> >> The quick & dirty way is embedding the C function into the nesC file.
> >> I did it and works properly, but since it is not very flexible nor
> >> scalable I moved to the second option.
> >>
> >> The second option means to declare the function in a header file
> >> "source.h" and to indicate that the "source.c" file must be compiled
> >> into the Makefile as "PFLAGS+=path/to/source.c".
> >>
> >> In your case, I would remove the LDFLAGS and just try this Makefile:
> >>
> >> "
> >> COMPONENT=FloodingC
> >> include $(MAKERULES)
> >>
> >> PFLAGS += path_to_C_source/source.c
> >> "
> >>
> >> I hope it helps!
> >> Cheers!
> >> Sergio
> >>
> >>
> >>
> >>
> >> On Wed, Jan 12, 2011 at 5:57 AM, Pedro Nunes <[email protected]>
> wrote:
> >> > Hi all.
> >> > I'm also trying to use a C function inside my nesC application but
> >> > there's a
> >> > problem I can't solve.
> >> > I edit the Makefile like David said:
> >> > ------------------
> >> > COMPONENT=FloodingC
> >> > include $(MAKERULES)
> >> > LDFLAGS=/opt/tinyos-2.1.1/tos/system/sha1.o
> >> > /opt/tinyos-2.1.1/tos/system/sha1.c:
> /opt/tinyos-2.1.1/tos/system/sha1.h
> >> > $(CC) -o /opt/tinyos-2.1.1/tos/system/sha1.o
> >> > /opt/tinyos-2.1.1/tos/system/sha1.c
> >> > ------------------
> >> > But whenever I try to build my application I always get this warning:
> >> > "gcc: /opt/tinyos-2.1.1/tos/system/sha1.o: linker input file unused
> >> > because
> >> > linking not done"
> >> > I know this is happening because when I compiled sha1 I did "gcc -c
> >> > sha1.c"
> >> > since sha1.c doesn't have a main function. But that's the purpose of
> it.
> >> > I
> >> > don't want to run it as a stand-alone program. I just want to use it
> as
> >> > a
> >> > library.
> >> > This warning will later lead me to this when running my simulation:
> >> > ------------------
> >> > Traceback (most recent call last):
> >> >   File "simulation.py", line 3, in <module>
> >> >     from TOSSIM import *
> >> >   File ".../Flooding/src/TOSSIM.py", line 7, in <module>
> >> >     import _TOSSIM
> >> > ImportError: .../Flooding/src/_TOSSIMmodule.so: undefined symbol:
> >> > SHA1Input
> >> > ------------------
> >> > Does anyone know a way to fix this?
> >> > Thank you in advance.
> >> > Regards,
> >> > Pedro Nunes
> >> >
> >> >>OK! now it works, but only in simulation!!!
> >> >>I tried to edit my makefile but without success!
> >> >>How can I solve this problem?
> >> >>Thank you!
> >> >>2008/1/31, AIGroup <[EMAIL PROTECTED]>:
> >> >>>
> >> >>> Hi David,
> >> >>>
> >> >>> before all thank you for your help.
> >> >>> I tried to edit my files as you wrote, but I yet have problems.
> >> >>> I edited my nesc file as follows:
> >> >>> -----
> >> >>> #include "Timer.h"
> >> >>> #include "Hello.h" //<------ I included the header file here
> >> >>>
> >> >>> module BlinkC
> >> >>> {
> >> >>>   uses interface Timer<TMilli> as Timer0;
> >> >>>   uses interface Timer<TMilli> as Timer1;
> >> >>>   uses interface Timer<TMilli> as Timer2;
> >> >>>   uses interface Leds;
> >> >>>   uses interface Boot;
> >> >>> }
> >> >>> implementation
> >> >>> {
> >> >>>   event void Boot.booted()
> >> >>>   {
> >> >>>     call Timer0.startPeriodic( 250 );
> >> >>>     call Timer1.startPeriodic( 500 );
> >> >>>     call Timer2.startPeriodic( 1000 );
> >> >>>   }
> >> >>>
> >> >>>   event void Timer0.fired()
> >> >>>   {
> >> >>>      Hello();         //<-------------This is the function call to
> >> >>> Hello()
> >> >>>      //dbg("BlinkC", "Timer 0 fired @ %s.\n", sim_time_string());
> >> >>>     //call Leds.led0Toggle();
> >> >>>   }
> >> >>>
> >> >>> --------
> >> >>> The C files are these:
> >> >>> -----------
> >> >>> //Hello.h
> >> >>> #ifndef HELLO_H
> >> >>> #define HELLO_H
> >> >>>
> >> >>> void Hello();
> >> >>>
> >> >>> #endif
> >> >>> ---------
> >> >>> #include "Hello.h"
> >> >>>
> >> >>> void Hello()
> >> >>> {
> >> >>>     printf("\nHELLO!\n");
> >> >>> }
> >> >>> -------------
> >> >>> and my Makefile is the following:
> >> >>> COMPONENT=BlinkAppC
> >> >>> LDFLAGS = Hello.o
> >> >>> Hello.c: Hello.h
> >> >>>     $(CC) -o Hello.o Hello.c
> >> >>> include $(MAKERULES)
> >> >>> ---
> >> >>> where $(CC)... is "tabbed"
> >> >>> So, when I run "make micaz sim" this error occurs:
> >> >>> ---------
> >> >>> [EMAIL PROTECTED]:/opt/tinyos-2.x/apps/ImportC$ make micaz sim
> >> >>> mkdir -p build/micaz
> >> >>>   placing object files in build/micaz
> >> >>>   writing XML schema to app.xml
> >> >>>   compiling BlinkAppC to object file sim.o
> >> >>> ncc -c -shared -fPIC -o build/micaz/sim.o -g -O0 -tossim
> >> >>> -fnesc-nido-tosnodes=1000 -fnesc-simulate
> >> >>> -fnesc-nido-motenumber=sim_node\(\)   -finline-limit=100000 -Wall
> >> >>> -Wshadow
> >> >>> -Wnesc-all -target=micaz -fnesc-cfile=build/micaz/app.c
> -board=micasb
> >> >>> -DIDENT_PROGRAM_NAME=\"BlinkAppC\" -DIDENT_USER_ID=\"penguin\"
> >> >>> -DIDENT_HOSTNAME=\"penguin-laptop\" -DIDENT_USER_HASH=0xdef7cfbeL
> >> >>> -DIDENT_UNIX_TIME=0x47a18a21L -DIDENT_UID_HASH=0x77ab7dfaL
> >> >>> -Wno-nesc-data-race BlinkAppC.nc Hello.o  -fnesc-dump=components
> >> >>> -fnesc-dump=variables -fnesc-dump=constants -fnesc-dump=typedefs
> >> >>> -fnesc-dump=interfacedefs -fnesc-dump=tags -fnesc-dumpfile=app.xml
> >> >>> gcc: Hello.o: No such file or directory
> >> >>> make: *** [sim-exe] Error 1
> >> >>> -----
> >> >>> How can I solve the problem???
> >> >>> Thank you very much in advance for your precious help
> >> >>> Regards,
> >> >>>
> >> >>> Roberto
> >> >>>
> >> >>>
> >> >>> 2008/1/30, David Gay <[EMAIL PROTECTED]>:
> >> >>> >
> >> >>> > #include works fine, but, as in C, it's just textual inclusion (it
> >> >>> > really is nothing complicated ;-)). So it's all as if you just
> >> >>> > wrote:
> >> >>> >
> >> >>> > module ...
> >> >>> > implementation
> >> >>> > {
> >> >>> > #ifndef C_CODE
> >> >>> > #define C_CODE
> >> >>> >
> >> >>> > void Hello();
> >> >>> >
> >> >>> > #endif
> >> >>> >
> >> >>> >     event void Boot.booted()
> >> >>> >     {
> >> >>> >         call Timer0.startPeriodic( 250 );
> >> >>> >     }
> >> >>> >
> >> >>> >     event void Timer0.fired()
> >> >>> >     {
> >> >>> >         Hello(); //Hello() is a function which is inside my C code
> >> >>> >     }
> >> >>> > }
> >> >>> >
> >> >>> > which therefore just declares Hello() as an internal function
> inside
> >> >>> > BlinkC.
> >> >>> >
> >> >>> > In nesC, C functions must be declared before the
> >> >>> > module/implementation
> >> >>> > (or interface) part of a file. So what you wanted to do was:
> >> >>> > /* nesC code*/
> >> >>> > #include "c_code.h"
> >> >>> > module ...
> >> >>> > implementation
> >> >>> > {
> >> >>> >
> >> >>> >     event void Boot.booted()
> >> >>> >     {
> >> >>> >         call Timer0.startPeriodic( 250 );
> >> >>> >     }
> >> >>> >
> >> >>> >     event void Timer0.fired()
> >> >>> >     {
> >> >>> >         Hello(); //Hello() is a function which is inside my C code
> >> >>> >     }
> >> >>> > }
> >> >>> >
> >> >>> > On Jan 30, 2008 6:37 AM, AIGroup <[EMAIL PROTECTED]> wrote:
> >> >>> > > I believed...
> >> >>> > > include directive works well. I have problem to edit the
> Makefile
> >> >>> > > in
> >> >>> > order
> >> >>> > > to compile also the C file.
> >> >>> >
> >> >>> > Yes, you then also of course need to compile and link with your C
> >> >>> > code. Several ways to do that... The easiest in this case at least
> >> >>> > is
> >> >>> > probably to add
> >> >>> >   LDFLAGS = c_code.c
> >> >>> > to your Makefile, which should cause ncc to compile and link
> >> >>> > c_code.c
> >> >>> > with your nesC app. A slightly more traditional Makefile approach
> >> >>> > would have you add
> >> >>> >
> >> >>> >   LDFLAGS = c_code.o
> >> >>> >   c_code.c: c_code.h
> >> >>> >       $(CC) -o c_code.o <your favourite flags> c_code.c
> >> >>> >
> >> >>> > to your Makefile... (don't cut & paste the text above, the
> character
> >> >>> > before $(CC) needs to be a tab to keep make happy, in this email
> >> >>> > it's
> >> >>> > some spaces...)
> >> >>> >
> >> >>> > David Gay
> >> >>> >
> >> >>> >
> >> >>> > >
> >> >>> > >
> >> >>> > > 2008/1/30, AIGroup <[EMAIL PROTECTED]>:
> >> >>> > >
> >> >>> > > > Hi all.
> >> >>> > > > I would like to include some routines in my nesC code as
> follows
> >> >>> > > (considering the BlinkApp for example):
> >> >>> > > > /* nesC code*/
> >> >>> > > > implementation
> >> >>> > > > {
> >> >>> > > >      #include "c_code.h"
> >> >>> > > >
> >> >>> > > >     event void Boot.booted()
> >> >>> > > >     {
> >> >>> > > >         call Timer0.startPeriodic( 250 );
> >> >>> > > >     }
> >> >>> > > >
> >> >>> > > >     event void Timer0.fired()
> >> >>> > > >     {
> >> >>> > > >         Hello(); //Hello() is a function which is inside my C
> >> >>> > > > code
> >> >>> > > >     }
> >> >>> > > > }
> >> >>> > > > -------------------------
> >> >>> > > > /*C code*/
> >> >>> > > > /*c_code.h*/
> >> >>> > > >
> >> >>> > > > #ifndef C_CODE
> >> >>> > > > #define C_CODE
> >> >>> > > >
> >> >>> > > > void Hello();
> >> >>> > > >
> >> >>> > > > #endif
> >> >>> > > >
> >> >>> > > > ---------------
> >> >>> > > > /* c_code.c */
> >> >>> > > >
> >> >>> > > > #include "c_code.h"
> >> >>> > > >
> >> >>> > > > void Hello()
> >> >>> > > > {
> >> >>> > > >    printf("HELLO!\n")
> >> >>> > > > }
> >> >>> > > > ---------------
> >> >>> > > > Compilation terminate with success, but if i try to execute a
> >> >>> > simulation,
> >> >>> > > this following error occurs:
> >> >>> > > > undefined symbol: BlinkC$Hello
> >> >>> > > > How can I solve this problem?
> >> >>> > > > Thank you very much for your help!
> >> >>> > > >
> >> >>> > > >
> >> >>> > > >
> >> >>> > > >
> >> >>> > >
> >> >>> > >
> >> >>> > > _______________________________________________
> >> >>> > > Tinyos-help mailing list
> >> >>> > > [email protected]
> >> >>> > >
> >> >>> >
> >> >>> >
> >> >>> >
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
> >> >>> > >
> >> >>> >
> >> >>>
> >> >>>
> >> > _______________________________________________
> >> > Tinyos-help mailing list
> >> > [email protected]
> >> >
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
> >> >
> >
> >
>
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to