土曜日, 7月 04, 2009

Embed Glade files in executable


  • Gtk#

    Just bundle glade files as resources (using the -resource: option in the compiler) and change constructor call or use the Glade.XML.FromAssembly () method to create Glade.XML ui.
    See also A google search application using Gtk#

  • Gtk+(Embedding Binary Blobs With GCC)
    1. Excerpt From Embedding Binary Blobs With GCC
      $ echo Hello, World > foo.txt
      $ ld -r -b binary -o foo.o foo.txt
      $ objdump -x foo.o

      test.c
      #include <stdio.h>
      extern char _binary_foo_txt_start[];

      int main (void) {
      puts (_binary_foo_txt_start);
      return 0;
      }



      $ gcc -o test test.c foo.o
      $ ./test
      Hello, World!

      Change the string itself in the .data section, which is read/write, to be read-only data in the .rodata section so that it isn't copied for every instance of the application.
      $ objcopy --rename-section .data=.rodata,alloc,load,readonly,data,contents foo.o foo.o
      $ objdump -h foo.o

    2. You might find GNU as's .incbin directive more useful for this purpose - you can control the symbol name, section, and add a NUL terminator. You do have to write little wrapper .s files though. For example
      $ echo hello world > demo.txt
      $ cat > demo.s
      .section ".rodata"
      .globl demo
      .type demo, @object
      demo:
      .incbin "demo.txt"
      .byte 0
      .size demo, .-demo
      ^D
      $ as demo.s -o demo.o
      $ nm demo.o
      00000000 R demo
      $ strings demo.o
      hello world


  • wxWidget(xml-based resource system overview)


For More, See:
Add icons to ELF files
How do I add an icon to a mingw-gcc compiled executable?
  1. create a .rc file that looks id ICON "path/to/my.ico"
  2. windres my.rc -O coff -o my.res
  3. g++ -o my_app obj1.o obj2.o my.res

0 件のコメント: