Created .exe, when running .exe error unable to load audio file

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
Nine Iron
Prole
Posts: 13
Joined: Fri Oct 09, 2020 5:59 am

Created .exe, when running .exe error unable to load audio file

Post by Nine Iron »

Hey,

I tried searching for an answer, I thought I would have found one but I didn't. Please let me know if I missed a post.

I created an exe from a working project. I have my files but when I try to run the .exe it has an issue with the first audio file listed in my sound.lua. I tried copying all of my files into the same folder with the .exe, no success. What am I missing? I ran the console commands listed on the wiki, /b love.exe+game.love game.exe . I don't know what I'm missing. Any help would be greatly appreciated.



Thank you,

Nine Iron
User avatar
ReFreezed
Party member
Posts: 612
Joined: Sun Oct 25, 2015 11:32 pm
Location: Sweden
Contact:

Re: Created .exe, when running .exe error unable to load audio file

Post by ReFreezed »

Make sure the audio files are in the .love file. All files for your game, except the .dll files, should be in the .love file.
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
User avatar
Nine Iron
Prole
Posts: 13
Joined: Fri Oct 09, 2020 5:59 am

Re: Created .exe, when running .exe error unable to load audio file

Post by Nine Iron »

They are, I zipped everything inside the project folder 'as-is'. I must have changed something because now I'm getting the same error trying to run the program from the ide. Ugh, I swear it was working when I created the zip file.

I set up a function to automatically require all my files and it looks like it's trying to require my sound files. I'll move them to a different folder and figure out how to id the sound and picture files in a bit.

I appreciate the help.
RNavega
Party member
Posts: 239
Joined: Sun Aug 16, 2020 1:28 pm

Re: Created .exe, when running .exe error unable to load audio file

Post by RNavega »

Is this "unable to load audio file" the only info that the error screen gives you? That's kinda vague.
- It might fail if it can't find the file (bad relative path or no read permission).
- It might fail if it does find the file but the contents are corrupted.
- It might fail for some other reason I'm not aware of.

You can find some complete Love2D games over at itch.io and look inside their love archive. The Curse of The Arrow game, for example, has this structure...
  • CurseOfTheArrow-V1.8.3-universal.love/
    • main.lua (entry point)
      • /assets/
        • jump.wav
        • arrow.wav
        • sprites.png
        • ...
      • /src/
        • engine.lua
        • cutscene.lua
        • ...
    ...which then loads things like this:

    Code: Select all

    sfx = {
      ["step"] = love.audio.newSource("assets/step.wav","static"),
      ["jump"] = love.audio.newSource("assets/jump.wav","static"),
      ["hit"] = love.audio.newSource("assets/hit.wav","static"),
      ...
    }
    User avatar
    Nine Iron
    Prole
    Posts: 13
    Joined: Fri Oct 09, 2020 5:59 am

    Re: Created .exe, when running .exe error unable to load audio file

    Post by Nine Iron »

    Okay, I reorganized my sound and picture files. My automated require function is no longer trying to require them. My program runs in the ide. When I create a zip and change .zip to .love, my program runs. When I create an exe though it will not run. As far I can see my archive has the same structure.

    I'm getting an error stating that it could not open my font file. 'Could not open file pics/font.tff. Does not exist.' The font is inside the pics folder. It traces back to a setNewFont function.

    If the .love runs fine, why won't the .exe? I tried moving it into my project folder, along with the love .dlls, and I get the same error.
    RNavega
    Party member
    Posts: 239
    Joined: Sun Aug 16, 2020 1:28 pm

    Re: Created .exe, when running .exe error unable to load audio file

    Post by RNavega »

    Are you sure that the .exe + .love fusion is being done properly? If you comment out that font loading, do the other assets load properly?
    User avatar
    pgimeno
    Party member
    Posts: 3544
    Joined: Sun Oct 18, 2015 2:58 pm

    Re: Created .exe, when running .exe error unable to load audio file

    Post by pgimeno »

    Check the case of the filenames. In the case of a zip file, they must match.

    (That's the comment I deleted, I thought I was off the mark when I noticed that you said that it didn't work in the IDE either)
    User avatar
    Nine Iron
    Prole
    Posts: 13
    Joined: Fri Oct 09, 2020 5:59 am

    Re: Created .exe, when running .exe error unable to load audio file

    Post by Nine Iron »

    As far as the fusion, cmd says 1 file copied, no error. I can run the .love file just fine though. I run cmd with admin, cd to program files\love.

    I commented out the font mentions and now I get the original error for my sound file. It's not able to find the assets. It runs just fine, or at least loads, in the ide and the .love file. I now get an error from commenting out the fonts but that's after clicking a button. I can at least get the first room to load.

    The exe is the same name as the zip file. My main.lua is in the top tree of the zip.
    User avatar
    pgimeno
    Party member
    Posts: 3544
    Joined: Sun Oct 18, 2015 2:58 pm

    Re: Created .exe, when running .exe error unable to load audio file

    Post by pgimeno »

    I bet if you move the .love file to another directory, it will give errors too. That's because it's still finding the files in your folder, out of the .love file (IIRC it doesn't search for them for fused programs).

    Check the letter case of the filename of the sound files and the font files, vs. what you have specified in the code. They must match.
    Post Reply

    Who is online

    Users browsing this forum: Ahrefs [Bot], Google [Bot] and 46 guests