How to Link a Miscellaneous File

  • Thread starter Robert L. Smith, Jr.
  • Start date
R

Robert L. Smith, Jr.

I want to include an online dictionary, a binary file with
its own unique format, into an executable at link time,
using the linker in Microsoft Visual-C++ V6. Is it
possible? What is the link option? How can I assign a
name to it that will fill in a pointer to the start of the RAM
copy at run time?

Yes, I know I can read in the dictionary at run time and in
fact that's what I'm doing. But this means the dictionary
is a separate file that can get lost. I'd like to include
it in the executable.

Thanks for your attention.

--Robert Smith
rlsj at nc.rr.com
 
W

Walter Roberson

I want to include an online dictionary, a binary file with
its own unique format, into an executable at link time,
using the linker in Microsoft Visual-C++ V6. Is it
possible?

Likely not directly.
What is the link option? How can I assign a
name to it that will fill in a pointer to the start of the RAM
copy at run time?

I suggest that you write a program that reads the dictionary
file and spits out C code that contains its equivilent.

unsigned char TheDictionary = {
0x01, 0x73, 0x08, ...
};

The code to produce the file could be quite simple -- just
loop around reading so many bytes at a time, print them out
using a constant format, and when you finally get fewer bytes
than that on your read, have a small loop to take care of the
end case. Or simpler yet to code, just loop getting a character
at a time, and do Magic Format Things at particular numeric
position boundaries...
 
K

Keith Thompson

I want to include an online dictionary, a binary file with
its own unique format, into an executable at link time,
using the linker in Microsoft Visual-C++ V6. Is it
possible? What is the link option? How can I assign a
name to it that will fill in a pointer to the start of the RAM
copy at run time?

The C language defines no mechanism for incorporating anything other
that code derived from C source files and libraries in an executable.
I'm not aware of any implementation that does so either.

You might write a separate program that reads the file (in binary
mode) and generates as output a C source file that declares an array
of unsigned char initialized to the contents of the file. It should
probably generate a header (.c) file that declares the array, and a C
(.c) file that defines and initializes it.
 
M

Mark McIntyre

You'd need to look at compiler-specific ways of attaching a binary
object to your app. Most modern compilers can do this easily with say
bitmaps, menus and resource data, presumably one can tailor this to
handle random BLOBs.
The C language defines no mechanism for incorporating anything other
that code derived from C source files and libraries in an executable.
I'm not aware of any implementation that does so either.

You must have lived down a well for the last 15 years then :)
You might write a separate program that reads the file (in binary
mode)

Or read the data file (in binary mode) at runtume
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top