Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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;

share|improve this question

closed as off topic by Joe Wreschnig, Jari Komppa, jco, michael.bartnett, Byte56 Oct 13 '12 at 18:27

Questions on Game Development Stack Exchange are expected to relate to game development within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

1  
"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. –  user744 Sep 27 '12 at 21:27
    
Can you show what some of these errors are? Your current description of the problem doesn't give us much to go on. –  Byte56 Sep 27 '12 at 22:35
    
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. –  Bugster Sep 28 '12 at 5:16
    
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. –  tsturzl Sep 28 '12 at 18:44
    
Undefined references are caused by a misconfiguration of your linker (often proxied by a misconfiguration of your IDE), PhysFS can't document every shitty IDE / editor / compiler configuration for you. –  user744 Oct 2 '12 at 21:24
add comment

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer
    
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! –  Bugster Oct 6 '12 at 15:56
    
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. –  Bugster Oct 7 '12 at 10:25
    
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 –  derivative Oct 7 '12 at 19:53
    
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) –  Bugster Oct 8 '12 at 7:32
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.