[beagleboard] can't find the header files.

Hi Kiran, If you could post your simple program, I would be willing to see if anything stands out. Regards, Jack.

ok…this is the program i used…

#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

FILE *fp;

int main(int argc, char** argv)
{

printf("\n**********************************\n"
“* Welcome to PIN Blink program \n"
"
…blinking pin 3 on port B \n"
"
…rate of 1 Hz… \n"
"
*********************************\n”);

//create a variable to store whether we are sending a ‘1’ or a ‘0’
char set_value[4];
//Integer to keep track of whether we want on or off
int toggle = 0;

//Using sysfs we need to write “37” to /sys/class/gpio/export
//This will create the folder /sys/class/gpio/gpio37
if ((fp = fopen("/sys/class/gpio/export", “ab”)) == NULL)
{
printf(“Cannot open export file.\n”);
exit(1);
}
//Set pointer to begining of the file
rewind(fp);
//Write our value of “37” to the file
strcpy(set_value,“37”);
fwrite(&set_value, sizeof(char), 2, fp);
fclose(fp);

printf("…export file accessed, new pin now accessible\n");

//SET DIRECTION
//Open the LED’s sysfs file in binary for reading and writing, store file pointer in fp
if ((fp = fopen("/sys/class/gpio/gpio37/direction", “rb+”)) == NULL)
{
printf(“Cannot open direction file.\n”);
exit(1);
}
//Set pointer to begining of the file
rewind(fp);
//Write our value of “out” to the file
strcpy(set_value,“out”);
fwrite(&set_value, sizeof(char), 3, fp);
fclose(fp);
printf("…direction set to output\n");

//SET VALUE
//Open the LED’s sysfs file in binary for reading and writing, store file pointer in fp
if ((fp = fopen("/sys/class/gpio/gpio37/value", “rb+”)) == NULL)
{
printf(“Cannot open value file.\n”);
exit(1);
}
//Set pointer to begining of the file
rewind(fp);
//Write our value of “1” to the file
strcpy(set_value,“1”);
fwrite(&set_value, sizeof(char), 1, fp);
fclose(fp);
printf("…value set to 1…\n");

//Run an infinite loop - will require Ctrl-C to exit this program
while(1)
{
//Set it so we know the starting value in case something above doesn’t leave it as 1
strcpy(set_value,“1”);

if ((fp = fopen("/sys/class/gpio/gpio37/value", “rb+”)) == NULL)
{
printf(“Cannot open value file.\n”);
exit(1);
}
toggle = !toggle;
if(toggle)
{
//Set pointer to begining of the file
rewind(fp);
//Write our value of “1” to the file
strcpy(set_value,“1”);
fwrite(&set_value, sizeof(char), 1, fp);
fclose(fp);
printf("…value set to 1…\n");
}
else
{
//Set pointer to begining of the file
rewind(fp);
//Write our value of “0” to the file
strcpy(set_value,“0”);
fwrite(&set_value, sizeof(char), 1, fp);
fclose(fp);
printf("…value set to 0…\n");
}
//Pause for one second
sleep(1);
}
return 0;
}

Heloooo…anyone please help…:frowning:

Are you trying to compile them on your host or on the BB itself? Try just using ‘gcc’ instead of ‘arm-angstrom-linux-gnueabi-gcc’ if you’re doing it on the BB.

-Jon

I’m compiling it on my BB. I compiled it on my host system running ubuntu using gcc and it worked fine. Using gcc in BB gives me an error saying gcc not found.

Did you try ’ opkg install task-native-sdk '?

ok I finally tried using a cross compiler. Installed the toolchain on my ubuntu host and using eclipse and all other steps involved I compiled a program and got the executable file. I copied this file with the folder involved and tried to run the file using ./filename. This time however i didnt get an eroor saying headers were not found but rather a single error which says… line 1: syntax error :"(" unexpected. What now!!!

Jason,
Hi, my bad…it seems I didn’t run opkg install task-native-sdk before…I ran it again just to make sure and voila! the header files are now in usr/include. This time when I try compiling the program i get another error…
/usr/lib/gcc/arm-angstrom-linux-gnueabi/4.3.3/…/…/…/…/arm-angstrom-linux-gnueabi/bin/ld: cannot find -lgcc_s
collect2: ld returned 1 exit status
the error seems to be similar when i tried using gcc, cpp,etc., instead of arm-angstrom-linux-gnueabi-gcc such that the “cannot find -lgcc_s” is substituted by other file names. What is wrong now…??

Did you figure this out? I’m running into the same problem and have racked my brain trying to figure it out.

Thanks!
Andrew

Never mind on my post above. I found that linking /lib/libgcc_s.so.1 to /usr/lib (ln -s /lib/libgcc_s.so.1 /usr/lib/libgcc_s.so) fixed the problem I was having.

Andrew