Re: cross compilation issue
"sudip05@mailcity.com" <zixenus@gmail.com> writes:
[color=blue]
> /*Sorry for cross posting, but as I didnt get in answers, so doing it[/color]
You didn't cross-post, you multi-posted.
Cross-posting is good, muti-posting is bad.
[color=blue]
> I have tried my application, then this is the simplest application,
> which gives a lot of errors...[/color]
Such as?
You should probably read this:
[url]http://catb.org/esr/faqs/smart-questions.html[/url]
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.
[color=blue]
> which I am compiling by $CROSS_COMPILER hello.c.[/color]
And $CROSS_COMPILER is set to ?
Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
Re: cross compilation issue
On May 4, 11:01*pm, Paul Pluzhnikov <ppluzhnikov-...@gmail.com> wrote:[color=blue]
> "sudi...@mailcity.com" <zixe...@gmail.com> writes:[color=green]
> > /*Sorry for cross posting, but as I didnt get in answers, so doing it[/color]
>
> You didn't cross-post, you multi-posted.
> Cross-posting is good, muti-posting is bad.
>[color=green]
> > I have tried my application, then this is the simplest application,
> > which gives a lot of errors...[/color]
>
> Such as?
>
> You should probably read this:[url]http://catb.org/esr/faqs/smart-questions.html[/url]
>
> 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.
>[color=green]
> > which I am compiling by $CROSS_COMPILER hello.c.[/color]
>
> And $CROSS_COMPILER is set to ?[/color]
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[color=blue]
>
> Cheers,
> --
> In order to understand recursion you must first understand recursion.
> Remove /-nsp/ for email.[/color]
Re: cross compilation issue
[email]sudip05@mailcity.com[/email] schrieb:[color=blue]
>
> ohh i am sorry not to mention, but its set to the cross comiler for
> arm9..thought it was obvious..
>[/color]
Well, why? Please describe your complete(!) setup, otherwise we could not
guess what may be missing.
[color=blue]
> 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)
>[/color]
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
Re: cross compilation issue
On May 5, 12:06 pm, Jan Kandziora <j...@gmx.de> wrote:[color=blue]
> sudi...@mailcity.com schrieb:
>[color=green]
> > ohh i am sorry not to mention, but its set to the cross comiler for
> > arm9..thought it was obvious..[/color]
>
> Well, why? Please describe your complete(!) setup, otherwise we could not
> guess what may be missing.
>[color=green]
> > 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)[/color]
>
> 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[/color]
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 <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
#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
Re: cross compilation issue
[email]sudip05@mailcity.com[/email] <zixenus@gmail.com> wrote:[color=blue]
> #include <stdio.h>
> #include <stdlib.h>
> #include <fcntl.h>
> #include <linux/i2c.h>
> #include <linux/i2c-dev.h>
> #define SMBUS 0
> int main()
> {
> int file;
> int adapter_nr = 0;
> char filename[20];
> int reg_addr = 0x10;
> int res;
> char buf[10];[/color]
[color=blue]
> 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);
> }[/color]
[color=blue]
> 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);
> }[/color]
[color=blue]
> #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[/color]
[color=blue]
> /* 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);
> }
> }[/color]
[color=blue]
> 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?[/color]
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 ___ [email]jt@toerring.de[/email]
\__________________________ [url]http://toerring.de[/url]
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
Re: cross compilation issue
[email]sudip05@mailcity.com[/email] <zixenus@gmail.com> wrote:[color=blue]
> 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[/color]
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 ___ [email]jt@toerring.de[/email]
\__________________________ [url]http://toerring.de[/url]