読者です 読者をやめる 読者になる 読者になる

haiju's 開発メモ

開発に必要な情報を自分用にメモ

Nim の GUIライブラリ nimxをインストールしてサンプルコードを動かしてみる(3)

tips Nim manjaro

この記事はNim Advent Calendar 2016 の25日目の記事です。

こちらの環境はManjaro Fluxbox 15.12のNim開発環境を

0.15.2 -> 0.15.3 にアップデートして再検証を行います。

[手順]

1. ローカルの開発環境のバージョンを上げる。

 ローカルにインストールしたNimディレクトリに移動し

 以下を実行。

% cd Nim

% git pull

% ./koch boot -d:release

2. バージョンを確認。

% nim
Nim Compiler Version 0.15.3 (2016-12-27) [Linux: amd64]
Copyright (c) 2006-2016 by Andreas Rumpf

3. nimxインストール。

% nimble install nimx
Downloading https://github.com/yglukhov/nimx using git
Verifying dependencies for nimx v0.1
Info: Dependency on sdl2 (any version) already satisfied
Verifying dependencies for sdl2 v1.1
Info: Dependency on opengl (>= 1.1) already satisfied
Verifying dependencies for opengl v1.1.0
Info: Dependency on x11 (any version) already satisfied
Verifying dependencies for x11 v1.0
Info: Dependency on nimsl (>= 0.2 & < 0.3) already satisfied
Verifying dependencies for nimsl v0.2
Installing jnim (any version)
Downloading https://github.com/vegansk/jnim using git
Verifying dependencies for jnim v0.2.5
Installing nimfp (>= 0.1.0)
Downloading https://github.com/vegansk/nimfp using git
Verifying dependencies for nimfp v0.3.5
Installing nimboost (>= 0.3.2)
Downloading https://github.com/vegansk/nimboost using git
Verifying dependencies for nimboost v0.3.4
Installing nimboost v0.3.4
Success: nimboost installed successfully.
Installing classy (>= 0.0.1)
Downloading https://github.com/nigredo-tori/classy using git
Verifying dependencies for classy v0.0.1
Installing classy v0.0.1
Success: classy installed successfully.
Installing nimfp v0.3.5
Success: nimfp installed successfully.
Installing jnim v0.2.5
Success: jnim installed successfully.
Installing nake (any version)
Downloading https://github.com/fowlmouth/nake using git
Verifying dependencies for nake v1.8
Installing nake v1.8
Building nake/nake using c backend
Success: nake installed successfully.
Installing closure_compiler (>= 0.2 & < 0.3)
Downloading https://github.com/yglukhov/closure_compiler.git using git
Verifying dependencies for closure_compiler v0.2
Installing closure_compiler v0.2
Building closure_compiler/closure_compiler using c backend
Success: closure_compiler installed successfully.
Installing plists (any version)
Downloading https://github.com/yglukhov/plists using git
Verifying dependencies for plists v0.1.0
Installing plists v0.1.0
Success: plists installed successfully.
Installing variant (>= 0.2 & < 0.3)
Downloading https://github.com/yglukhov/variant.git using git
Verifying dependencies for variant v0.2.1
Installing variant v0.2.1
Success: variant installed successfully.
Installing jester (any version)
Downloading https://github.com/dom96/jester using git
Verifying dependencies for jester v0.1.1
Installing jester v0.1.1
Success: jester installed successfully.
Installing https://github.com/yglukhov/ttf (>= 0.2.3 & < 0.3)
Downloading https://github.com/yglukhov/ttf using git
Verifying dependencies for ttf v0.2.3
Installing nimBMP (any version)
Downloading https://github.com/jangko/nimBMP using git
Verifying dependencies for nimBMP v0.1.2
Installing nimBMP v0.1.2
Success: nimBMP installed successfully.
Installing ttf v0.2.3
Success: ttf installed successfully.
Installing https://github.com/yglukhov/async_http_request (any version)
Downloading https://github.com/yglukhov/async_http_request using git
Verifying dependencies for async_http_request v0.1.0
Installing jsbind (any version)
Downloading https://github.com/yglukhov/jsbind using git
Verifying dependencies for jsbind v0.1
Installing jsbind v0.1
Success: jsbind installed successfully.
Installing async_http_request v0.1.0
Success: async_http_request installed successfully.
Installing jsbind (any version)
Downloading https://github.com/yglukhov/jsbind using git
Verifying dependencies for jsbind v0.1
Installing jsbind v0.1
Prompt: jsbind-0.1 already exists. Overwrite? [y/N]
Answer: y
Success: jsbind installed successfully.
Installing nimx v0.1
Success: nimx installed successfully.

