投稿者 トピック: MacでのSimutrans及びmakeobjコンパイル(on Xcode)  (参照数 11269 回)

THLeaderH

  • 各駅停車
  • *
  • 投稿: 18
Xcodeを使ってソースからSimutransの本体及びmakeobjをコンパ イルしたいのですが、どうすればいいのでしょうか。international forumを漁ってみたものの、7年前のトピックである上にコマンドライン上でのコンパイルだったので質問させていただきました。

私の環境は以下のとおりです
OS:Mac OSX 10.7.5(Lion)
Xcode4インストール済み
ビルドを試みるバージョン:112.3及びそれに付随するmakeobj

パッチ開発も考えているのでXcodeでプロジェクト読み込み、コンパイルが出来る方がいいです。
回答よろしくお願い致します。

kagari

  • 各駅停車
  • *
  • 投稿: 5
Xcode用プロジェクトファイルは見当たりませんね…。開発者にMacユーザーが少ないとのことで、Mac版はあまり積極的に維持されていない様子です。
MacPortsやHomebrew等をインストールした環境でのコマンドラインコ ンパイルが現時点でもっとも容易なのではないかと思います。

THLeaderH

  • 各駅停車
  • *
  • 投稿: 18
NetBeans(7.0.1)につっこんだらコンパイルできそうなので(コマンドライン上でのコンパイルと同じ扱いになる)フォーラムに落ちてる情報を拾い拾いしながらやってみたらSDL関連でエラー吐いてコンパイルできませんでした。エラーは以下のとおりです(本体のほう)
コード: [選択]
make: sdl-config: Command not found
make: sdl-config: Command not found
===> CXX simsys_s.cc
simsys_s.cc:7:17: warning: SDL.h: No such file or directory
simsys_s.cc:165:24: error: missing binary operator before token "("
simsys_s.cc:26: error: 'Uint8' does not name a type
simsys_s.cc:51: error: 'Uint8' does not name a type
simsys_s.cc:76: error: 'Uint8' does not name a type
simsys_s.cc:81: error: expected initializer before '*' token
simsys_s.cc:91: error: expected initializer before '*' token
simsys_s.cc:92: error: expected initializer before '*' token
simsys_s.cc:93: error: expected initializer before '*' token
simsys_s.cc:130: error: 'SDL_Rect' does not name a type
simsys_s.cc: In function 'bool dr_os_init(const int*)':
simsys_s.cc:141: error: 'SDL_INIT_VIDEO' was not declared in this scope
simsys_s.cc:141: error: 'SDL_INIT_NOPARACHUTE' was not declared in this scope
simsys_s.cc:141: error: 'SDL_Init' was not declared in this scope
simsys_s.cc:142: error: 'SDL_GetError' was not declared in this scope
simsys_s.cc:157: error: 'SDL_Quit' was not declared in this scope
simsys_s.cc: In function 'resolution dr_query_screen_resolution()':
simsys_s.cc:173: error: 'SDL_Rect' was not declared in this scope
simsys_s.cc:173: error: expected primary-expression before 'const'
simsys_s.cc:173: error: expected `;' before 'const'
simsys_s.cc:174: error: 'modi' was not declared in this scope
simsys_s.cc:174: error: expected primary-expression before ')' token
simsys_s.cc: In function 'int dr_os_open(int, int, int)':
simsys_s.cc:208: error: 'Uint32' was not declared in this scope
simsys_s.cc:208: error: expected `;' before 'flags'
simsys_s.cc:220: error: 'flags' was not declared in this scope
simsys_s.cc:220: error: 'SDL_FULLSCREEN' was not declared in this scope
simsys_s.cc:220: error: 'SDL_RESIZABLE' was not declared in this scope
simsys_s.cc:222: error: 'SDL_HWSURFACE' was not declared in this scope
simsys_s.cc:222: error: 'SDL_DOUBLEBUF' was not declared in this scope
simsys_s.cc:226: error: 'SDL_putenv' was not declared in this scope
simsys_s.cc:227: error: 'screen' was not declared in this scope
simsys_s.cc:227: error: 'SDL_SetVideoMode' was not declared in this scope
simsys_s.cc:230: error: 'SDL_GetError' was not declared in this scope
simsys_s.cc:234: error: expected initializer before '*' token
simsys_s.cc:236: error: 'SDL_VideoDriverName' was not declared in this scope
simsys_s.cc:237: error: 'vi' was not declared in this scope
simsys_s.cc:242: error: 'SDL_EnableUNICODE' was not declared in this scope
simsys_s.cc:243: error: 'SDL_DEFAULT_REPEAT_DELAY' was not declared in this scope
simsys_s.cc:243: error: 'SDL_DEFAULT_REPEAT_INTERVAL' was not declared in this scope
simsys_s.cc:243: error: 'SDL_EnableKeyRepeat' was not declared in this scope
simsys_s.cc:246: error: 'SDL_WM_SetCaption' was not declared in this scope
simsys_s.cc:247: error: 'SDL_ShowCursor' was not declared in this scope
simsys_s.cc:248: error: 'arrow' was not declared in this scope
simsys_s.cc:248: error: 'SDL_GetCursor' was not declared in this scope
simsys_s.cc:249: error: 'hourglass' was not declared in this scope
simsys_s.cc:249: error: 'hourglass_cursor' was not declared in this scope
simsys_s.cc:249: error: 'hourglass_cursor_mask' was not declared in this scope
simsys_s.cc:249: error: 'SDL_CreateCursor' was not declared in this scope
simsys_s.cc:250: error: 'blank' was not declared in this scope
simsys_s.cc:250: error: 'blank_cursor' was not declared in this scope
simsys_s.cc: In function 'void dr_os_close()':
simsys_s.cc:266: error: 'hourglass' was not declared in this scope
simsys_s.cc:266: error: 'SDL_FreeCursor' was not declared in this scope
simsys_s.cc:267: error: 'blank' was not declared in this scope
simsys_s.cc: In function 'int dr_textur_resize(short unsigned int**, int, int)':
simsys_s.cc:281: error: 'screen' was not declared in this scope
simsys_s.cc:281: error: 'SDL_UnlockSurface' was not declared in this scope
simsys_s.cc:283: error: 'Uint32' was not declared in this scope
simsys_s.cc:283: error: expected `;' before 'flags'
simsys_s.cc:293: error: 'screen' was not declared in this scope
simsys_s.cc:297: error: 'flags' was not declared in this scope
simsys_s.cc:297: error: 'SDL_SetVideoMode' was not declared in this scope
simsys_s.cc:309: error: 'screen' was not declared in this scope
simsys_s.cc: In function 'short unsigned int* dr_textur_init()':
simsys_s.cc:320: error: 'screen' was not declared in this scope
simsys_s.cc:320: error: 'SDL_LockSurface' was not declared in this scope
simsys_s.cc:322: error: 'screen' was not declared in this scope
simsys_s.cc: In function 'unsigned int get_system_color(unsigned int, unsigned int, unsigned int)':
simsys_s.cc:333: error: 'screen' was not declared in this scope
simsys_s.cc:333: error: 'Uint8' was not declared in this scope
simsys_s.cc:333: error: expected `)' before 'g'
simsys_s.cc:333: error: expected `)' before 'b'
simsys_s.cc:333: error: 'SDL_MapRGB' was not declared in this scope
simsys_s.cc: At global scope:
simsys_s.cc:331: warning: unused parameter 'r'
simsys_s.cc:331: warning: unused parameter 'g'
simsys_s.cc:331: warning: unused parameter 'b'
simsys_s.cc: In function 'void dr_flush()':
simsys_s.cc:354: error: 'screen' was not declared in this scope
simsys_s.cc:354: error: 'SDL_UnlockSurface' was not declared in this scope
simsys_s.cc:355: error: 'SDL_Flip' was not declared in this scope
simsys_s.cc:356: error: 'SDL_LockSurface' was not declared in this scope
simsys_s.cc:361: error: 'screen' was not declared in this scope
simsys_s.cc:361: error: 'SDL_Rects' was not declared in this scope
simsys_s.cc:361: error: 'SDL_UpdateRects' was not declared in this scope
simsys_s.cc:365: error: 'screen' was not declared in this scope
simsys_s.cc:365: error: 'SDL_UpdateRect' was not declared in this scope
simsys_s.cc: In function 'void dr_textur(int, int, int, int)':
simsys_s.cc:378: error: 'screen' was not declared in this scope
simsys_s.cc:381: error: 'screen' was not declared in this scope
simsys_s.cc:393: error: 'SDL_Rects' was not declared in this scope
simsys_s.cc: In function 'void move_pointer(int, int)':
simsys_s.cc:408: error: 'Uint16' was not declared in this scope
simsys_s.cc:408: error: expected `)' before 'y'
simsys_s.cc:408: error: 'SDL_WarpMouse' was not declared in this scope
simsys_s.cc: At global scope:
simsys_s.cc:406: warning: unused parameter 'x'
simsys_s.cc:406: warning: unused parameter 'y'
simsys_s.cc: In function 'void set_pointer(int)':
simsys_s.cc:415: error: 'hourglass' was not declared in this scope
simsys_s.cc:415: error: 'arrow' was not declared in this scope
simsys_s.cc:415: error: 'SDL_SetCursor' was not declared in this scope
simsys_s.cc: In function 'int dr_screenshot(const char*, int, int, int, int)':
simsys_s.cc:432: error: 'SDL_GetVideoSurface' was not declared in this scope
simsys_s.cc:432: error: 'SDL_SaveBMP' was not declared in this scope
simsys_s.cc: At global scope:
simsys_s.cc:425: warning: unused parameter 'x'
simsys_s.cc:425: warning: unused parameter 'y'
simsys_s.cc:425: warning: unused parameter 'w'
simsys_s.cc:425: warning: unused parameter 'h'
simsys_s.cc: In function 'unsigned int ModifierKeys()':
simsys_s.cc:442: error: 'SDLMod' was not declared in this scope
simsys_s.cc:442: error: expected `;' before 'mod'
simsys_s.cc:445: error: 'mod' was not declared in this scope
simsys_s.cc:445: error: 'KMOD_SHIFT' was not declared in this scope
simsys_s.cc:446: error: 'KMOD_CTRL' was not declared in this scope
simsys_s.cc: At global scope:
simsys_s.cc:450: error: 'Uint8' was not declared in this scope
simsys_s.cc:451: error: expected ',' or ';' before '{' token
simsys_s.cc: In function 'void internal_GetEvents(bool)':
simsys_s.cc:461: error: 'SDL_Event' was not declared in this scope
simsys_s.cc:461: error: expected `;' before 'event'
simsys_s.cc:462: error: 'event' was not declared in this scope
simsys_s.cc:468: error: 'SDL_WaitEvent' was not declared in this scope
simsys_s.cc:469: error: 'SDL_PollEvent' was not declared in this scope
simsys_s.cc:470: error: 'SDL_MOUSEMOTION' was not declared in this scope
simsys_s.cc:477: error: 'SDL_PollEvent' was not declared in this scope
simsys_s.cc:482: error: 'SDL_MOUSEMOTION' was not declared in this scope
simsys_s.cc:487: error: 'conv_mouse_buttons' cannot be used as a function
simsys_s.cc:490: error: 'SDL_MOUSEMOTION' was not declared in this scope
simsys_s.cc:496: error: 'SDL_VIDEORESIZE' was not declared in this scope
simsys_s.cc:504: error: 'SDL_VIDEOEXPOSE' was not declared in this scope
simsys_s.cc:510: error: 'SDL_MOUSEBUTTONDOWN' was not declared in this scope
simsys_s.cc:515: error: 'SDL_GetMouseState' was not declared in this scope
simsys_s.cc:515: error: 'conv_mouse_buttons' cannot be used as a function
simsys_s.cc:525: error: 'SDL_MOUSEBUTTONUP' was not declared in this scope
simsys_s.cc:530: error: 'conv_mouse_buttons' cannot be used as a function
simsys_s.cc:538: error: 'SDL_KEYDOWN' was not declared in this scope
simsys_s.cc:545: error: 'SDL_GetModState' was not declared in this scope
simsys_s.cc:545: error: 'KMOD_NUM' was not declared in this scope
simsys_s.cc:547: error: 'SDLKey' was not declared in this scope
simsys_s.cc:547: error: expected `;' before 'const'
simsys_s.cc:548: error: 'sym' was not declared in this scope
simsys_s.cc:549: error: 'SDLK_DELETE' was not declared in this scope
simsys_s.cc:550: error: 'SDLK_DOWN' was not declared in this scope
simsys_s.cc:551: error: 'SDLK_END' was not declared in this scope
simsys_s.cc:552: error: 'SDLK_HOME' was not declared in this scope
simsys_s.cc:553: error: 'SDLK_F1' was not declared in this scope
simsys_s.cc:554: error: 'SDLK_F2' was not declared in this scope
simsys_s.cc:555: error: 'SDLK_F3' was not declared in this scope
simsys_s.cc:556: error: 'SDLK_F4' was not declared in this scope
simsys_s.cc:557: error: 'SDLK_F5' was not declared in this scope
simsys_s.cc:558: error: 'SDLK_F6' was not declared in this scope
simsys_s.cc:559: error: 'SDLK_F7' was not declared in this scope
simsys_s.cc:560: error: 'SDLK_F8' was not declared in this scope
simsys_s.cc:561: error: 'SDLK_F9' was not declared in this scope
simsys_s.cc:562: error: 'SDLK_F10' was not declared in this scope
simsys_s.cc:563: error: 'SDLK_F11' was not declared in this scope
simsys_s.cc:564: error: 'SDLK_F12' was not declared in this scope
simsys_s.cc:565: error: 'SDLK_F13' was not declared in this scope
simsys_s.cc:566: error: 'SDLK_F14' was not declared in this scope
simsys_s.cc:567: error: 'SDLK_F15' was not declared in this scope
simsys_s.cc:568: error: 'SDLK_KP0' was not declared in this scope
simsys_s.cc:569: error: 'SDLK_KP1' was not declared in this scope
simsys_s.cc:570: error: 'SDLK_KP2' was not declared in this scope
simsys_s.cc:571: error: 'SDLK_KP3' was not declared in this scope
simsys_s.cc:572: error: 'SDLK_KP4' was not declared in this scope
simsys_s.cc:573: error: 'SDLK_KP5' was not declared in this scope
simsys_s.cc:574: error: 'SDLK_KP6' was not declared in this scope
simsys_s.cc:575: error: 'SDLK_KP7' was not declared in this scope
simsys_s.cc:576: error: 'SDLK_KP8' was not declared in this scope
simsys_s.cc:577: error: 'SDLK_KP9' was not declared in this scope
simsys_s.cc:578: error: 'SDLK_LEFT' was not declared in this scope
simsys_s.cc:579: error: 'SDLK_PAGEDOWN' was not declared in this scope
simsys_s.cc:580: error: 'SDLK_PAGEUP' was not declared in this scope
simsys_s.cc:581: error: 'SDLK_RIGHT' was not declared in this scope
simsys_s.cc:582: error: 'SDLK_UP' was not declared in this scope
simsys_s.cc:583: error: 'SDLK_PAUSE' was not declared in this scope
simsys_s.cc:628: error: 'SDL_MOUSEMOTION' was not declared in this scope
simsys_s.cc:633: error: 'conv_mouse_buttons' cannot be used as a function
simsys_s.cc:637: error: 'SDL_ACTIVEEVENT' was not declared in this scope
simsys_s.cc:638: error: 'SDL_KEYUP' was not declared in this scope
simsys_s.cc:643: error: 'SDL_QUIT' was not declared in this scope
simsys_s.cc: In function 'void show_pointer(int)':
simsys_s.cc:673: error: 'arrow' was not declared in this scope
simsys_s.cc:673: error: 'blank' was not declared in this scope
simsys_s.cc:673: error: 'SDL_SetCursor' was not declared in this scope
simsys_s.cc: In function 'void ex_ord_update_mx_my()':
simsys_s.cc:679: error: 'SDL_PumpEvents' was not declared in this scope
simsys_s.cc: In function 'long unsigned int dr_time()':
simsys_s.cc:685: error: 'SDL_GetTicks' was not declared in this scope
simsys_s.cc: In function 'void dr_sleep(uint32)':
simsys_s.cc:691: error: 'SDL_Delay' was not declared in this scope
make: *** [build/default/simsys_s.o] Error 1

構築 失敗 (実行結果 2、 合計時間: 1s)

普段simutransをプレイしているのでSDLがインストールされていないはず がないのですが、(念のためソースから./configure→makeでインストールしなおしたつもりです)SDLがないとエラーが出ているのが不思議です。
ちなみに今まで本体のソースに行った改変としては
・osx.mkを準備した
・config.templateをいじった(#を外したり云々)
ぐらいです。何が足りないのか教えてください、お願いします。

kagari

  • 各駅停車
  • *
  • 投稿: 5
NetBeansについては何ともお答えできません。
私自身はMacPortsからインストールしたSDL2で問題なくビルドできました が、そちらの方法を一度試されてみてはいかがでしょうか?
いずれにせよ、受け入れてもらえる形でパッチを用意するにはコマンドラインが必要になると思われますので……。

THLeaderH

  • 各駅停車
  • *
  • 投稿: 18
MacPortsをインストールして"sudo port install libsdl2"と入力し、SDL2とSDL2_mixerのインストールを行いましたが(ちゃんとコマンドライン上でmakeをしても)全く同じエラーが出ます。
ちなみにport installed(MacPortsによりインストールされた項目を確認するコマンド)を打ったところ以下のように出ました。
コード: [選択]
The following ports are currently installed:
  expat @2.1.0_0 (active)
  flac @1.3.1_2 (active)
  gettext @0.19.4_0 (active)
  jpeg @9a_1 (active)
  libiconv @1.14_0 (active)
  libmikmod @3.2.0_0 (active)
  libogg @1.3.2_1 (active)
  libpng @1.6.16_0 (active)
  libsdl2 @2.0.3_0 (active)
  libsdl2_image @2.0.0_1 (active)
  libsdl2_mixer @2.0.0_0 (active)
  libvorbis @1.3.4_0 (active)
  ncurses @5.9_2 (active)
  smpeg2 @2.0.0_0 (active)
  tiff @4.0.3_4 (active)
  xz @5.0.7_0 (active)
  zlib @1.2.8_0 (active)

見たところSDLもきちっとインストールされているようですが何が不足しているので しょうか・・・

kagari

  • 各駅停車
  • *
  • 投稿: 5
正直あまり状況が読めないのですが、
  • libsdl2ではなくてlibsdlをインストールする(SDL1を使う場合)
  • BACKENDをsdl2に設定する(SDL2を使う場合)
といった所ではないかと。SDL2版はここ一年ほどで追加されたものですので、112をコンパイルする場合は前者になるでしょうね。

THLeaderH

  • 各駅停車
  • *
  • 投稿: 18
MacPortsでSDLの1をインストールしなおしたらうまくいきました :D
ちなみにNetBeansのBashはmacports等をうまく認識してくれなか ったのでコマンドでやろうと思いますです。

コンパイルは本体もmakeobjの方もうまくいきましたが、本体は正常に動作したのに対し、makeobjを実際に使用したところ次のようなエラーがでました。
コード: [選択]
Makeobj version 55.2 for Simutrans 112.3 and higher

Makeobj version 55.2 for Simutrans 112.3 and higher

(c) 2002-2012 V. Meyer, Hj. Malthaner, M. Pristovsek & Simutrans development team

Image size is set to 128x128
writing invidual files to ./
   reading file ./Keihan800.dat
   writing file ./vehicle.Keihan_800_Mc1.pak
      packing vehicle.Keihan_800_Mc1
libpng warning: Application built with libpng-1.5.14 but running with 1.6.16
read_png: Could not create read struct.
↑モンダイなのは一番下の行です。

実際出来上がったpakファイルはpngファイルよりもサイズがかなり小さいので正 常に生成されてないものと思われます。実行側のライブラリの欠落とかが原因なんですかね・・・

THLeaderH

  • 各駅停車
  • *
  • 投稿: 18
とりあえず本体のコンパイルはきちっとうまくいったということで、自信の備忘録として、またMacでsimutransの開発をしようとする人たちがスムーズにコンパイル作業できるように手順を示しておきます。
ここまで親身に対応してくださったkagari氏ありがとうございました。

なおターミナルの"cd"コマンドは知っている前提で話を進めます。

・本体のビルド
  • XCodeをインストールしてない人はMacAppStoreでいれておく。(gccが必要なためです。後述のmacportsでインストールしてもうまくいかないようです。4〜5GBくらい喰われますが諦めましょう。)
  • simutransのソースコードをDLして好きな場所に置く。
  • config.template(DLしたフォルダの一番上の階層にあります)を開いて(テキストエディタとかで開けます)
    「#BACKEND = sdl」
    「#COLOUR_DEPTH = 16」
    「#OSTYPE = mac」
    「#DEBUG = 3」
    「#OPTIMISE = 1」
    の行の先頭の"#"を外す
    例えば「#BACKEND = sdl」の行なら「BACKEND = sdl」となります。
    さらに、「#FLAGS = -DUSE_C」の行を「FLAGS = -DSTEPS16」と書き換えてください(冒頭の#を外すのは必須らしいですが後ろを書き換えるのが本当に必要なのかよくわかりません、ただコレでうまくいったので書き換えておいたほうがいいでしょう。)
  • osx.mk(https://github.com/aburch/simutrans/blob/master/OSX/osx.mkにあります)を準備して「OSX」フォルダの中に入れる。(ファイルの形でDLするやり方がよくわからないのでリンクしたページのソースをテキストエディタとかにコピペしてosx.mkの名前で保存すればいいと思います。)

    ここまででファイルの準備は終わり
  • MacPorts(https://www.macports.org/)をインストールする(このソフトウェアはこの先で使うプログラムをインストールするのに使います)
  • MacPortsを使ってlibsdlをインストールする。具体的にはターミナルで
    「sudo port install libsdl」
    と入力。インストール時にはシステムのパスワードを求められます。(libsdl2をインストールしてもうまくいきません。)
    なおmakeobjコンパイル時に必要になるlibpng、pkgconfigも一緒にインストールしておきましょう。インストールは先程のコマンドの"libsdl"をインストールするソフトウェア名に置き換えるだけです。
    インストールが終わったら
    「port installed」
    でMacportsでインストールされたソフトウェア一覧が出てくるのでその中にイ ンストールしたものが入っているか確認するといいと思います。
  • cdコマンドでsimutransのソースフォルダのディレクトリに移動して、ターミナルで
    「make」
    と入力して実行
これでソースフォルダ中の/build/defaultにsimという名前で実行ファイルが生成されるはずです。もちろん単体では動かないので普段プレイしてるpakとかが入ってるところに放りこんであげてください。(すんません掲示板の制限でコマンドを別枠で囲めませんでした。)
なおバージョン120以降の場合、config.templateに「sdl2」という選択肢があると思います。そちらを選択した場合はMacPortsでlibsdl2の方を入れるとうまくいくようです。

・Makeobjのビルド(こっちはビルドはできましたが正常動作していないので参考程度に。)
  • ソースのDL、MacPortsでlibsdl、libpng、pkgconfigをインストール(詳しくは上の項目を見てください)
  • uncommon.ukを準備してmakeobjフォルダの中に配置する(https://github.com/aburch/simutrans/blob/master/uncommon.mkから先程のosx.mkと同じ要領で作業してください。)
  • ターミナルで、cdコマンドでmakeobjフォルダに移動して、makeすればソースフォルダの/build/default/makeobjに実行ファイルが生成されます(makeobj.ccが入っているフォルダではないので注意)

不備があれば教えてください。訂正いたします。

kagari

  • 各駅停車
  • *
  • 投稿: 5
遅くなりました。解決されたようで良かったです。
引用
config.template(DLしたフォルダの一番上の階層にあります)を開いて(テキストエディタとかで開けます)
「#BACKEND = sdl」
「#COLOUR_DEPTH = 16」
「#OSTYPE = mac」
「#DEBUG = 3」
「#OPTIMISE = 1」
の行の先頭の"#"を外す
DEBUGとOPTIMISEは基本的に両立しません。デバッグ用コードを埋め込んだバイナリは遅くなり、最適化したバイナリはデバッグが困難になります。
それと、config.templateはあくまで雛形として元のまま残しておくほうがよろしいかと。ファイル冒頭にconfig.defaultという名前でコピーした上で編集するように、といった意味のコメントがあります。
引用
さらに、「#FLAGS = -DUSE_C」の行を「FLAGS = -DSTEPS16」と書き換えてください(冒頭の#を外すのは必須らしいですが後ろを書き換えるのが本当に必要なのかよくわかりません、ただコレでうまくいったので書き換えておいたほうがいいでしょう。)
これは……。何を定義しているのかよく分からないのですが、THLeaderHさんの環境では必須だったのでしょうか?