Emscripten compile ERROR:root:libraylib.bc: No such file or directory

I have been struggling to get emscripten working for a few days now. I've followed the "Compile for Web (HTML5)" guide in the wiki. The full error reads as follows:

ERROR:root:libraylib.bc: No such file or directory ("libraylib.bc" was expected to be an input file, based on the commandline arguments provided)

I have done the following already:
- Updated emsdk
- Installed sdk-1.34.1-64bit
- Installed java-7.45-64bit
- Installed the latest version of emsdk
- Activated the latest version of emsdk
- Checked the emsdk tools to make sure everything's active and the versions are right
- Made sure my file was based on the template provided from the "Compile for Web (HTML5)" guide
- Changed the name of the paths (see below)


echo > Setup required Environment
echo -------------------------------------
echo WARNING: raylib for HTML5 requires EMSCRIPTEN SDK (http://kripken.github.io/emscripten-site/docs/getting_started/downloads.html), setup required paths correctly:
echo
SET RAYLIB_DIR=C:\raylib
SET EMSDK_PATH=C:\emsdk
SET EMSCRIPTEN_VERSION=1.35.0
SET CLANG_VERSION=e1.35.0_64bit
SET PYTHON_VERSION=2.7.5.3_64bit
ENV_SET PATH=C:\emsdk;C:\emsdk\clang\e1.35.0_64bit;C:\emsdk\node\4.4.1_64bit\bin;C:\emsdk\python\2.7.5.3_64bit;C:\emsdk\emscripten\1.35.0;C:\raylib\MinGW\bin
SET EMSCRIPTEN=C:\emsdk\emscripten\1.35.0
echo
cd $(CURRENT_DIRECTORY)
echo
echo > Compiling program
echo -------------------------
emcc.bat -O1 -o $(NAME_PART).html $(FILE_NAME) libraylib.bc -std=c99 -Wall -I. -I$(RAYLIB_DIR)\raylib\release\html5 -L.-L$(RAYLIB_DIR)\raylib\release\html5 -DPLATFORM_WEB -s USE_GLFW=3 --shell-file $(RAYLIB_DIR)\raylib\templates\web_shell\shell.html
echo
echo > Reset Environment
echo --------------------------
ENV_UNSET PATH


Do I need to copy the libraylib.bc file from the HTML5 released folder to my project folder? I'm sure I'm missing a simple step but I'm new and am not use to compiling scripts and reading batch files. I would appreciate any help. If you need any more information I'll respond as soon as I can. thanks again.

Always learning,

Vitasa

Comments

  • Hello Vitasa, welcome to raylib forum! :)

    Have you verified paths and versions are correct? They should be:

    EMSDK_PATH=C:\emsdk
    EMSCRIPTEN_VERSION=1.35.0
    CLANG_VERSION=e1.35.0_64bit
    PYTHON_VERSION=2.7.5.3_64bit

    Try copying libraylib.bc into same folder of your code. Also verify that you don't have spaces or weird characters in the path to your code.

    Please, let me know if it works!
  • Sweet! I copied the libraylib.bc folder in the file I was working in and it returned some warnings in the console, but after I built it again after that there was no warning or errors. I also got the
    --preload-file resources working by adding it to the script as follows:
    emcc.bat -O1 -o $(NAME_PART).html $(FILE_NAME) libraylib.bc -std=c99 -Wall -I. -I$(RAYLIB_DIR)\raylib\release\html5 -L.-L$(RAYLIB_DIR)\raylib\release\html5 -DPLATFORM_WEB -s USE_GLFW=3 --shell-file $(RAYLIB_DIR)\raylib\templates\web_shell\shell.html --preload-file resources


    2 questions:

    1. I noticed there was a raylib.h file in the C:\raylib\raylib\release\html5. Should I add that to the folder I'm working in?

    2. What is the .data file? I seem to be able to build with no errors with the following files in the folder I'm working in:

    - resources(folder)
    - core_basic_window_web.c
    - core_basic_window_web.html
    - core_basic_window_web.js
    - libraylib.bc
  • Hi Vitasa, glad to read it worked, there is some issue with paths, I need to review it.

    About your questions:

    1) raylib.h is just the header containing the functions declarations, it's common for every platform and it's already available in default paths. If compiler doesn't complaint about it saying something like "raylib.h can not be found", it's ok, no need to copy.

    2) When you compile your game, the data is transformed, here it is what it happens, left files are the origin and right files the final result:

    resources folder ---------------------------> core_basic_window_web.data
    core_basic_window.c + libraylib.bc ------------> core_basic_window_web.js

    core_basic_window_web.html is just a shell to run core_basic_window_web.js
    core_basic_window_web.data is kind of a zip with all the resources data and it's used by core_basic_window_web.js.

    So, to upload your web game to your web, you only need:

    core_basic_window_web.js
    core_basic_window_web.data
    core_basic_window_web.html (optional)
  • Thank you very much for your explanation, I really appreciate the detail and timeliness of your response.

    I noticed that in the comment at the top of the core_basic_window_web.c template, it says that if I want to "compile it for PLATFORM_WEB just uncomment #define PLATFORM_WEB at beginning". However if I uncomment #define PLATFORM_WEB

    I get the following warning:
    core_basic_window_web.c:18:9: warning: 'PLATFORM_WEB' macro redefined [-Wmacro-redefined]
    #define PLATFORM_WEB
    ^
    <command line>:4:9: note: previous definition is here
    #define PLATFORM_WEB 1
    ^
    1 warning generated.


    I'm thinking it's because there's a line in the batch script that already does this and it may possibly be conflicting.

    segment from raylib_compile_emscripten:

    emcc.bat -O1 -o $(NAME_PART).html $(FILE_NAME) libraylib.bc -std=c99 -Wall -I. -I$(RAYLIB_DIR)\raylib\release\html5 -L.-L$(RAYLIB_DIR)\raylib\release\html5 -DPLATFORM_WEB -s USE_GLFW=3 --shell-file $(RAYLIB_DIR)\raylib\templates\web_shell\shell.html --preload-file resources


    If I leave it commented I get no errors so I suppose I could just do that. Should that comment at the beginning of the core_basic_window_web.c template be changed to clear any confusion? My apologies for asking so many questions I'm just deeply engaged in the mechanics of everything.
  • Hi Vitasa,

    Actually, I left that comment there in case someone tries to compile the example from a different tool than Notepad++, I mean, without a predefined script.

    There shouldn't be any problem defining PLATFORM_WEB twice, it's just a warning.

    Probably I could review the comment to state it clearly...

    Please, don't apologise for asking, that's the forum for! Any feedback is really welcome! :)
  • Sweet I understand now. I'd love to learn more about batch commands and exactly how this all works:

    emcc.bat -O1 -o $(NAME_PART).html $(FILE_NAME) libraylib.bc
    -std=c99 -Wall
    -I. -I$(RAYLIB_DIR)\raylib\release\html5
    -L.-L$(RAYLIB_DIR)\raylib\release\html5 -DPLATFORM_WEB
    -s USE_GLFW=3
    --shell-file $(RAYLIB_DIR)\raylib\templates\web_shell\shell.html
    --preload-file resources

    :neutral: I'm now even sure If I spaced that out properly haha. I looked at the emscripten tools reference and learned that -I and -L are for warnings like you said.

    Now that I have everything running I'll get started making some games. :smiley:
  • edited July 2016
    Basically, that line runs a program (compiler) that transforms a text file written in a language that compiler understands into an executable file, additionally, some parameters are passed to the compiler to let him know how to do that job.

    Emscripten compiler parameters are quite similar to GCC compiler parameters, at least most of them. Parameters:

    -O1 --> Level of code optimization when compiling
    -std=c99 --> C version used in the text file (in this case C version from year 1999)
    -o filename.c --> Object file to be generated on compilation
    -I. -I../src --> Paths where compiler should look for #include files
    -L. -L../release --> Paths where compiler/linker should look for libraries to be linked together with your code.
    -s USE_GLFW=3 --> (Emscripten parameter) To use GLFW3 library (internally available in Escripten folder)
    --shell-file template.html --> (Emscripten parameter) The shell html file where your .js/.data files will be shown.
    --preload-file resources --> (Emscripten parameter) Resources to be compiled into .data file
  • Thanks for the breakdown! so much to learn haha :)
Sign In or Register to comment.