if(($ACT == 'edit' || $ACT == 'preview') && $INFO['editable']){ ?> } else { ?> } ?>
This shows you the differences between two versions of the page.
wiki:embedding_resources_in_executables [16.10.2016 11:59] rgareus [Architecture dependent binary linking] OSX/getsectiondata |
wiki:embedding_resources_in_executables [10.01.2018 15:57] (current) rgareus [Alternative option using asm] |
||
---|---|---|---|
Line 161: | Line 161: | ||
A complete project that uses this approach to include a jpeg image file and a javascript text file is [[https://github.com/x42/harvid|harvid]]. It also outlines how to use a x-platform ''Makefile'' for creating the object files and adding the relevant flags to the OSX gcc command. | A complete project that uses this approach to include a jpeg image file and a javascript text file is [[https://github.com/x42/harvid|harvid]]. It also outlines how to use a x-platform ''Makefile'' for creating the object files and adding the relevant flags to the OSX gcc command. | ||
+ | ===== Alternative option using asm ===== | ||
+ | |||
+ | User ColaEuphoria points out that an alternative for x86 architecture is to use assembly | ||
+ | |||
+ | section .rodata | ||
+ | |||
+ | global _my_data; | ||
+ | |||
+ | _my_data: incbin "my_data.file" | ||
+ | _my_data_size: dd $-_my_data | ||
+ | |||
+ | and compile it with `''nasm -felf64 resource.s -o resource.o''` (Note that ''-felf64'' here is Linux 64bit. The options needs to be replaced with the corresponding target architecture and OS). | ||
+ | |||
+ | The data can then be referenced using | ||
+ | |||
+ | extern const unsigned char _my_data[]; | ||
+ | |||
+ | with gcc. MSVC does not need the leading underscore in c-code and one can reference it using ''my_data''. | ||
{{tag>development article}} | {{tag>development article}} |