ADVENTUREがらみでVRML 1.0 を見なくてはいけなくなった。これがまた古い規格なのでどこにも載っていないが,検索してみると OpenInventor というライブラリを使ったら読めるらしい。おお、Amira 関連で出てきとったな。と言うことで,とりあえずダウンロードしてコンパイルしてみる。(サンプルのアプリで開けるかもしれん)
/usr/include/architecture/ppc/math.h:224: error: declaration of C function 'float acos(float)' conflicts with
/usr/include/architecture/ppc/math.h:223: error: previous declaration 'double acos(double)' here
という種類のエラーが大量に出てくる。何だ?
直前の行を見てみると、
/usr/bin/g++ -D_DOUBLE_MATH_ONLY -I/usr/X11R6/include -I. -I../../lib/database/include -I../../lib/interaction/include -I../../lib/nodekits/include -I../../libSoXt/include -dynamic -fno-common -DIVPREFIX=\"/usr\" -O -DNDEBUG -c ppp.c++
この D_DOUBLE_MATH_ONLY で検索をかけると,以下の記事が出てきた。
In an effort to get OIV building for DarwinPorts, I had to make a series of patches. Most significantly, I needed to build the library before installing it. I needed to use plain 'make' before running 'make install'. The default makefiles aren't really set up to accommodate that, as they expect to the find libInventor in the installed location. I'm not sure if this makes a mess of linking, but perhaps using libtool with install_name could resolve problems? Anyhow, here are the changes that I made:
make/ivcommondefs: removed MATHDEFS for darwin, as apple-gcc 3.3 doesn't need them anymore (same as Edward Patel's patch)
make/localrules.apple: added -lmx for math library linking (same as Edward Patel's patch)
libFL/ang/flfreetype.h: new versions of freetype2 seem to require a different way to include the header
several GNUmakefiles: added LLDOPTS with $(IVDEPTH)/lib and $(IVDEPTH)/libSoXt so that in-place builds work
Chris
さらに情報をあさっていたら,OpenInventorをMacOSXに入れてるページを見つけた。
Open Inventor on Darwin
In the spring semester of 2005 I took Dr. Banks's Scientific Visualization course. It was a fascinating course that taught me quite a bit, but there was one problem.
It used SGI's Open Inventor extensively, and my machine of choice was my trusty iBook. Unwilling to lose my mobility just so I could make a few images, I gritted my teeth and managed to compile a working version of Open Inventor. This page walks you through the necessary steps.
Things you will need
1. A working Mac running OS X. I use 10.3 (Jaguar), and I imagine that Tiger will work just as well.
2. Motif, lesstif, or if you have neither, [[Fink]], for installation of lesstif (should require just 'fink install lesstif').
3. The Open Inventor source code. Version 2.1.5-10 is the latest.
4. Apple's X11 implementation. Since Open Inventor is in no way OS X native, it still expects an X server, so make sure you can provide one.
Procedure
1. There are some interesting errors in the math.h file for ppc architecture. The Inventor source defines _DOUBLE_MATH_ONLY (which is supposed to prevent predefined functions that use or return variable of type floats), but it isn't properly implemented by the header file, so that needs to be changed. Make a backup copy of /usr/include/architecture/ppc/math.h, then open it for editing.
2. On or about line 210 or so of this file there will be the following line:
extern float acosf( float );
Replace the line with the following three lines:
#ifndef _DOUBLE_MATH_ONLY
extern float acosf( float );
#endif
3. The previous step set the float version of the function acos() so that it would not be defined if _DOUBLE_MATH_ONLY is set. The following functions, found in the same file, also need to be modified similarly:
• asinf(float)
• atanf(float)
• atan2f(float)
• cosf(float)
• sinf(float)
• tanf(float)
• powf(float)
• sqrtf(float)
4. Once these functions have been appropriatly modified, save the file (you do have a backup, right?).
5. Download the Open Inventor source code linked above if you haven't already. Unpack it to a convenient directory, and cd to that directory. I'm assuming that you unpacked it to /usr/src/inventor
6. More file editing! Make a backup of the file /usr/src/inventor/make/ivcommondefs, then edit it in the following manner (pay close attention, this is poorly laid out):
1. Find the line ifeq ($(usingDarwin), 1)
2. the next series of lines should look like this:
FREETYPE = 1
CC = /usr/bin/gcc
C++ = /usr/bin/g++
LD = /usr/bin/libtool
ARFLAGS = vrs
INSTALL = /usr/bin/install
LCXXDEFS += $(MATHDEFS)
LCDEFS += $(MATHDEFS)
DARWINOPTS = -dynamic -fno-common
LCXXOPTS += $(DARWINOPTS)
LCOPTS += $(DARWINOPTS)
X11DIR = /usr/X11R6
X11INCDIR = $(X11DIR)/include
X11LIBDIR = $(X11DIR)/lib
3. After these lines (after the first cluster of lines dealing with X11, for those too impatient to read through all that), add the following lines:
FINKDIR=/sw
FINKLIBDIR=$(FINKDIR)/lib
FINKINCDIR=$(FINKDIR)/include
4. Those lines tell the compiler where to find libraries and headers that have been installed by Fink. These are useful, as using Fink to install Mesa is infinitely easier than doing it by hand. Anyway, the next lines look like this:
LCXXINCS += -I$(X11INCDIR)
LCINCS += -I$(X11INCDIR) -I$(X11INCDIR)/freetype2
LDDSOOPTS += -dynamic -all_load -L$(X11LIBDIR)
LDOPTS += -multiply_defined suppress -L$(X11LIBDIR)
CXXDSOOPTS += -bundle -flat_namespace -undefined suppress -L$(X11LIBDIR)
LOCALRULES = $(IVDEPTH)/make/localrules.apple
endif
5. Everywhere you see a -L$(X11LIBDIR) in the above lines, edit that line to add -L$(FINKLIBDIR) to the end of it. Similarly, whenever you see a -I$(X11INCDIR), add -I$(FINKINCDIR) to the end of that line.
6. Save the file.
7. From here on it's relatively smooth sailing. Return to the root of the Inventor source tree and read the README.FIRST included with the source code. You should be able to compile with little to no trouble if you follow the instructions (make sure to notice the Darwin specific ones!).
ということで直してみたが,今度は
powerpc-apple-darwin8-gcc-4.0.0: /freetype2: No such file or directory
というエラーが出て止まる。フォントを指定する部分が切れているらしいので,
To use the FreeType interface, set the FL_FONT_PATH environment
variable to the directory where TrueType fonts are installed
(defaults to /usr/share/data/fonts) and run the linkTrueType.sh
script in libFL/freetype as root.
というのを読んで,
setenv FL_FONT_PATH “/sw/src/xfree86-4.3.99.16-2/xc/lib/freetype2/”
としてから
sh linkTrueType.sh
を走らせたらさらに少し進んだ。こんどは
/usr/bin/ld: warning -L: directory name (/usr/src//usr/lib) does not exist
というエラーが出てくる。//があるのがおかしいので,該当部分を見てみると(ivcommondefs)
#
# Inventor install directories.
#
IVPREFIX = /usr
LCXXOPTS += -DIVPREFIX=¥"$(IVPREFIX)¥"
LCOPTS += -DIVPREFIX=¥"$(IVPREFIX)¥"
IVBINDIR = $(IVROOT)/$(IVPREFIX)/bin
IVLIBDIR = $(IVROOT)/$(IVPREFIX)/lib
IVDLIBDIR = $(IVLIBDIR)/InventorDebug
IVHDRTOP = $(IVROOT)/$(IVPREFIX)/include/Inventor
IVHDRDIR = $(IVHDRTOP)/$(HDRSUBDIR)
IVMAN1DIR = $(IVROOT)/$(IVPREFIX)/man/man1
IVMAN3DIR = $(IVROOT)/$(IVPREFIX)/man/man3
IVHELPDIR = $(IVROOT)/$(IVPREFIX)/share/help
IVDATADIR = $(IVROOT)/$(IVPREFIX)/share/data/models
IVDEMODIR = $(IVROOT)/$(IVPREFIX)/demos
IVDEMOBINDIR = $(IVDEMODIR)/Inventor
IVDEMODATADIR = $(IVDEMODIR)/data/Inventor
となっている。とりあえずIVROOT を””にしてみる(ルートにインストールする)とそのエラーは消えるが,
/usr/bin/g++ -L//usr/lib -multiply_defined suppress -L/usr/X11R6/lib -L/sw/lib ppp.o -lm -lXm -lXt -lX11 -lGLU -lGL -liconv -ldl -lcc_dynamic -lstdc++ -lmx -o ppp
/usr/bin/ld: can't locate file for: -lcc_dynamic
がでてくる。これでも//usr/lib というのがでてくるが...
前述のソースのIVPREFIX をusr のみにしてみるが、次は
/usr/bin/ld: can't locate file for: -lcc_dynamic
というのが出てくる。対応するライブラリ(libgcc.a)を探して,
LD = /usr/bin/libtool
とあるところを
LD = /usr/local/lib
に変えてみる。
どうもうまくいかん。そのうちにADVENTURE のホームページを見ていたら,Meshmanというソフトを発見。これを使ったら普通に見えるので、ばかばかしくなってインストール終了。
後日再チャレンジ。マニュアルを読み直して,
5. Everywhere you see a -L$(X11LIBDIR) in the above lines, edit that line to add -L$(FINKLIBDIR) to the end of it. Similarly, whenever you see a -I$(X11INCDIR), add -I$(FINKINCDIR) to the end of that line.
の部分を,引用されている部分のみにする。
「ライブラリが定義されていない」というエラーが二つばかり出た「-lXm」「-lcc_dynamic」ので、単純に削ったらさらにコンパイラが通る。
SoText2.c++: In member function 'SbBool SoBitmapFontCache::convertToUCS(uint32_t, const SoMFString&)':
SoText2.c++:781: error: invalid conversion from 'char**' to 'const char**'
SoText2.c++:781: error: initializing argument 2 of 'size_t libiconv(void*, const char**, size_t*, char**, size_t*)'
make[5]: *** [SoText2.o] Error 1
というエラーが出た。とりあえず、char と const char の差は何だ?
そもそも/usr/bin/ldって何だ?とおもって、manをかけてみると,リンカらしい。
ものすごく久しぶりに再度コンパイルにチャレンジ。-lcc_dynamic がない、とか出てくるので,何かなと思ってmiでマルチファイル検索をかけてみたら,appleローカルの設定らしい。面倒なので削ってみたら,かなりコンパイルが進む。何だ?
最終更新:2007年01月19日 05:41