Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use C libraries in Vlang for basic statistics

I want to do basic statistics with Vlang.

Can I use C libraries? For example, Apophenia: http://apophenia.info/

Or IMSL C stat library: https://docs.roguewave.com/en/imsl/c/8.6/pdf/C_Stat_library.pdf

Thanks for your help.

like image 727
rnso Avatar asked Sep 12 '25 17:09

rnso


1 Answers

Yes, you can call C libraries from V.

You need to make the C library's structs, typedefs and functions known to V by defining them in V first - before calling/using them.

For structs you conveniently only need to define the fields you need to use.

Here's some examples:

  • via 2D game framework wrapping several C libs
  • sokol in vlib
  • v-miniaudio wrapper (disclaimer: my own module)

Generally you can find a lot of C wrapper code in vlib itself. (We're working on replacing C with pure V)

like image 68
Larpon Avatar answered Sep 14 '25 10:09

Larpon