Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use this project? #39

Closed
hchargois opened this issue Apr 23, 2024 · 11 comments
Closed

How to use this project? #39

hchargois opened this issue Apr 23, 2024 · 11 comments

Comments

@hchargois
Copy link

Hi, I'm a bit confused about how to use this project.

The README has a "Usage" section but it only contains info about how to clone the project and install dependencies... What should we do after that?

I saw that there's a CMakeLists.txt file, so I ran cmake ., which created a Makefile, so I then ran make, and that did create a bin/main binary which runs correctly. But I don't think this is how we're supposed to compile and run the project, right? We're supposed to build and run it from within VSCode I think.

If I open VSCode by running code simulator.code-workspace, open main/src/main.c and click the "Run" icon, it asks me to select a "debug configuration":

image

The first one seems alright, but if I click on it, the compilation within VSCode fails:

image

 *  Executing task: C/C++: gcc build active file 

Starting build...
/usr/bin/gcc -fdiagnostics-color=always -g /home/gohu/coding/lv_port_pc_vscode/main/src/main.c -o /home/gohu/coding/lv_port_pc_vscode/main/src/main
/home/gohu/coding/lv_port_pc_vscode/main/src/main.c:14:10: fatal error: lvgl/lvgl.h: No such file or directory
   14 | #include "lvgl/lvgl.h"
      |          ^~~~~~~~~~~~~
compilation terminated.

Build finished with error(s).

 *  The terminal process failed to launch (exit code: -1). 
 *  Terminal will be reused by tasks, press any key to close it. 

Is this the right way to do? Should this work? If not, what's the correct way to run the project from VSCode?

@kisvegabor
Copy link
Member

Please try this way:

To allow debugging inside VSCode you will also require a GDB extension or other suitable debugger. All the requirements, build and debug settings have been pre-configured in the .workspace file (simply open the project by doubleclick on this file).

@hchargois
Copy link
Author

Thanks for your help. I installed the extension (I didn't think it was necessary as I don't want to debug the program, I just want to run it). And VSCode does say that the workspace is "open".

But it doesn't change anything, I'm still unsure about what to do after opening the workspace, and if I try to click the "run" icon on the main.c, I still have the same error I posted above.

@kisvegabor
Copy link
Member

It works well for me on Linux, but I've tried on Windows with someone and I had the same issue. I still don't know what could be the problem.

@gcopoix, @danyyliu do you have any idea what could be the problem?

@danyyliu
Copy link

danyyliu commented May 3, 2024

I checked what @hchargois written above, if I am taking it correctly, I think what @hchargois wants is: build and execute main program with vscode, instead of shell commands.

I think it should be done in this way:

  1. Add a task in the code-workspace file, like this:
    image
  2. Run the task in this way:
    a. By F1, show command palette, and input or select "Tasks: Run Task":
    image
    b. Then we will see two tasks to be selected: "Build" and "Build and Run main". This "Build and Run main" is @hchargois needed.
    image

Please let me know if I am take it correctly, @hchargois

@hchargois
Copy link
Author

Thank you for your help, adding the task and running it as you've shown works fine, the demo builds and runs correctly!

But I'm very confused... I'm not sure that's what I want? I mean, since that task was not provided already, this makes me think that it was not how I was supposed to use this project? So, I'm back to my very first question: what does this project do and how to use it?

Maybe it would help if I explain how I arrived at this point.

I came to this project because of the "Get Started" documentation:

https://lvgl.io/get-started
-> "Set up a simulator" ->
https://docs.lvgl.io/master/integration/ide/pc-simulator.html

This doc forces us to choose an IDE. I chose VScode as that's what I'm writing code with. And the doc says to "read the README" of the project. So I read the README of this project, but I don't see anything about how to use it. The "Usage" section only explains how to install dependencies, but not what to do after that, i.e. how to actually use the project.

