How to insert / link binary data in C ++ DLL

So, I have a Visual Studio 2008 project that contains a large amount of binary data that it is currently referencing. I would like to pack binary data the same way you can do with C #, adding it as a โ€œresourceโ€ and compiling it as a DLL.

Suppose all my data has the extension ".data" and is currently being read from a visual studio project.

Is there a way with which you can compile or link the data in the .dll that it calls?

I looked at some Google links for this, and so far I havenโ€™t come up with anything - the only possible solution I came up with is to use something like ResGen to create a .resources file and then link it using AssemblyLinker with / Embed or / Link, I do not think that it will work properly, though, because I do not have text files to create .resources files, but binary files themselves.

Any tips?

+7
c ++ binary-data linker embed
source share
2 answers
  • Right-click the resource script (.rc file)
  • Select import.

http://msdn.microsoft.com/en-us/library/saced6x2.aspx

You can embed any โ€œcustomโ€ file you want, as well as things like .bmps and more. VisualStudio "knows" how to edit. Then you can access them with your resource resources like FindResource LoadResource etc.

If you do not have a script resource.

  • Click "Project"
  • Add New Item
  • Script Resource

http://msdn.microsoft.com/en-us/library/sxdy04be(v=VS.71).aspx

+4
source share

You can embed binary data as an array of C - no resources at all. Old classic trick. see for example XD

+6
source share

All Articles