On Mon, June 3, 2013 18:09, Ewald wrote: > Once upon a time, Anthony Walter said: >> I am trying to come up with an embedded binary resource system and was >> considering placing data in object files when I found this question on >> stack overflow: >> >> http://stackoverflow.com/questions/4158900/embedding-resources-in-exe-using-gcc >> >> >> I see that it's possible to directly turn any file into an object file >> and reference the memory of that as a resource in a C program using: >> >> extern char binary_foo_bar_start[]; >> extern char binary_foo_bar_end[]; >> >> My question, is it possible to link extern char in free pascal in a >> way similar to above? Perhaps something similar to: >> >> var binary_foo_bar_start: pointer; external; >> >> {$L foo.bar.o} >> >> Or some permutation of the above? > > You can pass an option directly to the link ( add -k--format=binary > -k<binary files you wish to embed> -k--format=default to the fpc command > line), or you could use objcopy. > > These two aproaches aren't very portable though, so it is best you write > a script or something that generates code that contains this file. > Something like this: . . > PS: Sorry about the php code there; I know it's not the php mailing > list, but my buildtool happens to be written in php ;-)
Well, you can obviously use tool bin2obj created with/for FPC and distributed with FPC releases - see fpcsrc/utils/bin2obj.pp. Tomas _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal