Emscripten build can't find the file but native builds can - filesystems

I'm writing an SDL2 program which needs to find images on the filesystem to draw to the screen. On the Linux and Windows builds, this works perfectly and the images appear how they should. However, when compiling with Emscripten, the app tells me that the image file wasn't found. I made the program print its working directory (which is /), then I used the JavaScript console to check what files where the files were and the image file is in the directory that the program expects. Why can't the Emscripten-compiled version find my file?

Related

Compiling with SDL in different directories

I'm trying to do a project which uses SDL2 to do the graphics.
I want to have my project files in a directory.
I have the functions that manipulate the SDL directly and pictures in a subdirectory of this (UI_library).
I solved the compiling part by adding to the compilation commands
-LUI_library
The problem is that when I run the program, it can't find the pictures, since it assumes they are in the project directory and not in the subdirectory.
Do you know how to fix this without manually changing the code in the subdirectory? There are a lot of references to the pictures in the library.
One way to solve this problem would be addressing the whole path to your file.
For Example:
Windos:
SDL_LoadBMP("C:\Documents\your_image.bmp")
Linux:
SDL_LoadBMP("/home/tigre200/Documents/your_image.bmp")

ioquake3 on MacOS: Bundling Freetype With Game

I'm making a game based on ioquake3, and I enabled the use of Freetype for rendering fonts in the game.
However, that library has been a sore on my back throughout the development, and now the game doesn't run right on MacOS computers besides my own because they don't have Freetype installed.
It will look for "renderer_opengl2_x86_64.dylib" in "." and fail. Yet ioquake3 runs just fine on the same computer. And if I transfer ioquake3.app's renderer dylibs, the game runs but without the text rendering because Freetype isn't enabled by default.
So my question is how I would be able to bundle Freetype with my ioquake3-based game. I thought it would be as simple as copying libfreetype.6.dylib into [game].app/Contents/MacOS , but that didn't work either. The original game doesn't use it so copying the renderer dylibs didn't work. I don't want every user to have to install Freetype and link it and all that, so how do I get the library bundled with my app?
OK, so I found out that the renderer dylib files were calling on a hard-coded directory in the system, a directory I had to map myself to get the game to compile but otherwise is not on a normal MacOS computer.
So what I did was use install_name_tool in Terminal to change the directory the dylibs searched in.
install_name_tool -change /usr/local/lib/libfreetype.6.dylib #executable_path/libfreetype.6.dylib /Applications/{game name}.app/Contents/MacOS/renderer_opengl2_x86_64.dylib
^ Then the same thing for the OpenGL 2 dylib, and I copied the libfreetype.6.dylib file into the Contents/MacOS directory of my app. After that, the game ran perfectly on my computer and the "guinea pig" computer I used that didn't have Freetype installed.
I hope this might help anyone else having issues with Freetype and ioquake3!

How to make multiple subdirectories in Eclipse from existing code

I am using Windows 10 and Eclipse Mars edition 32 bit. Programming in C
I am trying to learn C from a Lynda.com course C Essential Training. The course provides a zipped directory with many .c and files and a few others like .h files as you can see below.
However in the video he managed to get each .c file and related source code into its own directory structure.
I've tried numerous type of imports and I also used a batch file to put each .c file in its own folder and tried importing that. I was able to get the Eclipse IDE project window to look like the instructors, but as soon as I tried to compile individual .c programs the project kept looking in the primary workspace folder which for me is C:\Source\Testing\workspace and error'd out.
Is there an import option to create this type of subdirectory structure automatically? I want to go through the tutorial and build and execute each .c file individually. However what I have had to do is put the .c file into a single folder build it and run it one at a time. I then have to delete the source and debug folder and start over for each lesson. There must be a better way.
Eclipse workspace is streigh connected to FS.
This means that your workspace in Eclipse is a folder on your hard disk or where it is stored.
What you can simply do is to create a new folder using right-click-popup-menu within Eclipse Project Explorer and then copy/move files into the new folder.
Or you can create a new folder into your workspace directory and copy/move file inside, then you must refresh Eclipse workspace.

installing GTK+3 on CodeBlocks Windows 7

I am trying to install GTK+3 on windows. It installs but it always tells me that it can't find the file libgtk-3-0.dll. However, GTK+2 works perfectly for me. The main issue is that I am trying to run some interface coded with GTK+3. Only the interface appears but none of the drawing in it! How can I make this work?
Do I need GTK+3 to make it work? If yes, how can I install it properly?
If you installed both gtk2 and gtk3 there might be a conflict with you path.
Surely if you installed gtk2 from a setup file (it usually add a path)
I do use both and compile gtk project with codeblock as well.
What I do is a dedicated folder where there is all gtk and dependency dll and always put the gtk executable I've build with CB.
download gtk3 from there http://www.gtk.org/download/win32.php and unzip
then create a folder MyGtk for example put all .dll from the /bin directory
copy also the /etc & share content at the root of MyGtk
then copy your .exe app also
everything should run fine.
If not edit your windows path and remove any location to c:\xxx\gtk

relative path and system paths are not working in codeblocks

When I am trying to access files from standard usr/ it is not working. and showing errors that file is missing .
I have added path but and make it work but i think this is not the correct way.
I have a workspace with 10-12 projects which are of c and cpp both.
In one project I am using cpp with thrift libraries and protocol.
in that project only I am facing issue. with I am individually building that project it is working but when building it from the main project. it starts showing error in files.
There all almost 17 projects and 16 are generating .so files and all are going to the main project. and main is generating an executable. and that executable uses all the .so files.
but In thrift only it is showing errors. before it was showing for #include i added that file so now it is showing undefined type Name Space ..
I think this issue is because of relative path but I am not sure
Please Help

Resources