{"id":294,"date":"2020-02-24T12:31:00","date_gmt":"2020-02-24T10:31:00","guid":{"rendered":"https:\/\/arnoldvanhofwegen.com\/blog\/?p=294"},"modified":"2020-02-24T13:03:49","modified_gmt":"2020-02-24T11:03:49","slug":"compiling-ren-c-and-making-some-changes","status":"publish","type":"post","link":"https:\/\/arnoldvanhofwegen.com\/blog\/compiling-ren-c-and-making-some-changes\/","title":{"rendered":"Compiling REN-C and making some changes"},"content":{"rendered":"\n<figure class=\"wp-block-gallery columns-0 is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\"><ul class=\"blocks-gallery-grid\"><\/ul><\/figure>\n\n\n\n<p>So downloading the source from the repository page <\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/metaeducation\/ren-c\">https:\/\/github.com\/metaeducation\/ren-c<\/a><\/p>\n\n\n\n<p>And follow the instructions (we are all on Linux now right!?) in the readme.md file. If this is your first time you should add a mkdir build before doing the cd to build.<\/p>\n\n\n\n<p><code>export R3_MAKE=\"$(pwd)\/prebuilt\/r3-linux-x64-8994d23\"<br>cd build<br>\"$R3_MAKE\" ..\/make.r config: ..\/configs\/default-config.r<\/code><\/p>\n\n\n\n<p>We now change some files. In rebmake.r before the first line with &#8220;Running:&#8221; we add the lines<\/p>\n\n\n\n<p><code>if not null? find cmd \"mod-view\" [replace cmd \"gcc -c \" \"gcc -c `pkg-config --cflags gtk+-3.0` \"]<br> if not null? find cmd \"gcc -o\" [replace cmd \"objs\/main.o\" \"objs\/main.o `pkg-config --libs gtk+-3.0`\"]<\/code><\/p>\n\n\n\n<p>In extensions\/view\/make-spec.r we delete some stuff and keep<\/p>\n\n\n\n<p><code>libraries: _<br>options: []<\/code><\/p>\n\n\n\n<p>in extensions\/view\/ext-view-init.reb we make everything a comment by putting a semicolon before every line.<\/p>\n\n\n\n<p>And we experiment with the code in mod-view.r and add some GTK things in there.<\/p>\n\n\n\n<p>Because of compilation times we extract our compilation strings from the log so we can develop a lot faster:<\/p>\n\n\n\n<p><code>gcc -c `pkg-config --cflags gtk+-3.0` -Iprep\/extensions\/view -I..\/src\/include -Iprep\/include -DREB_API -DNDEBUG -DOS_STACK_GROWS_DOWN -DENDIAN_LITTLE -DHAS_LL_CONSTS -D_FILE_OFFSET_BITS=64 -DUSE_PIPE2_NOT_PIPE -D__LP64__ -DTO_LINUX -DTO_LINUX_X64 -O2 -fvisibility=hidden -o objs\/view\/mod-view.o ..\/extensions\/view\/mod-view.c<\/code><\/p>\n\n\n\n<p>and<\/p>\n\n\n\n<p><code>gcc -o r3 -fvisibility=hidden -rdynamic objs\/a-constants.o objs\/a-globals.o objs\/a-lib.o objs\/b-init.o objs\/c-bind.o objs\/c-do.o objs\/c-context.o objs\/c-error.o objs\/c-eval.o objs\/c-function.o objs\/c-path.o objs\/c-port.o objs\/c-signal.o objs\/c-specialize.o objs\/c-value.o objs\/c-word.o objs\/d-crash.o objs\/d-dump.o objs\/d-eval.o objs\/d-gc.o objs\/d-print.o objs\/d-stack.o objs\/d-stats.o objs\/d-test.o objs\/d-trace.o objs\/f-blocks.o objs\/f-deci.o objs\/f-device.o objs\/f-dtoa.o objs\/f-enbase.o objs\/f-extension.o objs\/f-int.o objs\/f-math.o objs\/f-modify.o objs\/f-qsort.o objs\/f-random.o objs\/f-round.o objs\/f-series.o objs\/f-stubs.o objs\/l-scan.o objs\/l-types.o objs\/m-gc.o objs\/m-pools.o objs\/m-series.o objs\/m-stacks.o objs\/n-control.o objs\/n-data.o objs\/n-do.o objs\/n-error.o objs\/n-function.o objs\/n-io.o objs\/n-loop.o objs\/n-math.o objs\/n-protect.o objs\/n-reduce.o objs\/n-sets.o objs\/n-strings.o objs\/n-system.o objs\/s-cases.o objs\/s-crc.o objs\/s-find.o objs\/s-make.o objs\/s-mold.o objs\/s-ops.o objs\/t-binary.o objs\/t-bitset.o objs\/t-blank.o objs\/t-block.o objs\/t-char.o objs\/t-datatype.o objs\/t-date.o objs\/t-decimal.o objs\/t-function.o objs\/t-integer.o objs\/t-logic.o objs\/t-map.o objs\/t-money.o objs\/t-object.o objs\/t-pair.o objs\/t-port.o objs\/t-quoted.o objs\/t-string.o objs\/t-time.o objs\/t-tuple.o objs\/t-typeset.o objs\/t-varargs.o objs\/t-word.o objs\/u-compress.o objs\/u-parse.o objs\/u-zlib.o objs\/tmp-boot-block.o objs\/tmp-type-hooks.o objs\/gob\/mod-gob.o objs\/gob\/t-gob.o objs\/tmp-mod-gob-init.o objs\/uuid\/mod-uuid.o objs\/uuid\/libuuid\/gen_uuid.o objs\/uuid\/libuuid\/unpack.o objs\/uuid\/libuuid\/pack.o objs\/uuid\/libuuid\/randutils.o objs\/tmp-mod-uuid-init.o objs\/event\/mod-event.o objs\/event\/t-event.o objs\/event\/p-event.o objs\/event\/event-posix.o objs\/tmp-mod-event-init.o objs\/bmp\/mod-bmp.o objs\/tmp-mod-bmp-init.o objs\/time\/mod-time.o objs\/time\/time-posix.o objs\/tmp-mod-time-init.o objs\/console\/mod-console.o objs\/tmp-mod-console-init.o objs\/stdio\/mod-stdio.o objs\/stdio\/p-stdio.o objs\/stdio\/stdio-posix.o objs\/stdio\/readline-posix.o objs\/tmp-mod-stdio-init.o objs\/library\/mod-library.o objs\/library\/library-posix.o objs\/tmp-mod-library-init.o objs\/serial\/mod-serial.o objs\/serial\/serial-posix.o objs\/tmp-mod-serial-init.o objs\/dns\/mod-dns.o objs\/tmp-mod-dns-init.o objs\/crypt\/mod-crypt.o objs\/crypt\/aes\/aes.o objs\/crypt\/bigint\/bigint.o objs\/crypt\/dh\/dh.o objs\/crypt\/rc4\/rc4.o objs\/crypt\/rsa\/rsa.o objs\/crypt\/sha256\/sha256.o objs\/crypt\/md5\/u-md5.o objs\/crypt\/sha1\/u-sha1.o objs\/tmp-mod-crypt-init.o objs\/image\/mod-image.o objs\/image\/t-image.o objs\/tmp-mod-image-init.o objs\/gif\/mod-gif.o objs\/tmp-mod-gif-init.o objs\/utf\/mod-utf.o objs\/tmp-mod-utf-init.o objs\/network\/mod-network.o objs\/network\/dev-net.o objs\/tmp-mod-network-init.o objs\/png\/mod-png.o objs\/png\/lodepng.o objs\/tmp-mod-png-init.o objs\/debugger\/mod-debugger.o objs\/tmp-mod-debugger-init.o objs\/secure\/mod-secure.o objs\/tmp-mod-secure-init.o objs\/process\/mod-process.o objs\/process\/call-posix.o objs\/tmp-mod-process-init.o objs\/vector\/mod-vector.o objs\/vector\/t-vector.o objs\/tmp-mod-vector-init.o objs\/locale\/mod-locale.o objs\/tmp-mod-locale-init.o objs\/jpg\/mod-jpg.o objs\/jpg\/u-jpg.o objs\/tmp-mod-jpg-init.o objs\/filesystem\/mod-filesystem.o objs\/filesystem\/p-file.o objs\/filesystem\/p-dir.o objs\/filesystem\/file-posix.o objs\/tmp-mod-filesystem-init.o objs\/view\/mod-view.o objs\/tmp-mod-view-init.o -lm -ldl objs\/main.o `pkg-config --libs gtk+-3.0<\/code>`<\/p>\n\n\n\n<p>A quick overview of some code I have got now<\/p>\n\n\n\n<p><code>\/\/ \"warning: implicit declaration of function\"<br><br>\/\/<br>  \/\/  export open-window: native [<br>  \/\/  ]<br>  \/\/<br>  REBNATIVE(open_window)<br>  {<br>    VIEW_INCLUDE_PARAMS_OF_OPEN_WINDOW;<br>    REBINT n = 0;<br>    n = open_my_window();<br>    Init_Integer(D_OUT, n);<br>    return D_OUT;<br>  }<\/code><\/p>\n\n\n\n<p>The empty line is important!<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;gtk\/gtk.h>\n\n\/\/ Include the rebol core for the rebnative c-function\n#include \"sys-core.h\"\n\n#include \"tmp-mod-view.h\"\n\n#define VIEW_LINUX_64_GTK\n\n\/\/ Helper functions\nstatic void\nprint_hello (GtkWidget *widget,\n             gpointer   data)\n{\n  g_print (\"Hello World\\n\");\n}\n\nstatic void\nmove_this_window (GtkWidget* widget,\n                  gpointer   data)\n{\n   GtkWidget *toplevel = gtk_widget_get_toplevel (widget);\n   if (gtk_widget_is_toplevel (toplevel))\n     {\n       \/* Perform action on toplevel. *\/\n       const gchar *text_window = gtk_window_get_title (GTK_WINDOW (toplevel));\n       g_print (\"Hello again - %s \\n\", (char *) text_window);\n       gtk_window_move (GTK_WINDOW (toplevel), 400, 600);\n     }\n\n}\n\nstatic void\nactivate (GtkApplication* app,\n          gpointer        user_data)\n{\n  GtkWidget *window;\n  GtkWidget *grid;\n  GtkWidget *button;\n\n  window = gtk_application_window_new (app);\n  gtk_window_set_title (GTK_WINDOW (window), \"REN-C Window\");\n  gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER_ALWAYS);\n  gtk_window_set_default_size (GTK_WINDOW (window), 500, 500);\n\n  gtk_container_set_border_width (GTK_CONTAINER (window), 10);\n\n  \/* Here we construct the container that is going pack our buttons *\/\n  grid = gtk_grid_new ();\n\n  \/* Pack the container in the window *\/\n  gtk_container_add (GTK_CONTAINER (window), grid);\n\n  button = gtk_button_new_with_label (\"Move me!\");\n  g_signal_connect (button, \"clicked\", G_CALLBACK (move_this_window), NULL);\n\n  \/* Place the first button in the grid cell (0, 0), and make it fill\n   * just 1 cell horizontally and vertically (ie no spanning)\n   *\/\n  gtk_grid_attach (GTK_GRID (grid), button, 0, 0, 1, 1);\n\n  button = gtk_button_new_with_label (\"Print Hello\");\n  g_signal_connect (button, \"clicked\", G_CALLBACK (print_hello), NULL);\n\n  \/* Place the second button in the grid cell (1, 0), and make it fill\n   * just 1 cell horizontally and vertically (ie no spanning)\n   *\/\n  gtk_grid_attach (GTK_GRID (grid), button, 1, 0, 1, 1);\n\n  button = gtk_button_new_with_label (\"Quit\");\n  g_signal_connect_swapped (button, \"clicked\", G_CALLBACK (gtk_widget_destroy), window);\n\n  \/* Place the Quit button in the grid cell (0, 1), and make it\n   * span 2 columns.\n   *\/\n  gtk_grid_attach (GTK_GRID (grid), button, 0, 1, 2, 1);\n\n  \/* Now that we are done packing our widgets, we show them all\n   * in one go, by calling gtk_widget_show_all() on the window.\n   * This call recursively calls gtk_widget_show() on all widgets\n   * that are contained in the window, directly or indirectly.\n   *\/\n  gtk_widget_show_all (window);\n}\n\nint open_my_window ()\n{\n    GtkApplication *app;\n    int status;\n    int argc = 0;\n    char **argv;\n    app = gtk_application_new (\"info.rebol.rencexample\", G_APPLICATION_FLAGS_NONE);\n    g_signal_connect (app, \"activate\", G_CALLBACK (activate), NULL);\n    status = g_application_run (G_APPLICATION (app), argc, argv);\n\n    g_object_unref (app);\n\n    return status;\n}<\/code><\/pre>\n\n\n\n<p>This works on my machine. It is a starting point of discovering more functionality and then gradually work forward to a real flexible solution. My take is do not just add everything at once, just what is essential. <\/p>\n\n\n\n<p>Till next blog!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So downloading the source from the repository page https:\/\/github.com\/metaeducation\/ren-c And follow the instructions (we are all on Linux now right!?) in the readme.md file. If this is your first time you should add a mkdir build before doing the cd &hellip; <a href=\"https:\/\/arnoldvanhofwegen.com\/blog\/compiling-ren-c-and-making-some-changes\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"gallery","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/arnoldvanhofwegen.com\/blog\/wp-json\/wp\/v2\/posts\/294"}],"collection":[{"href":"https:\/\/arnoldvanhofwegen.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/arnoldvanhofwegen.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/arnoldvanhofwegen.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/arnoldvanhofwegen.com\/blog\/wp-json\/wp\/v2\/comments?post=294"}],"version-history":[{"count":2,"href":"https:\/\/arnoldvanhofwegen.com\/blog\/wp-json\/wp\/v2\/posts\/294\/revisions"}],"predecessor-version":[{"id":296,"href":"https:\/\/arnoldvanhofwegen.com\/blog\/wp-json\/wp\/v2\/posts\/294\/revisions\/296"}],"wp:attachment":[{"href":"https:\/\/arnoldvanhofwegen.com\/blog\/wp-json\/wp\/v2\/media?parent=294"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/arnoldvanhofwegen.com\/blog\/wp-json\/wp\/v2\/categories?post=294"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/arnoldvanhofwegen.com\/blog\/wp-json\/wp\/v2\/tags?post=294"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}