including linux API files?
BlitzMax Forums/BlitzMax Programming/including linux API files?
| ||
In c, to include the v4l2 API header file, i use: #include <linux/videodev2.h> I'm currently importing into BMax a .c file that includes #include <linux/videodev2.h> and I'm using the Extern to import the functions into BMax I now want to get rid of the .c file all together and deal with linux/videodev2.h directly from within BMax... However, when I: Import "linux/videodev2.h" I get an error "realpath failed" What is the proper way to do this in BlitzMax? thanks |
| ||
try ?linux import "-videodev2.h" ? im just guessing but try anyway if that doesnt work try ?linux import "-videodev2" ? |
| ||
If the header is in a relative directory "linux", then you can do Import "linux/*.h" However, you can't deal with the header at all in BlitzMax. It doesn't understand them. You will need some "glue" to connect BlitzMax to C, either be defining "Extern" functions in BlitzMax itself for specific library functions, or write some glue code to wrap functions in a more BlitzMax friendly way. There are many examples of those and other methods available from third-party module makers. |
| ||
pub.mod is a good example |
| ||
Brucey: In c/c++ linux programming, including "linux/xxx.h" are normally the source files for various software API's, so they aren't a relative path (or even an absolute path).. Some how, g++ must know where to look for all of the linux header files. Usually these files just have a bunch of #includes to the other source files. So I should be able to import them directly in BMX, use Extern, and use the functions directly in BlitzMax (with no extra c programming "glue") slenkar: it appears to have worked- I got no errors about a missing file with import "-videodev2.h"... (though it did give an error on the output: g++: unrecognized option '-videodev2.h' I'll keep looking around and browse the mod folder, I'm sure there are some hints in there. thanks |
| ||
also you might have to install the videodev library to linux in the same place the other libraries are, e.g. libgdev etc. i think linux keeps all libraries in the same folder like the equivalent of windows/system32 |
| ||
In c/c++ linux programming... Indeed... but BlitzMax isn't c/c++. If there is a c function defined in a header as int myfunction(int param1); you can access that function in BlitzMax with this code : Extern Function myfunction:Int(param1:Int) End Extern ' call it Local ret:Int = myfunction(100) Also, if you can change the name assigned in BlitzMax, for reasons like conflicts and whatnot.. Extern Function myrenamedfunction:Int(param1:Int)="myfunction" End Extern If you want to call C++ class methods in BlitzMax, it's usually easier to wrap the class in C glue. Other than BlitzMax's own modules, I knocked together a few basic examples here. |