Hello fb community,
I'm trying to build the fbc+emscripten compiler to build some programs and play around.
But the guide from https://freebasic.net/wiki/devbuildemscripten seems to be very extensive and complicated and seems to link to https://freebasic.net/wiki/DevBuildWindows which has even more tools and folders to manage.
Also, I'm not sure if this guild isn't outdated now.
So I want to ask if there are any prebuild version of the fbc+emscripten compiler - or if it would be possible for you to provide a script (or even a program written in FreeBasic) than automates all the downloading, unpacking, compiling etc. until you can run the command to compile your own programs.
I have a Linux and a Windows computer to try this.
Best Regards,
linuxanddos
Prebuild fbc+emscripten installer
-
- Posts: 19
- Joined: Oct 28, 2023 13:31
Re: Prebuild fbc+emscripten installer
Basically, you need FreeBasic for your system, and its source code. Then, you need to install Emscripten: under Linux, the procedure is something like:
As described here: https://emscripten.org/docs/getting_sta ... loads.html
At this point, you need to compile the runtime libraries for Emscripten, you do it with:
You might have to manually copy the files :termlib_min.js , fb_shell.html , fb_rtlib.js , fbextra.x in the lib directory and in the lib/freebasic/js-asmjs directory
At this point, it should be able to work
Code: Select all
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
git pull
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh
At this point, you need to compile the runtime libraries for Emscripten, you do it with:
Code: Select all
make rtlib gfxlib2 TARGET=asmjs-unknown-emscripten ENABLE_STANDALONE=1
At this point, it should be able to work
-
- Posts: 19
- Joined: Oct 28, 2023 13:31
Re: Prebuild fbc+emscripten installer
Thanks. Now it is almost working (on Linux).
But if I try to compile, there is the following error:
I think I've missed some environment variable, but sadly, I don't know which one.
EDIT: It seems like I do not have an /lib/freebasic directory.
But if I try to compile, there is the following error:
Code: Select all
wasm-ld: error: unable to find library -lfb
wasm-ld: error: unable to find library -lfbgfx
wasm-ld: error: unable to find library -lfb
EDIT: It seems like I do not have an /lib/freebasic directory.
-
- Posts: 19
- Joined: Oct 28, 2023 13:31
Re: Prebuild fbc+emscripten installer
I have found the folder: /usr/local/lib/freebasic/
Now it is compiling, but it seems like I have to enable async support...
Now it is compiling, but it seems like I have to enable async support...
-
- Posts: 19
- Joined: Oct 28, 2023 13:31
Re: Prebuild fbc+emscripten installer
Now my software is almost working.
But I need some conditional compiling distinguishing between emscripten and the other platforms.
Is there something like
for emscripten/wasm?
But I need some conditional compiling distinguishing between emscripten and the other platforms.
Is there something like
Code: Select all
#ifdef __FB_DOS__
'code here
#endif
Re: Prebuild fbc+emscripten installer
There is a builtin define, available since emscripten target was added to fbc:
Not in the wiki / manual, but should probably be added (even if exact naming changes in future).
Code: Select all
'' defined for '-target js-asmjs'
#ifdef __FB_JS__
#endif
-
- Posts: 19
- Joined: Oct 28, 2023 13:31
Re: Prebuild fbc+emscripten installer
Somewhere in this forum I have read that it is possible to run JS code from your FreeBasic app. Sadly, I don't find this message again.
Instead, I found this: https://emscripten.org/docs/porting/con ... rom-native
How can I use this in FreeBasic?
Instead, I found this: https://emscripten.org/docs/porting/con ... rom-native
How can I use this in FreeBasic?