ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I need to write some C or C++ code that (on some events) displays a png file on fullscreen. Preferably without X, on the framebuffer. I found fbida and fbv, but:
it doesn't seem too simple how they do it
I can't even compile the code of neither of them, I get tons of errors
the license is GPL. I'd prefer BSD or LGPL so I could use their code or simply use their libs. In this case GPL is good only to learn how this is done, so I could then write my own code
Can you give me any directions or examples how to do this? Decoding png could be probably accomplished with libpng, which is LGPL. I'm more concerned about displaying the image on framebuffer. If really, really necessary, I could use X, but I'm trying to avoid using X at all costs here.
If you do have to use X, then you might look into the framebuffer server, or possibly a non-XFree86/XOrg distro, to reduce the overhead.
You can certainly do this. DirectFB (LGPL) should be up to the job I think.
Alternatively, it would probably be easier, and more portable, to write your program using the SDL library, which takes care of a lot of the hassles for you.
Another option is fbi (GPL) or ppmtofb (GPL, more specifically fbview) which you could shell out to to show the image. (There's a legal minefield here as to whether this counts as linking or not; one possibility is to make the viewer configurable but I'm not a legal expert and I don't know if that will get you out of trouble).
Yet another option is to write a kernel module to do it (after decompressing the PNG in userspace); you'll find an entire pixmap-drawing library in drivers/video/cfbimgblt.c
You might also want to try searching on freshmeat.net
Thank you very much. I went for SDL, it seems fast enough. Got some huge problems (I'm an SDL newbie) with enabling fb in debian sarge and geting SDL_Init to succeed without mouse, but got it now.
if you are doing this without X as I did, you need framebuffer support in kernel. Look for options CONFIG_FB* when you configure the kernel.
Install SDL and SDL_image.
If you will use framebuffer and are missing fb0 device node, create it:
Code:
mknod -m 666 /dev/fb0 c 29 0
I had some difficulties (lockups, errors, can't remember what exactly) because I didn't have a mouse attached. I had to set this environment variable before running my SDL program.
Code:
export SDL_NOMOUSE=1
For info about writing C code that works with SDL, see the documentation on SDL website. There should be some example code, like Hello World.
SVGALIB is a quite archaic piece of code, but not as complex as SDL, and it runs without X. It not used often these days, but if your interest in rather in learning the concept, then it's maybe worth a look.
As of the license: You can use GPL code and libs, unless you intend to go commercial with code written by others. Even then you can link your application to shared GPL libraries. Only advantage of LGPL for commercial purposes is that you can link them statically if the code of the library itself didn't changed.
It seems you're at the start position with your coding project. Isn't it too early to bother with licenses?
As of the license: You can use GPL code and libs, unless you intend to go commercial with code written by others. Even then you can link your application to shared GPL libraries. Only advantage of LGPL for commercial purposes is that you can link them statically if the code of the library itself didn't changed.
It seems you're at the start position with your coding project. Isn't it too early to bother with licenses?
Besides, only I was concerned about license and I finished my project long ago. So as far as this thread is concerned, the license issue is probably irrelevant.
If a library is released under the GPL (not the LGPL), does that mean that any program which uses it has to be under the GPL?
Yes, because the program as it is actually run includes the library.
Hmm, yes .. well, Apache uses it's own license and still uses the GNU C libraries. Same for OpenOffice. This is an endless topic. I never heard of Eben Moglen stressing a law suite against Apache or OpenOffice developers.
The FAQ is actually a bit vague, as it confuses the term "using a library" without going into detail on static and shared libraries. A static library becomes part of the compiled code and moves along with it. A shared library is accessed at runtime.
You could create an application that uses a shared library called 'libc' by calling a function called 'malloc' and 'free'. C, malloc and free are standard C terms and are not subject to GPL. Assume that on one system libc is provided by GPL code, on another system by BSD code or something else. Your application can be copied between those two systems, will always find a libc with the proper malloc and free implementation, so it will work. You as a developer can not be made responsible for a shared service provided on any of those systems - the same compiled code can not be illegal on one system while being legal on another one.
Note how different this is from a situation where the library is statically linked, so it becomes part of the application and does not use the libc implementation provided by the running system.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.