Skip to content

add raylib support#235

Closed
mohamedLT wants to merge 4 commits intovlang:masterfrom
mohamedLT:raylib
Closed

add raylib support#235
mohamedLT wants to merge 4 commits intovlang:masterfrom
mohamedLT:raylib

Conversation

@mohamedLT
Copy link

No description provided.

@MatejMagat305
Copy link
Contributor

is it only about v fmt -w . ?

@larpon
Copy link
Contributor

larpon commented Jan 15, 2023

No it's about application design and how to extend vab without building special case support into the app for every framework available out there. A compile time plugin system would be gold - but maybe runtime plugin support would be okay as well. vab also miss some essential features from the v_sdl4android project.

@JalonSolov
Copy link

... but yes, the failing CI check is because the files need to be formatted with v fmt.

src_path := os.join_path(raylib_path, 'src')
ndk_path := ndk.root()
os.execute('make -C ${src_path} clean')
arch_name := if arch == 'arm64-v8a' {
Copy link
Contributor

@MatejMagat305 MatejMagat305 Mar 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be more eficient and nicer with mach{...} instead of if ... else if ... else?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would look cleaner with match. The else branch for the match would take care of the following if as well.


// add the compiled raylib libraries for each arch
if is_raylib {
build_cmd << '-L ${lflags}'
Copy link
Contributor

@MatejMagat305 MatejMagat305 Mar 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe initialisation of 'lflags' for raylib would be nice put inside if

@larpon
Copy link
Contributor

larpon commented Sep 11, 2024

Just to refresh what is going on here: I'm keeping this PR open because I think vab should support (.. or have better support for) compilation and packaging of user projects.

Work has been done lately to simplify calling and using vab as a module which is currently the most feasible and flexible way to get support for thirdparty projects into vab. Support should come, it just takes time.

@MatejMagat305
Copy link
Contributor

I was copy and done (with vlang/raylib#18) own version of this pr, can I give here or should I open other one? And I asume that is suitable all command put into vab, I will put prototypes and I asume you will tidy(give me point), it is ok?

@larpon
Copy link
Contributor

larpon commented May 11, 2025

I was copy and done (with vlang/raylib#18) own version of this pr, can I give here or should I open other one? And I asume that is suitable all command put into vab, I will put prototypes and I asume you will tidy(give me point), it is ok?

I would prefer raylib support is done like SDL is supported; via an extra command like vab-sdl https://github.com/larpon/vab-sdl ... this way we can keep vab free of all the special cases that the different libraries uses in the build and package process etc.

The extra command should thus result in the user being able to build an application importing vlang/raylib with something like: vab raylib ...

@MatejMagat305
Copy link
Contributor

MatejMagat305 commented May 14, 2025

I was copy and done (with vlang/raylib#18) own version of this pr, can I give here or should I open other one? And I asume that is suitable all command put into vab, I will put prototypes and I asume you will tidy(give me point), it is ok?

I would prefer raylib support is done like SDL is supported; via an extra command like vab-sdl https://github.com/larpon/vab-sdl ... this way we can keep vab free of all the special cases that the different libraries uses in the build and package process etc.

The extra command should thus result in the user being able to build an application importing vlang/raylib with something like: vab raylib ...

please can you help me?

vab is working with manual :

cd ~/.vmodules/raylib/raylib/src
make clean
make PLATFORM=PLATFORM_ANDROID \
     ANDROID_NDK=$ANDROID_NDK_HOME \
     ANDROID_ARCH=arm64 \
     ANDROID_API_VERSION=21 \
     INCLUDE_PATHS="-I$ANDROID_NDK_HOME/sources/android/native_app_glue \
                    -I$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include \
                    -I$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/aarch64-linux-android"

@larpon
Copy link
Contributor

larpon commented May 14, 2025

please can you help me?

I will take a look as soon as possible. I am a bit busy IRL at the moment 👍

@MatejMagat305
Copy link
Contributor

I will take a look as soon as possible. I am a bit busy IRL at the moment 👍

ok, I will search for error, but I am probable at the end of my ability/skills and I do not want end without giving you report at least prototype .......

@larpon
Copy link
Contributor

larpon commented May 14, 2025

If the .so is not picked up it may be a directory structure problem or similar see the --libs flag, and https://github.com/vlang/vab/blob/master/docs/FAQ.md#i-managed-to-compile-some-external-so-libs-how-do-I-include-them

(--libs can be used programatically as well)

@larpon
Copy link
Contributor

larpon commented May 14, 2025

Ok. I've tried now to build the project. IMO both vlang/raylib and raysan5/raylib is extremely messy in the way everything is setup to work. I'll have to set aside some more time to investigate this.

@larpon
Copy link
Contributor

larpon commented May 14, 2025

@MatejMagat305 I have opened MatejMagat305/vab-raylib#1 to fix it so make works. But I'm getting some other error that hints that the dreadful raylib/raylib directory setup might be causing confusion.

@larpon
Copy link
Contributor

larpon commented May 14, 2025

I am building with: vab raylib -v 3 --flag "-enable-globals -translated" ~/.vmodules/raylib/examples/hello.v

@MatejMagat305
Copy link
Contributor

MatejMagat305 commented May 14, 2025

I am building with: vab raylib -v 3 --flag "-enable-globals -translated" ~/.vmodules/raylib/examples/hello.v

ok, your changes make:

~/v$ v ../.vmodules/vab-raylib/
~/v$ ../.vmodules/vab-raylib/vab-raylib -v 3 --no-parallel ./examples/hello.v 
Compiling V to C
Compiling V import C dependencies (.c to .o for ['arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64']) in parallel
Compiling C output for ['arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64'] in parallel
Include /home/matej-magat/.vmodules/raylib/raylib/src
Preparing package "io.v.android.raylib"...
Preparing apk base"
Modifying base files...
Copying assets...
Including assets from "./examples/assets"
Generated /home/matej-magat/v/v_test_app.apk
notice: Use `vab-raylib --device <id> /home/matej-magat/v/v_test_app.apk` to deploy package
notice: Use `vab-raylib --device <id> run /home/matej-magat/v/v_test_app.apk` to both deploy and run the package

and it make full apk, with old https://github.com/MatejMagat305/raylib/pull/1/files or new vlang/raylib#19

@MatejMagat305
Copy link
Contributor

MatejMagat305 commented May 14, 2025

and of course

export ANDROID_SDK_ROOT=$HOME/Android/Sdk
export ANDROID_NDK_HOME=$ANDROID_SDK_ROOT/ndk/27.0.12077973
export ANDROID_NDK_ROOT=$ANDROID_NDK_HOME
export PATH=$ANDROID_NDK_HOME:$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_SDK_ROOT/platform-tools:$PATH

@MatejMagat305
Copy link
Contributor

I am building with: vab raylib -v 3 --flag "-enable-globals -translated" ~/.vmodules/raylib/examples/hello.v

my android was install it, but some bug ......, please wait

@MatejMagat305
Copy link
Contributor

well, some ideas?

FATAL EXCEPTION: main
                                                                                                    Process: io.v.android.raylib, PID: 12182
                                                                                                    java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "InitWindow" referenced by "/data/app/~~dpHzkMDAHM__nbbINiratg==/io.v.android.raylib-B_lDiaEYJdILPpcdxoEXjQ==/lib/arm64/libv_test_app.so"...
                                                                                                    	at java.lang.Runtime.loadLibrary0(Runtime.java:1081)
                                                                                                    	at java.lang.Runtime.loadLibrary0(Runtime.java:1003)
                                                                                                    	at java.lang.System.loadLibrary(System.java:1765)
                                                                                                    	at io.v.android.raylib.VRaylibActivity.<clinit>(VRaylibActivity.java:7)
                                                                                                    	at java.lang.Class.newInstance(Native Method)
                                                                                                    	at android.app.AppComponentFactory.instantiateActivity(AppComponentFactory.java:95)
                                                                                                    	at android.app.Instrumentation.newActivity(Instrumentation.java:1378)
                                                                                                    	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4042)
                                                                                                    	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4330)
                                                                                                    	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
                                                                                                    	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139)
                                                                                                    	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96)
                                                                                                    	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2693)
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:106)
                                                                                                    	at android.os.Looper.loopOnce(Looper.java:230)
                                                                                                    	at android.os.Looper.loop(Looper.java:319)
                                                                                                    	at android.app.ActivityThread.main(ActivityThread.java:9063)
                                                                                                    	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:588)
                                                                                                    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)

