0

I have a program:

dist/
├── myapp
│   ├── bin
│   │   └── launcher
│   ├── lib
│   │   └── libmyapp.so
│   └── share
│       ├── data00.zip
│       └── data01.zip

What I want to do is combine all of that into a single executable file, so that, for the end user, it's a single file to copy around.

I'd be OK with a bash shell file too. Also, I have control over the .so file. I could statically link it to the player.

How do I combine all of this into a single / merged executable file?

This is on linux. The .zip files are opened with fopen(). I'm hoping for some kind of magic involving something like FUSE or similar technology.

I was hoping to avoid embedding the .zip as a DATA segment payload or using a .h file because that would change my program in ways that I didn't intend. This is more of a packaging question.

101010
  • 14,866
  • 30
  • 95
  • 172
  • For which platform? – rici Jan 19 '22 at 00:55
  • how are zip files used? – Diego Torres Milano Jan 19 '22 at 01:27
  • zip files are loaded using API commands like fopen to find the .zip in the /share folder. The code looks for `pwd` and then goes up and over to `share/` to find the .zip files – 101010 Jan 19 '22 at 01:55
  • I ran across this https://makeself.io/ and it seems solve part of the problem -- possibly enough of the problem. It extracts the binary into a temp folder. A better solution would be no extraction. – 101010 Jan 19 '22 at 01:55
  • you can convert your zips into C headers and use it in your code; for example with: `xxd -i data00.zip > mydata00.h` – Fravadona Jan 19 '22 at 01:59
  • This is the true duplicate that _properly_ answers the question: [Is there a Linux equivalent of Windows' "resource files"?](https://stackoverflow.com/questions/1997172/is-there-a-linux-equivalent-of-windows-resource-files) – Dúthomhas Jan 19 '22 at 07:29

2 Answers2

0

This is not an unusual need or question. And there are a number of different ways to do this.

On Windows, of course, you should use a Windows Resource with the Windows Resource Compiler.
But you are on Linux :O)

On Linux, objcopy(1) is what comes to the rescue. There is an old Linux Journal article specifically about this:

It really does not get simpler than that.

BTW, there are quite a few questions on SO that deal with the same thing, all using a variation of the same answer. For example: Is there any standard way of embedding resources into Linux executable image? [duplicate] The top answer uses the assembler to do the same thing that objcopy does. Variations abound.

EDIT: Found the proper duplicate. Will mark above.

Dúthomhas
  • 8,200
  • 2
  • 17
  • 39
  • Then why not mark this as a duplicate ? – John3136 Jan 19 '22 at 05:08
  • Because the duplicates do it the hard way, instead of using objcopy. – Dúthomhas Jan 19 '22 at 05:58
  • @Dúthomhas: so contribute a better answer to the duplicate you choose. – rici Jan 19 '22 at 06:23
  • Because this question is a spiderweb of posts. :-( But I think I found the duplicate with the top-voted correct answer: [Is there a Linux equivalent of Windows' "resource files"?](https://stackoverflow.com/questions/1997172/is-there-a-linux-equivalent-of-windows-resource-files) – Dúthomhas Jan 19 '22 at 07:28
  • You convinced yourself this is a dupe and closed my question. This isn't a windows question. The windows resource file is not roughly analogous to this either. The .zip files are opened with fopen whereas a resource file is opened with a special Windows API. I was hoping for some magic -- say a Fuse wrapper or a container technology that could hide the internal filesystem without changing the C code. – 101010 Jan 20 '22 at 12:29
  • You did not mention any of this in your question. Reformulate your question to be more specific so that it can be re-opened. – Dúthomhas Jan 20 '22 at 13:27
0

You can compress files and share as self extracting archive, that is .exe format.

You can use 7-zip for that. Use-7Zip-to-Create-Self-Extracting-excutables