0

Possible Duplicate:
How to Embed/Link binary data into a C++ DLL

I need a commandline tool which could embed my binary file(s) into some (C way linkable) .obj file - this binary data should be under some given symbols to reach to it from c code

Is there such tool? (I am especially interested in windows platform, coff and omf formats )

3
  • 1
    Usually the easiest way is to convert the binary file into C source code, and feed that through the compiler to the linker. Not sure if that's acceptable here. Commented Oct 21, 2012 at 12:30
  • The more I look around on SO, this questions is beginning to look like a duplicate of either this or that one. You might want refine your question and/or get more specific. Commented Oct 21, 2012 at 12:54
  • It is not a duplicate I am asking about tool for static modules (obj), gosh Commented Oct 24, 2012 at 10:55

2 Answers 2

1

If you are using gcc. You can use the linker to do just that using something like:

ld -r -b binary -o foo.o foo.txt

Take a look here

Sign up to request clarification or add additional context in comments.

Comments

1

If a windows-only solution is sufficient, i.e. portability is not required, you could also use binary resources and the "standard" resource compiler, tool, and formats.

Resources don't have to be just icons, cursors, dialogs, etc. but can also be arbitrary data. Here is an example. Or this stackoverflow answer.

I do not know what exactly you are trying to achieve here, but if you search stackoverflow or google for "embed binary as resource" you'll find a couple of examples.

2 Comments

windows resources are unhandy, I need commandline tool to put binary under some symbol name in linkers obj - want to find a tool
It wouldn't be too complicated to write a reusable script that first creates a wrapper resource script for your binary, second calls rc.exe to create the .res file an third calls link.exe to create the final .dll/.exe that contains your binary. The benefit of resources are, that they are easily extractable. Either by the application they are contained in itself, or by some stand alone tool. YMMV, of course.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.