cross compilation issue - Linux

This is a discussion on cross compilation issue - Linux ; /*Sorry for cross posting, but as I didnt get in answers, so doing it here..i apologise for the inconvenience, but pls reply if someone is aware of this stuff...am badly stuck*/ Hi Everybody, am facing a problem in cross compiling ...

+ Reply to Thread
Results 1 to 8 of 8

Thread: cross compilation issue

  1. cross compilation issue

    /*Sorry for cross posting, but as I didnt get in answers, so doing it
    here..i apologise for the inconvenience, but pls reply if someone is
    aware of this stuff...am badly stuck*/
    Hi Everybody,
    am facing a problem in cross compiling for arm9. I
    have the toolchain installed, the hello world program builds fine, but
    when I add headers linux/i2c.h and linux/i2c-dev.h, i get a hell of
    errors. I think I am missing out something here, can somebody point it
    out?

    I have tried my application, then this is the simplest application,
    which gives a lot of errors...

    #include
    #include
    #include

    main()
    {
    return 0;

    }

    which I am compiling by $CROSS_COMPILER hello.c.

    Thanks and Regards,
    Sudip

  2. Re: cross compilation issue

    "sudip05@mailcity.com" writes:

    > /*Sorry for cross posting, but as I didnt get in answers, so doing it


    You didn't cross-post, you multi-posted.
    Cross-posting is good, muti-posting is bad.

    > I have tried my application, then this is the simplest application,
    > which gives a lot of errors...


    Such as?

    You should probably read this:
    http://catb.org/esr/faqs/smart-questions.html

    It might explain why you didn't get any responses first time around,
    and are unlikely to get any useful responses the second time either.

    > which I am compiling by $CROSS_COMPILER hello.c.


    And $CROSS_COMPILER is set to ?

    Cheers,
    --
    In order to understand recursion you must first understand recursion.
    Remove /-nsp/ for email.

  3. Re: cross compilation issue

    On May 4, 11:01*pm, Paul Pluzhnikov wrote:
    > "sudi...@mailcity.com" writes:
    > > /*Sorry for cross posting, but as I didnt get in answers, so doing it

    >
    > You didn't cross-post, you multi-posted.
    > Cross-posting is good, muti-posting is bad.
    >
    > > I have tried my application, then this is the simplest application,
    > > which gives a lot of errors...

    >
    > Such as?
    >
    > You should probably read this:http://catb.org/esr/faqs/smart-questions.html
    >
    > It might explain why you didn't get any responses first time around,
    > and are unlikely to get any useful responses the second time either.
    >
    > > which I am compiling by $CROSS_COMPILER hello.c.

    >
    > And $CROSS_COMPILER is set to ?


    ohh i am sorry not to mention, but its set to the cross comiler for
    arm9..thought it was obvious..is there anything apart from just using
    the cross compiler?Do i need to pass any extra params, like -I(include
    directories for cross compiler) or -l(librarries)

    Thanks
    >
    > Cheers,
    > --
    > In order to understand recursion you must first understand recursion.
    > Remove /-nsp/ for email.



  4. Re: cross compilation issue

    sudip05@mailcity.com schrieb:
    >
    > ohh i am sorry not to mention, but its set to the cross comiler for
    > arm9..thought it was obvious..
    >

    Well, why? Please describe your complete(!) setup, otherwise we could not
    guess what may be missing.


    > is there anything apart from just using
    > the cross compiler?Do i need to pass any extra params, like -I(include
    > directories for cross compiler) or -l(librarries)
    >

    Depends on your setup. If the cross compiler is inside a chroot, probably
    not. If the cross compiler itself was compiled with other include and
    library paths as default, probably not.

    The usual way to set this up is a *makefile*. Much clearer to understand
    than handling with a crosscompiler shell skript like you do. Last time I
    saw the latter, it was when an apprentice programmer left alone his beloved
    (Borland C) IDE because it didn't run on Linux, and so he was left without
    a clue. He came up with shell skripting, because he didn't know any better.
    (No, it wasn't me, I made this mistake years before... ^___^)


    A makefile primer for you:
    ------------------------------------------
    ..PHONY: all clean

    CC=cross_compiler_binary
    LINKER=cross_compiler_binary
    CPPFLAGS+=-Icross_compiler_include_path
    LINKER_FLAGS+=-Lcross_compiler_library_path

    all: hello
    clean:
    -rm *.o hello

    hello.o: hello.c
    $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<

    hello: hello.o
    $(LINKER) $(LINKER_FLAGS) -o $@ $^
    ------------------------------------------
    That could be shortened using implicit rules, but that's not the way
    somebody should start. Important note on makefiles: TABs on the beginning
    of lines must never be replaced by spaces!

    Now all you have to do is placing this file named as "Makefile" inside the
    source directory, then run "make". Read the info page on make to get more
    information on make.


    Kind regards

    Jan

  5. Re: cross compilation issue

    On May 5, 12:06 pm, Jan Kandziora wrote:
    > sudi...@mailcity.com schrieb:
    >
    > > ohh i am sorry not to mention, but its set to the cross comiler for
    > > arm9..thought it was obvious..

    >
    > Well, why? Please describe your complete(!) setup, otherwise we could not
    > guess what may be missing.
    >
    > > is there anything apart from just using
    > > the cross compiler?Do i need to pass any extra params, like -I(include
    > > directories for cross compiler) or -l(librarries)

    >
    > Depends on your setup. If the cross compiler is inside a chroot, probably
    > not. If the cross compiler itself was compiled with other include and
    > library paths as default, probably not.
    >
    > The usual way to set this up is a *makefile*. Much clearer to understand
    > than handling with a crosscompiler shell skript like you do. Last time I
    > saw the latter, it was when an apprentice programmer left alone his beloved
    > (Borland C) IDE because it didn't run on Linux, and so he was left without
    > a clue. He came up with shell skripting, because he didn't know any better.
    > (No, it wasn't me, I made this mistake years before... ^___^)
    >
    > A makefile primer for you:
    > ------------------------------------------
    > .PHONY: all clean
    >
    > CC=cross_compiler_binary
    > LINKER=cross_compiler_binary
    > CPPFLAGS+=-Icross_compiler_include_path
    > LINKER_FLAGS+=-Lcross_compiler_library_path
    >
    > all: hello
    > clean:
    > -rm *.o hello
    >
    > hello.o: hello.c
    > $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
    >
    > hello: hello.o
    > $(LINKER) $(LINKER_FLAGS) -o $@ $^
    > ------------------------------------------
    > That could be shortened using implicit rules, but that's not the way
    > somebody should start. Important note on makefiles: TABs on the beginning
    > of lines must never be replaced by spaces!
    >
    > Now all you have to do is placing this file named as "Makefile" inside the
    > source directory, then run "make". Read the info page on make to get more
    > information on make.
    >
    > Kind regards
    >
    > Jan





    Hi Jan,
    thanks a lot for ur help....btw, am giving all the info in the
    command line. Actually, I have to call the i2c specific routines for
    this architecture. So, I have the application like this:

    #include
    #include
    #include
    #include
    #include
    #define SMBUS 0
    int main()
    {
    int file;
    int adapter_nr = 0;
    char filename[20];
    int reg_addr = 0x10;
    int res;
    char buf[10];

    sprintf(filename,"/dev/i2c-%d",adapter_nr);
    if ((file = open(filename,O_RDWR)) < 0) {
    /* ERROR HANDLING; you can check errno to see what went wrong */
    exit(1);
    }

    int addr = 0xA0; /* The I2C address */
    if (ioctl(file,I2C_SLAVE,addr) < 0) {
    /* ERROR HANDLING; you can check errno to see what went wrong */
    exit(1);
    }

    #ifdef SMBUS
    /* Using SMBus commands */
    res = i2c_smbus_read_word_data(file,reg_addr);
    }
    #else
    buf[0] = reg_addr;
    buf[1] = 0x43;
    buf[2] = 0x65;
    if ( write(file,buf,3) != 3) {
    printf("Write word failed");
    }
    #endif

    /* Using I2C Read, equivalent of i2c_smbus_read_byte(file) */
    if (read(file,buf,1) != 1) {
    printf("Read failed");
    }
    else {
    printf("Data read: %s\n", buf);
    }
    }


    I am getting the same errors with the Makefile also. :-(. If I use
    normal gcc, I get undefined reference to `i2c_smbus_read_word_data',
    which is valid as its not declared in /usr/include/linux/i2c.h, but
    its there in cross compiler header included file. How to do the proper
    setup so that it takes from cross compiler path?


    Thanks n Regards,
    Sudip

  6. Re: cross compilation issue

    sudip05@mailcity.com wrote:
    > #include
    > #include
    > #include
    > #include
    > #include
    > #define SMBUS 0
    > int main()
    > {
    > int file;
    > int adapter_nr = 0;
    > char filename[20];
    > int reg_addr = 0x10;
    > int res;
    > char buf[10];


    > sprintf(filename,"/dev/i2c-%d",adapter_nr);
    > if ((file = open(filename,O_RDWR)) < 0) {
    > /* ERROR HANDLING; you can check errno to see what went wrong */
    > exit(1);
    > }


    > int addr = 0xA0; /* The I2C address */
    > if (ioctl(file,I2C_SLAVE,addr) < 0) {
    > /* ERROR HANDLING; you can check errno to see what went wrong */
    > exit(1);
    > }


    > #ifdef SMBUS
    > /* Using SMBus commands */
    > res = i2c_smbus_read_word_data(file,reg_addr);
    > }
    > #else
    > buf[0] = reg_addr;
    > buf[1] = 0x43;
    > buf[2] = 0x65;
    > if ( write(file,buf,3) != 3) {
    > printf("Write word failed");
    > }
    > #endif


    > /* Using I2C Read, equivalent of i2c_smbus_read_byte(file) */
    > if (read(file,buf,1) != 1) {
    > printf("Read failed");
    > }
    > else {
    > printf("Data read: %s\n", buf);
    > }
    > }


    > I am getting the same errors with the Makefile also. :-(. If I use
    > normal gcc, I get undefined reference to `i2c_smbus_read_word_data',
    > which is valid as its not declared in /usr/include/linux/i2c.h, but
    > its there in cross compiler header included file. How to do the proper
    > setup so that it takes from cross compiler path?


    The i2c_smbus_read_word_data() function looks very much like
    a function from the kernel. And if that's true you can't use
    it from a normal program since there's no library that would
    contain it. It then can only be used by kernel modules.

    Regards, Jens
    --
    \ Jens Thoms Toerring ___ jt@toerring.de
    \__________________________ http://toerring.de

  7. Re: cross compilation issue

    ok, thanks a lot for that info..I was trying to figure which library
    has got it, now I wil try to use it in module..will let know the
    status

    Thanks n Regards,
    Sudip

  8. Re: cross compilation issue

    sudip05@mailcity.com wrote:
    > ok, thanks a lot for that info..I was trying to figure which library
    > has got it, now I wil try to use it in module..will let know the
    > status


    Well, take it with a grain of salt. I just said that the function
    looks suspiciously like it's from the I2C driver in the kernel (at
    least there is such a function of that name) but, of course, there
    could be some library that also defines a function with that name.
    But then it would have to appear in a header file for that library
    and you shouldn't include a kernel header that also declares it...

    Best regards, Jens
    --
    \ Jens Thoms Toerring ___ jt@toerring.de
    \__________________________ http://toerring.de

+ Reply to Thread