4. Hello, world!をWindowに表示するサンプルコードを書く。

# File: main.nim
import nimx.window
import nimx.text_field
import nimx.system_logger # Required because of Nim bug (#4433)
 
proc startApp() =
      # First create a window. Window is the root of view hierarchy.
     var wnd = newWindow(newRect(40, 40, 800, 600))
 
      # Create a static text field and add it to view hierarchy
      let label = newLabel(newRect(20, 20, 150, 20))
      label.text = "Hello, world!"
      wnd.addSubview(label)
 
# Run the app
runApplication:
        startApp()

5. ビルドして動作確認。

% nim c -r --noMain --threads:on main.nim
Hint: used config file '/home/haiju/Nim/config/nim.cfg' [Conf]
Hint: system [Processing]
Hint: main [Processing]
Hint: window [Processing]
Hint: abstract_window [Processing]
Hint: view [Processing]
Hint: typetraits [Processing]
Hint: tables [Processing]
Hint: hashes [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
Hint: math [Processing]
Hint: algorithm [Processing]
Hint: etcpriv [Processing]
Hint: sequtils [Processing]
Hint: types [Processing]
Hint: context [Processing]
Hint: opengl [Processing]
Hint: macros [Processing]
Hint: x [Processing]
Hint: xlib [Processing]
Hint: xutil [Processing]
Hint: keysym [Processing]
Hint: dynlib [Processing]
Hint: system_logger [Processing]
Hint: logging [Processing]
Hint: times [Processing]
Hint: os [Processing]
Hint: posix [Processing]
Hint: matrixes [Processing]
Hint: font [Processing]
Hint: unicode [Processing]
Hint: streams [Processing]
Hint: resource [Processing]
Hint: json [Processing]
Hint: lexbase [Processing]
Hint: async_http_request [Processing]
Hint: asyncdispatch [Processing]
Hint: oids [Processing]
Hint: endians [Processing]
Hint: heapqueue [Processing]
Hint: nativesockets [Processing]
Hint: net [Processing]
Hint: sets [Processing]
Hint: deques [Processing]
Hint: selectors [Processing]
Hint: epoll [Processing]
Hint: httpclient [Processing]
Hint: uri [Processing]
Hint: strtabs [Processing]
Hint: base64 [Processing]
Hint: mimetypes [Processing]
Hint: random [Processing]
Hint: httpcore [Processing]
Hint: asyncnet [Processing]
Hint: threadpool [Processing]
Hint: cpuinfo [Processing]
Hint: linux [Processing]
Hint: cpuload [Processing]
Hint: pathutils [Processing]
Hint: variant [Processing]
Hint: sdl2 [Processing]
Hint: unsigned [Processing]
Hint: timer [Processing]
Hint: mini_profiler [Processing]
Hint: sdl_perform_on_main_thread [Processing]
Hint: font_data [Processing]
Hint: stb_ttf_glyph_provider [Processing]
Hint: rect_packer [Processing]
Hint: ttf [Processing]
Hint: write_image_impl [Processing]
Hint: edtaa3func [Processing]
Hint: simple_table [Processing]
Hint: portable_gl [Processing]
Hint: image [Processing]
Hint: resource_cache [Processing]
Hint: oswalkdir [Processing]
Hint: load_image_impl [Processing]
Hint: worker_queue [Processing]
Hint: nimsl [Processing]
Hint: glsl_codegen [Processing]
Hint: composition [Processing]
Hint: helper_macros [Processing]
Hint: text_drawing [Processing]
Hint: animation [Processing]
Hint: animation_runner [Processing]
Hint: property_visitor [Processing]
Hint: class_registry [Processing]
Hint: serializers [Processing]
Hint: notification_center [Processing]
Hint: sdl_window [Processing]
Hint: event [Processing]
Hint: keyboard [Processing]
Hint: app [Processing]
Hint: window_event_handling [Processing]
Hint: view_event_handling [Processing]
Hint: view_event_handling_new [Processing]
Hint: linkage_details [Processing]
Hint: screen [Processing]
Hint: sdl_vk_map [Processing]
Hint: text_field [Processing]
Hint: control [Processing]
Hint: unistring [Processing]
Hint: table_view_cell [Processing]
Hint: pasteboard [Processing]
Hint: abstract_pasteboard [Processing]
Hint: key_commands [Processing]
Hint: formatted_text [Processing]
Hint: lower_bound [Processing]
Hint: scroll_view [Processing]
Hint: clip_view [Processing]
Hint: scroll_bar [Processing]
Hint: slider [Processing]
CC: main
CC: stdlib_system
CC: stdlib_sharedlist
CC: stdlib_locks
CC: nimx_window
CC: nimx_abstract_window
CC: nimx_view
CC: stdlib_typetraits
CC: stdlib_tables
CC: stdlib_sequtils
CC: stdlib_hashes
CC: stdlib_math
CC: stdlib_strutils
CC: stdlib_etcpriv
CC: stdlib_parseutils
CC: stdlib_algorithm
CC: nimx_types
CC: nimx_context
CC: opengl_opengl
CC: stdlib_macros
CC: x11_x
CC: x11_xlib
CC: x11_xutil
CC: x11_keysym
CC: stdlib_dynlib
CC: nimx_system_logger
CC: stdlib_logging
CC: stdlib_times
CC: stdlib_os
CC: stdlib_posix
CC: nimx_matrixes
CC: nimx_font
CC: stdlib_unicode
CC: stdlib_streams
CC: nimx_resource
CC: stdlib_json
CC: stdlib_lexbase
CC: async_http_request_async_http_request
CC: stdlib_asyncdispatch
CC: stdlib_oids
CC: stdlib_endians
CC: stdlib_heapqueue
CC: stdlib_nativesockets
CC: stdlib_net
CC: stdlib_sets
CC: stdlib_deques
CC: stdlib_selectors
CC: stdlib_epoll
CC: stdlib_httpclient
CC: stdlib_uri
CC: stdlib_strtabs
CC: stdlib_base64
CC: stdlib_mimetypes
CC: stdlib_random
CC: stdlib_httpcore
CC: stdlib_asyncnet
CC: stdlib_threadpool
CC: stdlib_cpuinfo
CC: stdlib_linux
CC: stdlib_cpuload
CC: nimx_pathutils
CC: variant_variant
CC: sdl2_sdl2
CC: stdlib_unsigned
CC: nimx_timer
CC: nimx_mini_profiler
CC: nimx_sdl_perform_on_main_thread
CC: nimx_font_data
CC: nimx_stb_ttf_glyph_provider
CC: nimx_rect_packer
CC: ttf_ttf
CC: nimx_write_image_impl
CC: ttf_edtaa3func
CC: nimx_simple_table
CC: nimx_portable_gl
CC: nimx_image
CC: nimx_resource_cache
CC: stdlib_oswalkdir
CC: nimx_load_image_impl
CC: nimx_worker_queue
CC: nimsl_nimsl
CC: nimsl_glsl_codegen
CC: nimx_composition
CC: nimx_helper_macros
CC: nimx_text_drawing
CC: nimx_animation
CC: nimx_animation_runner
CC: nimx_property_visitor
CC: nimx_class_registry
CC: nimx_serializers
CC: nimx_notification_center
CC: nimx_sdl_window
CC: nimx_event
CC: nimx_keyboard
CC: nimx_app
CC: nimx_window_event_handling
CC: nimx_view_event_handling
CC: nimx_view_event_handling_new
CC: nimx_linkage_details
CC: nimx_screen
CC: nimx_sdl_vk_map
CC: nimx_text_field
CC: nimx_control
CC: nimx_unistring
CC: nimx_table_view_cell
CC: nimx_pasteboard
CC: nimx_abstract_pasteboard
CC: nimx_key_commands
CC: nimx_formatted_text
CC: nimx_lower_bound
CC: nimx_scroll_view
CC: nimx_clip_view
CC: nimx_scroll_bar
CC: nimx_slider
Hint: [Link]
Hint: operation successful (82751 lines compiled; 7.564 sec total; 194.234MiB; Debug Build) [SuccessX]
Hint: /home/haiju/workspace/test-nimx/main [Exec]

6. 表示ができた!

f:id:haiju:20161227081504j:plain

[参考サイト]

How I Start.

github.com