LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   compilation problem for mtd (https://www.linuxquestions.org/questions/programming-9/compilation-problem-for-mtd-4175491863/)

answerme 01-20-2014 01:44 AM

compilation problem for mtd
 
I have an application for mtd when I cross-compile this application for powerpc compile it properly ,but when I cross-compile it for ARM (pxa300)
It gives error for header file or api's related to MTD for eg

#include <mtd/mtd-user.h>
#include <linux/mtd/mtd.h>

mtd_info_t mtd_info;
erase_info_t ei;

If I am enabling one of these api's or header file I get compilation error .I s there any problem related to cross compiler .I have seen these header files in my linux kernel (mtd-user.h & mtd.h ) THEY EXIST


My application is below with error statement

Code:

#include <stdio.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <mtd/mtd-user.h>
#include <linux/mtd/mtd.h>

int main()
{
    mtd_info_t mtd_info;          // the MTD structure
    erase_info_t ei;              // the erase block structure
    int i;

    unsigned char data[20] = { 0xDE, 0xAD, 0xBE, 0xEF,  // our data to write
                              0xDE, 0xAD, 0xBE, 0xEF,
                              0xDE, 0xAD, 0xBE, 0xEF,
                              0xDE, 0xAD, 0xBE, 0xEF,
                              0xDE, 0xAD, 0xBE, 0xEF};
    unsigned char read_buf[20] = {0x00};                // empty array for reading
    unsigned char data1[2] = {0xAA};       
    int fd = open("/dev/mtd0", O_RDWR); // open the mtd device for reading and
                                        // writing. Note you want mtd0 not mtdblock0
                                        // also you probably need to open permissions
                                        // to the dev (sudo chmod 777 /dev/mtd0)



Code:

ERROR STATEMENT

[root@localhost NOR_FLASH]# make
/usr/local/arm-linux-4.1.1/bin/arm-linux-gcc  -g -o nor nor_example.c
nor_example.c:4:26: error: mtd/mtd-user.h: No such file or directory
make: *** [all] Error 1


NevemTeve 01-20-2014 02:14 AM

When you are cross-compiling, include files don't come from your own /usr/include. Try to look into /usr/<platfromname>/include.


All times are GMT -5. The time now is 10:42 PM.