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

POC of Vlang library callable like C lib #6

Open
shiipou opened this issue Jun 11, 2020 · 5 comments
Open

POC of Vlang library callable like C lib #6

shiipou opened this issue Jun 11, 2020 · 5 comments
Assignees
Labels
type | poc You have make a Proof of Concept before making a choice. You can try everything you want here.

Comments

@shiipou
Copy link
Member

shiipou commented Jun 11, 2020

POC of Vlang library callable like C lib in Android NDK (Or other)

This will help me to know if it better to use V for the main base of the app orif I will use C.

@shiipou
Copy link
Member Author

shiipou commented Jul 16, 2020

To use Vi-v on Android or iOS I will use flutter C interop (dart:ffi)
That will allow the usage of Vi-v on each mobile devices.

@shiipou shiipou added the type | poc You have make a Proof of Concept before making a choice. You can try everything you want here. label Jul 16, 2020
@shiipou shiipou self-assigned this Jul 16, 2020
@shiipou
Copy link
Member Author

shiipou commented Jul 20, 2020

Here first step of my POC :

The Vi-v lib in V :
Screen Shot 2020-07-20 at 15 42 18
This just contain a test function that will be called in a V exe.

Compile the V version of the Vi-v lib into a C file.
Screen Shot 2020-07-20 at 15 44 48
The command use the V compiler to translate V into C file. It's supported by default in V.

The C file got too many content to easly find how V translate the V code into C.
Screen Shot 2020-07-20 at 15 46 45
Because it include all the V types, structs, and functions. But I did'nt need to see it.

So I've make an empty lib in V and translate it in V to.
Screen Shot 2020-07-20 at 15 48 55

Screen Shot 2020-07-20 at 15 53 30

And I use the diff command to see only the translated code without deps.
Screen Shot 2020-07-20 at 15 58 37
Here I can see V has generate my function vi_v.test() into a C function named vi_v__test();

So I'll generate the compiled lib to the root folder :
Screen Shot 2020-07-20 at 16 05 22
I'm on Mac os, so .dylib is the dynamic library generated.
On Linux that must be .so.

To call the lib function on my main program (in V), I just have to include it and to call it.
Screen Shot 2020-07-20 at 15 40 02

But I've got an error on the last step :
Screen Shot 2020-07-20 at 16 40 52

@ken0x0a
Copy link

ken0x0a commented Feb 3, 2021

It should work in this way

#include ...

fn C.vi_v__test() // <- add this

fn main() {
  C.vi_v__test()
}

@shiipou
Copy link
Member Author

shiipou commented Feb 4, 2021

@ken0x0a Thanks, I haven't updated it, But that will be really great to work like this.

Thanks for the tips,
Love to see you following this project.

PS: By the way, Just let you know I now will work at part time on it with the help of a student. I hope to make something appear before September.

@shiipou
Copy link
Member Author

shiipou commented Oct 20, 2021

I'm little late, nothing appear in September because of some points that make me upset with my app.
I want the best approach, so I've restarted almost everything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type | poc You have make a Proof of Concept before making a choice. You can try everything you want here.
Projects
None yet
Development

No branches or pull requests

2 participants