After my recent question on GD I've been advised to use PhysFS to pack all my game data in 1 file. So I have, and the decission wasn't light, because I've tried out every library in my answers but none contained a single good tutorial whatsoever, in fact PhysFS is the poorest documented library I've ever seen.

After attempting to set up PhysFS in my game I realized it's not as simple as adding the headers to the project, it appears something much more complicated, in fact after my first attempt to install PhysFS the compiler ran out of memory to display errors, it reached the critical count of 50 errors.

So basically what I'm asking here is: How can I set up PhysFS on my game? I'm using Code::Blocks IDE on Windows XP SP3;

  • 1
    \$\begingroup\$ "PhysFS is the poorest documented library I've ever seen." - It's a library that abstracts filesystem access. It only needs like a dozen functions, and they have the usual names like eof, seek, tell, read. How to set up your personal development environment is not very game development related. \$\endgroup\$
    – user744
    Commented Sep 27, 2012 at 21:27
  • \$\begingroup\$ Can you show what some of these errors are? Your current description of the problem doesn't give us much to go on. \$\endgroup\$
    – House
    Commented Sep 27, 2012 at 22:35
  • \$\begingroup\$ Most of the errors consisted of undefined references despite the fact I had all PhysFS headers and sources in my project. I heavily disagree with Joe, even the poorest library needs documentation, at least on how to install it, not everyone knows how to do this properly. \$\endgroup\$
    – Bugster
    Commented Sep 28, 2012 at 5:16
  • \$\begingroup\$ I for one agree with Joe. PhysFS is a filesystem library, its functions are pretty basic. You don't require much knowledge of PhysFS, but rather of how filesystems work. All you really need to know is how to initialize it, then its all typical filesystem API. \$\endgroup\$
    – tsturzl
    Commented Sep 28, 2012 at 18:44

1 Answer 1


You want to know how to compile and link against PhysFS. First, you need to create the binaries to link against. I'll assume you're using MinGW with C::B.

Creating the PhysFS binaries (with C::B IDE, MinGW on Windows)

  1. Unzip your PhysFS archive into a directory (e.g. C:\physfs-2.0.2)

  2. You want to download CMake as per INSTALL.TXT in the directory. Once installed, open the CMake GUI and point the first field (Where is the source code:) at your directory (C:/physfs-2.0.2).

  3. Create a directory for the binaries (doesn't matter where, I created one on the desktop) and point the second field (Where to build the binaries:) at that.

  4. Click "Generate". Under the drop-down for generators, I chose "CodeBlocks - MinGW Makefiles" - assuming you're using CodeBlocks with MinGW and MinGW is installed to its default location, this will work. Otherwise, you'll have to click "Configure" and play with the settings.

  5. Assuming no errors, navigate to your directory and open PhysicsFS.cbp. Try to build it - chances are, you'll get an error about an unused variable. If you do, expand the virtual folder "CMake Files" in the project file structure and open "CMakeLists.txt".

  6. On line 47, remove '-Werror' from ADD_DEFINITIONS(). Try to build the project again - this time, it should work. You now have files in your project directory: libphysfs.a, libphysfs.dll, libphysfs.dll.a.

  7. Create a folder for your binaries, e.g. "C:\physfs-2.0.2\bin" and copy them there.

Linking against the PhysFS binaries

  1. In the Code::Blocks settings, you need to now add "C:\physfs-2.0.2\" as a compiler search directory and "C:\physfs-2.0.2\bin" as a linker search directory. This can be done either locally to the project or globally to the IDE, depending on your needs.

  2. Finally, right click on your project, choose "build options", go to "linker settings" and under "other linker options" add -llibphysfs at the end.

  3. Now, in your project where you want to use PhysFS, make sure to #include physfs.h, but don't actually put the file (or any of the physfs files) in your project.

  4. Try building your project and (assuming there are no errors in your code) it should compile.

  • \$\begingroup\$ Awesome. I lost all faith to get a possible answer, I've asked this on 3 different sites but the answers were not step-by-step, this answer is great, thanks! \$\endgroup\$
    – Bugster
    Commented Oct 6, 2012 at 15:56
  • \$\begingroup\$ Also what do I do in the case that I'm getting a missing DLL? It still runs but I'm sure somewhere those missing DLLs will have an impact. \$\endgroup\$
    – Bugster
    Commented Oct 7, 2012 at 10:25
  • \$\begingroup\$ at what point are you getting a missing DLL? building the PhysFS binaries or building your project? I got a missing libgmp-10.dll error with cmake and had to add it to my windows PATH because I think the default installation has it not add its directory to the PATH variable... in my case I added: C:\Program Files (x86)\CMake 2.8\bin \$\endgroup\$
    – derivative
    Commented Oct 7, 2012 at 19:53
  • \$\begingroup\$ Yeah it was that DLL that you also got, I will try set the PATH even though it should be there (It's in mingw, and I haev mingw/bin to my path) \$\endgroup\$
    – Bugster
    Commented Oct 8, 2012 at 7:32

Not the answer you're looking for? Browse other questions tagged .