BTW I would absolutely, 100% prefer NOT to use an IDE, and instead just run commands in a terminal myself. However the get started documentation doesn't offer this option; and I don't see any documentation about how to "get started" with the simulator & demos by just running commands in a terminal.

So, yeah, the "get started" doc promises "10 minutes" to set up a simulator, and I'm hours into this and I still don't know what to do 😅

@danyyliu
Copy link

danyyliu commented May 4, 2024

Well, it's clear that it's not a technical question, either a question I can answer. Maybe @kisvegabor can help us with this.

@gcopoix
Copy link
Contributor

gcopoix commented May 6, 2024

Hi, this project is meant as a VisualStudio Code project with configured workspace file, which

  • recommends the required plugins
  • has pre-configured settings for building and running/debugging
    So if you only use VSCode as an editor and the command line for building you will loose the debugging comfort (building from command line will work, but should be done in ./build folder)

The process should be:

  1. Open the project by double-click on the simulator.code-workspace file
    ("All the requirements, build and debug settings have been pre-configured in the .workspace file (simply open the project by doubleclick on this file)"
  2. If VSCode asks to "trust the authors", please trust
  3. If VSCode asks to install recommended plugins, please do so (as they are required!)
  4. VSCode will configure the project on open ("cmake.configureOnOpen": true)
    This can be later done manually too by selecting Ctrl+Shift+P and choosing CMake: Configure
  5. If VSCode asks to select a kit, you can select unspecifiedand let cmake guess a suitable compiler
    This can be later done manually too by selecting Ctrl+Shift+P and choosing CMake: Select a Kit
    If building doesn't work, please make sure a Kit has been selected (only necessary once, VSCode keeps this configuration for the project folder)
  6. To build: Menu->Terminal->Run Build Task or F7 (at least in my configuration)
  7. To Launch Debugger: **Menu->Run->Start Debugging" or F5 or the debug symbol (top/left)

If this doesn't work, please try changing the tasks section to

	// tasks.json section
	"tasks": {
		"version": "2.0.0",
		"tasks": [
			{
				"type": "cmake",
				"label": "Build",
				"command": "build",
				"group": "build",
				"problemMatcher": [],
				"detail": "CMake template build task"
			},
		],
	},

@hchargois
Copy link
Author

Thanks for the detailed steps. Everything works fine.

Looking back at my first post, I now see that the "Debug LVGL demo with GDB" option was there all along. Had I clicked on it, I think it would have worked right off the bat. It's just unfortunate that VSCode adds 2 unrelated C/C++ tasks, which I guess are automatically added whenever it detects a C file, but these fail to build since they're not invoking the actual build system. And it even puts those tasks at the very top of the list. Even the "Detected task" mention may have made things even more confusing for me by making me believe these were "detected" in the workspace file.

I really think these steps (or at the very least the name of the task that we're expected to run) should be in the README in a usage section.

I guess I can close this ticket, thanks all for the help.

@kisvegabor
Copy link
Member

Based on your feedback I've updated the README.
I've mentioned "Debug LVGL demo with gdb" and how to use it purely from the Terminal.

What do you think?

@hchargois
Copy link
Author

It's great! Especially having both options. Thanks.

BTW a few days ago I stumbled upon another project, https://github.com/lvgl/lv_port_linux
After some tweaking of the lv_conf.h, of the build system and of the initialization functions, I was able to make it work with the SDL simulator backend instead of the default framebuffer. I see that it has been improved just a few hours ago to support the SDL backend out of the box simply by editing the lv_conf.h.

That is exactly the project I would have loved to see as the one true official way to "get started". Something simple that can be reliably configured and run with a few simple, documented commands, without having to worry about a complex IDE.

@kisvegabor
Copy link
Member

That is exactly the project I would have loved to see as the one true official way to "get started". Something simple that can be reliably configured and run with a few simple, documented commands, without having to worry about a complex IDE.

Oh, very nice! It's great that the change was useful! 😊
I've just opened lvgl/lvgl#6205 to mention lv_port_linux as a simulator option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants