How to include data object files (images, etc.) in program and access the symbols?

后端 未结 4 1580
耶瑟儿~
耶瑟儿~ 2020-12-02 00:12

I\'ve turned a couple of resource files into .obj files using objcopy and i link them with my programs source code. I can very well access the symbols inside th

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-02 01:05

    The trick with objcopy isn't meant as a full-featured way to embed resources and isn't portable at all, as you have seen.

    Microsoft has its own mechanism for resources, so if you're specifically targeting windows, you could use a windows resource file and the RCDATA resource.

    If you want something completely portable, your only option is to format the file as C sourcecode like e.g.

    const uint8_t my_binary[] = { 0x00, 0x01, ... }
    

    It's straight forward to write your own conversion tool for that.

提交回复
热议问题