Building simply very simple c/c++ code?

View: New views
3 Messages — Rating Filter:   Alert me  

Building simply very simple c/c++ code?

by Tony_Toulouse :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

Is there any way of compiling a simple helloworld.c using cross compilation (I'm on uBuntu 9.04) and without doing a bitbake? like under linux when doing "gcc hello.c -o hello".

Thanks for your help,

Tony

Re: Building simply very simple c/c++ code?

by Bruce Bernstein :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Sure.   I do it all the time.   The easiest thing to do is put together
a makefile.  The important part is the toolchain definition, for instance:

    TOOLCHAIN=$(OVEROTOP)/tmp/cross/armv7a
    STAGING=$(OVEROTOP)/tmp/staging/armv7a-angstrom-linux-gnueabi/usr
    TOOLDIR=$(TOOLCHAIN)/bin
    CXX=$(TOOLDIR)/arm-angstrom-linux-gnueabi-gcc
    STRIP=$(TOOLDIR)/arm-angstrom-linux-gnueabi-strip
   
    LIBDIR=$(STAGING)/lib
    INCDIR=$(STAGING)/include
   
    LIBS=$(TOOLCHAIN)/arm-angstrom-linux-gnueabi/lib/libstdc++.a -L$(LIBDIR)
    LINK=$(CXX)


My compile rule looks like:
%.o: %.cpp
    $(CXX) $<  -I $(INCDIR) -fno-rtti  -o $@

I build the list of objects (since I have a parameter dirven variable
mix of C and C++ modules), and link with:
$(TARGET) : $(OBJS)
    $(LINK) -o $(TARGET) -Wl $(DEBUG) $(OBJS) $(LIBS)


Obviously, for a simple program you can combine it into a single compile
and link step.   The important part is getting the include path and
library path right.   You have to have done a bitbake once to have
generated the toolchain and staging area, but for simple programs you
don't have to do it again.
Bruce



Tony_Toulouse wrote:

> Hello,
>
> Is there any way of compiling a simple helloworld.c using cross compilation
> (I'm on uBuntu 9.04) and without doing a bitbake? like under linux when
> doing "gcc hello.c -o hello".
>
> Thanks for your help,
>
> Tony
>  


------------------------------------------------------------------------------
_______________________________________________
gumstix-users mailing list
gumstix-users@...
https://lists.sourceforge.net/lists/listinfo/gumstix-users

Re: Building simply very simple c/c++ code?

by Tony_Toulouse :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Two more questions:
- How do I find docs about libraries and even libraries names to use overo interfaces (like GPIOs, UARTs, SPI, I2C; PWM etc...)
- could you point me to any reference or something that helps configuring and using OMAP interrupts for the interfaces listed above?

Thanks again for you help.

Tony

Bruce Bernstein wrote:
Sure.   I do it all the time.   The easiest thing to do is put together
a makefile.  The important part is the toolchain definition, for instance:

    TOOLCHAIN=$(OVEROTOP)/tmp/cross/armv7a
    STAGING=$(OVEROTOP)/tmp/staging/armv7a-angstrom-linux-gnueabi/usr
    TOOLDIR=$(TOOLCHAIN)/bin
    CXX=$(TOOLDIR)/arm-angstrom-linux-gnueabi-gcc
    STRIP=$(TOOLDIR)/arm-angstrom-linux-gnueabi-strip
   
    LIBDIR=$(STAGING)/lib
    INCDIR=$(STAGING)/include
   
    LIBS=$(TOOLCHAIN)/arm-angstrom-linux-gnueabi/lib/libstdc++.a -L$(LIBDIR)
    LINK=$(CXX)


My compile rule looks like:
%.o: %.cpp
    $(CXX) $<  -I $(INCDIR) -fno-rtti  -o $@

I build the list of objects (since I have a parameter dirven variable
mix of C and C++ modules), and link with:
$(TARGET) : $(OBJS)
    $(LINK) -o $(TARGET) -Wl $(DEBUG) $(OBJS) $(LIBS)


Obviously, for a simple program you can combine it into a single compile
and link step.   The important part is getting the include path and
library path right.   You have to have done a bitbake once to have
generated the toolchain and staging area, but for simple programs you
don't have to do it again.
Bruce



Tony_Toulouse wrote:
> Hello,
>
> Is there any way of compiling a simple helloworld.c using cross compilation
> (I'm on uBuntu 9.04) and without doing a bitbake? like under linux when
> doing "gcc hello.c -o hello".
>
> Thanks for your help,
>
> Tony
>  


------------------------------------------------------------------------------
_______________________________________________
gumstix-users mailing list
gumstix-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gumstix-users