Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
flubbernugget

"Low Level" API's

Recommended Posts

So I've been trying to work with my webcam in C and Linux, and the API's I have been trying to use to interface my hardware are a nightmare to work with. First I had to work with l4v2 to interface directly with the webcam. The api was huge. No big deal. I figured I could search through it like I do when I worked with MSDN. Well it's all pure html, but a little google-fu fixed that. But I still found myself calling the wrong functions at the wrong times, and generally over-viewing the documents with little understanding of what's going on. I found example code that did what I needed to do with a little tweaking. So I got what I needed but didn't really learn much about what l4v2 does or how it works.

Well I basically had to put the image from the webcam into memory. Done. But I want to show that everything is in there correctly. So why not make an image file out of it? Because holy crap this documentation makes no freaking sense that's why. I installed Libjpeg or turbojpeg (or whatever the hell it is) from a .deb off the official website (apt-get gave me a bunch of middle fingers trying to install the api "officially"). The install appeared to work, but when I went to make an executable, gcc gave me assloads of linker errors. Thats a cringe in and of itself, but whatever, I've gotta trek through it. Well I looked through the website and the directory it said all the api files were in didn't exist on my system. Awesome! That's probably where all the linker errors came from!

I sat and thought about how to begin looking for the files and how to put them where the linker could find them. After about a week of thinking about it I finally came up with a solution...try a new api. Enter libpng. The documentation is...interesting. It's all example based. The expectation seems to be that if you need specifics, you can flip through the header files....what??? Maybe that's why all my first linux tutorials were going on about how awesome grep was when I just couldn't see it. Either way, I can't seem to find function descriptions, just their prototypes. Kinda helpful...ish. I'm pushing through getting my webcam data into a pretty picture, because at least all of the header files are where the fuck they need to be. Things are painfully slow, but moving along. Well now I'm looking through some of the example code, and when I try to use a function in the api for cleaning up the heap, I get an "undefined reference" error from gcc. So I grep through all the header files to see why this is happening (please just trust me that this isn't a spelling error). I cannot find this function call anywhere in the entire directory all the api code is in except for this one example file. And I don't remember the flag off the top of my head, but yes, I did a recursive search. Nothing. Whyyyyyyy

tl;dr: When I was working with .NET I could get done what I needed to get done fairly painlessly with the MSDN. Now with these low level C api's I'm banging my head against a wall trying to find the information I need to use the api, and that information seems to be wrong when I can find it. Is this just part of the struggle with working with C, or am I working with these api's the wrong way?

Share this post


Link to post
flubbernugget said:

I installed Libjpeg or turbojpeg (or whatever the hell it is) from a .deb off the official website (apt-get gave me a bunch of middle fingers trying to install the api "officially"). The install appeared to work, but when I went to make an executable, gcc gave me assloads of linker errors.

Well that made me cringe....

The official packages usually work fine. You probably know you need -dev versions, like libjpeg8-dev, if you want the headers (for compiling). The base library package only has the raw libraries (for applications to use).

Well now I'm looking through some of the example code, and when I try to use a function in the api for cleaning up the heap, I get an "undefined reference" error from gcc.

What function?

Share this post


Link to post
flubbernugget said:

png_free_image()

The PNG library on my Debian system is version 1.2.50 and has no such function.

Where did you see/find it?

Share this post


Link to post
flubbernugget said:

It was in the example.c file of libpng.

Having piss poor or non-existent documentation, a constantly changing API, and out-of-date examples, if any, are badges of honor for C programmers. The more important the API in question, the bigger the honor is for having all of these elements be as unprofessional as possible.

Share this post


Link to post

File a bug report that the example is out of date, not like the libpng developers will send you death threats when you submit a bug.

Share this post


Link to post

In all honestly I never thought to file a bug report. That always seemed like something left for "real" software developers to do.

Are a lot of the C libraries open source? That would explain why they're less professional than something done "on the clock"

Share this post


Link to post
flubbernugget said:

That would explain why they're less professional than something done "on the clock"


Just because a programmer is paid to program, does not mean it has good quality.

You have for example two people:

  • Person 1 loves what he does and does it for free and does it really good.
  • Person 2 hates his job and probably his life, and does not care at all the quality of his work.
No matter how much you pay Person 2, he will always write bad quality code.

If your only choice was to select either of these two, which one would you choose?

Share this post


Link to post
flubbernugget said:

You can love to code and hate documenting it.

Does anyone really like documenting code??

Admittedly, no ;) And I say this as a user of Doxygen at my job :P

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×