Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Is it possible to put media files into the .exe file?  (Read 8029 times)

0 Members and 1 Guest are viewing this topic.

Rimdeker

  • Newbie
  • *
  • Posts: 4
    • MSN Messenger - qaghan@live.de
    • View Profile
Is it possible to put media files into the .exe file?
« on: February 21, 2012, 10:25:41 am »
[REDACTED]
« Last Edit: March 10, 2016, 11:59:00 am by Rimdeker »

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Is it possible to put media files into the .exe file?
« Reply #1 on: February 21, 2012, 10:42:17 am »
I know that this is possible with Visual Studio, I don't know about Code::Blocks.
What you need is called resources, so if you google something like "codeblocks resources" then you might find out more.
TGUI: C++ SFML GUI

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Is it possible to put media files into the .exe file?
« Reply #2 on: February 21, 2012, 10:53:33 am »
It can be done in a standard way. All you have to do is to convert your media files to C++ files (using an external tool) that define the data as char arrays, include them into your app and use LoadFromMemory rather than LoadFromFile.
Laurent Gomila - SFML developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Is it possible to put media files into the .exe file?
« Reply #3 on: February 21, 2012, 11:33:07 am »
Quote
Can you recommend a converter?

I don't know them, sorry. But writing one is a straight-forward task.

Quote
Why LoadFromMemory?

Because the file contents are now in RAM (it is loaded when you run your exe), not on your hard drive anymore.
Laurent Gomila - SFML developer

slotdev

  • Sr. Member
  • ****
  • Posts: 385
    • View Profile
Is it possible to put media files into the .exe file?
« Reply #4 on: February 21, 2012, 03:59:34 pm »
You can also use a program like Molebox, which I use all the time.

You just pack your resources into the final exe. It's great :)

http://www.molebox.com/

Ed
SFML 2.1

Svenstaro

  • Full Member
  • ***
  • Posts: 222
    • View Profile
Is it possible to put media files into the .exe file?
« Reply #5 on: February 21, 2012, 04:29:31 pm »
Use QT with qrc. If you need a colorful interface, use qtcreator. This is a cross-platform way.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Is it possible to put media files into the .exe file?
« Reply #6 on: February 21, 2012, 04:31:23 pm »
Using Qt (not QT, which is QuickTime) only for their resource system would really be crazy.
Laurent Gomila - SFML developer

Svenstaro

  • Full Member
  • ***
  • Posts: 222
    • View Profile
Is it possible to put media files into the .exe file?
« Reply #7 on: February 21, 2012, 04:37:35 pm »
Er why? It's not like there aren't other nice things in Qt worth using. Also, most popular distros already have Qt installed anyway. Windows users usually don't worry about a few extra dlls and neither do Mac folks.

There's lots of good stuff in Qt and the tools are great as well. Throw away Codeblocks and use Qtcreator.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Is it possible to put media files into the .exe file?
« Reply #8 on: February 21, 2012, 04:47:42 pm »
Quote
Er why? It's not like there aren't other nice things in Qt worth using.

That's why I said "only for their resource system".

- Qt is a big dependency -- Windows users do worry about it, since DLLs are usually very badly managed.
- It requires pre-build steps to create the resource files, which are difficult to integrate into your preferred IDE if you don't have a dedicated plugin. And switching from your preferred IDE to QtCreator just because you use Qt to embed resources into your executable, doesn't seem like a reasonable choice.
- You must learn the Qt's basics before using it. Even if it's just for resources, there are a few tricks to understand.
- Then you have to use their IO classes if you want to be able to load your resources, but you must then convert them to something else so that you can use SFML's loading functions.
- And... well it's a huge multi-purpose C++ framework, it's insane to use it when the required feature can be written with 10 lines of code.

Let's focus on the requested feature, and not into a "Qt / QtCreator is better than X / Y" discussion please ;)
Laurent Gomila - SFML developer

the_composer

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: Is it possible to put media files into the .exe file?
« Reply #9 on: March 06, 2013, 04:09:47 pm »
I know that this is possible with Visual Studio, I don't know about Code::Blocks.
What you need is called resources, so if you google something like "codeblocks resources" then you might find out more.
How would you do it in Visual Studio? (I'm using VS 2012)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Is it possible to put media files into the .exe file?
« Reply #10 on: March 06, 2013, 04:17:47 pm »
How would you do it in Visual Studio? (I'm using VS 2012)
Maybe this helps. ;)
« Last Edit: March 06, 2013, 04:34:42 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Is it possible to put media files into the .exe file?
« Reply #11 on: March 06, 2013, 04:24:03 pm »
404 Not Found ;D
You forgot a question mark before q.
Back to C++ gamedev with SFML in May 2023

the_composer

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: Is it possible to put media files into the .exe file?
« Reply #12 on: March 06, 2013, 04:25:57 pm »
I got the hint. :P

Thanks eXpl0it3r.

 

anything