Image tutorial have issue?

yeah, I think so
here’s the example code:

int main () {
   FILE *fp;
   int c;
  
   fp = fopen("file.txt","r");
   while(1) {
      c = fgetc(fp);
      if( feof(fp) ) { 
         break ;
      }
      printf("%c", c);
   }
   fclose(fp);
   
   return(0);
}

ABout running fail in codeblock, I think it’s a codeblocks running environment issue

Then is should return ‘0’. But it was Process returned -1073741819 (0xC0000005) execution time : 1.873 s

But it works well in command line, that prove it’s not a fopen issue.

That is an “access violation” in Windows AFAIK (i.e. segfault).

Yeah, something is wrong, but I believe it’s not a fopen issue,

Remember that you have to check the working directory of the CodeBlocks project. By default I think it’s the Debug folder.

Your code doesn’t bother to check whether fp is valid (i.e. if the file existed) so that’s probably why it crashes in CodeBlocks.

Yeah, both the exmaple and lvgl exe files are in debug folders, and there are where I put the txt/bin files

fp should be valid, or it should fail in command line way too

I think of a reason, CodeBlocks crash because it’s calling the program from another folder.
In command way, I’m in the debug folder to run the program

Right, that’s what I meant. Just because the program is located in a folder doesn’t mean that that is the working directory.

It’s generally a better idea to have a check in place for that rather than assuming that it will always be valid.

Tried to run command line in another folder, crashed as CodeBlock do, so the reason confirmed,

1 Like

Sure, I didn’t do that because don’t know how, just copied the example.

The problem is, when I try lvgl in command line, I’m in it’s debug folder but it still don’t work

Look the pcfs_open:

static lv_fs_res_t pcfs_open(lv_fs_drv_t * drv, void * file_p, const char * fn, lv_fs_mode_t mode)

There’s a parameter called drv, what’s it when pcfs_open is called?

Sorry, I realize it’s ignored, never mind.

You may think why don’t you try eclipse in linux?

Actually, I tried that in fitst order but failed, I tried it recently again, in a different way, failed again.

Would you please make Install Eclipse CDT better, with more details?

What was the problem with installing Eclipse?

There’s no installer at https://www.eclipse.org/cdt/downloads.php, I did it by “apt install eclipse”, then when I try to install cdt in “help–install new software…”, it would complain lacking all kinds of packages.

Another way I tried is download a package from https://www.eclipse.org/cdt/downloads.php, extract it and run eclipse in the folder, it says “Cannot run program “make”: Unknown reason”

I’d got eclipse work in linux, got same result as codeblocks in windows, here’s the warnings:

Warn: Image draw cannot open the image resource |(…/lvgl/src/lv_draw/lv_img_cache.c #118)
Warn: Image draw error |(…/lvgl/src/lv_draw/lv_draw_img.c #61)

Why not try the main download page (https://www.eclipse.org/downloads/)?

On any Linux system that you want to use for C development, you need basic tools like gcc and make installed. Normally build-essential or a similar metapackage like that will install them. Google a basic tutorial on setting up Eclipse CDT if you need more help on that. Unless you were having a different issue?

  1. Because in Install Eclipse CDT, it says https://www.eclipse.org/cdt/downloads.php, so I believe that’s where I should go.
  2. I did install build-essential, the make issue was not from make, but from some conflict between the installed eclipse and the extracted eclipse

Good point… it looks like the Eclipse website changed. We should update the link.