@MatejMagat305
Copy link
Contributor

I am sorry I was not provading full version what was working, here is old fashion............. https://github.com/MatejMagat305/vab-raylib-bin-prototype/tree/main, I probably know where is error, I will inform, thank for help

@MatejMagat305
Copy link
Contributor

MatejMagat305 commented May 15, 2025

well I do not know what I do wrong ...........
it seams eqvivalent: https://drive.google.com/file/d/1PmSKEjom0uG2tSvUvlFTXyqowcrm0old/view?usp=sharing

../.vmodules/vab/vab --archs "arm64-v8a" -v 3 --no-parallel ./examples/hello.v - works ...........,

../.vmodules/vab-raylib/vab-raylib -v 3 --no-parallel --archs arm64-v8a ./examples/hello.v - crash at run ...

can I move ownership to Vlang after work will be done ?

@larpon
Copy link
Contributor

larpon commented May 15, 2025

I'll look onto it ASAP. It can take a while as I am currently busy

@larpon
Copy link
Contributor

larpon commented May 23, 2025

I have this working locally:
Screenshot_20250524_011006

@larpon
Copy link
Contributor

larpon commented May 24, 2025

well, some ideas?

FATAL EXCEPTION: main
                                                                                                    Process: io.v.android.raylib, PID: 12182
                                                                                                    java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "InitWindow" referenced by "/data/app/~~dpHzkMDAHM__nbbINiratg==/io.v.android.raylib-B_lDiaEYJdILPpcdxoEXjQ==/lib/arm64/libv_test_app.so"...
                                                                                                    	at java.lang.Runtime.loadLibrary0(Runtime.java:1081)
 ...

@MatejMagat305 this is because libraylib.a is never used by the NDK compiler. If you run vab-raylib with -v 3 you can see in the output from clang that it ignores -l:raylib etc.
I think the linking is done in the wrong stage of building.

I am working on a solution that is not forked from larpon/vab-sdl that compiles raylib in parallel directly instead and does not depend on make and git .

@larpon
Copy link
Contributor

larpon commented May 24, 2025

I am closing this. Use https://github.com/larpon/vab-raylib to build vlang/raylib based apps for Android.

@larpon larpon closed this May 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants