将数据嵌入到C ++程序中 [英] Embed data in a C++ program

查看:109
本文介绍了将数据嵌入到C ++程序中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用SQLite的C ++程序。我想将SQL查询存储在单独的文件中 - 一个纯文本文件,不是源代码文件 - 但将该文件作为资源嵌入可执行文件中。



(这必须在Linux上运行,所以我不能把它存储为一个实际的资源,就我所知,虽然那将是完美的,如果它是Windows。)



有没有简单的方法,或者它会有效地要求我写我自己的资源系统为Linux? (很容易实现,但需要很长时间。)

解决方案

您可以使用objcopy将文件的内容您的程序可以使用的符号。有关详细信息,请参见此处。 p>

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.)

解决方案

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.

这篇关于将数据嵌入到C ++程序中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