Skip to content
Advertisement

Embed data in a C++ program

I’ve got a C++ program that uses SQLite. I want to store the SQL queries in a separate file — a plain-text file, not a source code file — but embed that file in the executable file like a resource.

(This has to run on Linux, so I can’t store it as an actual resource as far as I know, though that would be perfect if it were for Windows.)

Is there any simple way to do it, or will it effectively require me to write my own resource system for Linux? (Easily possible, but it would take a lot longer.)

Advertisement

Answer

You can use objcopy to bind the contents of the file to a symbol your program can use. See, for instance, here for more information.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement