桜、抹茶、白、日記

名古屋市在住のC++使いのcoderの日記だったもの。

続々・Autotools

d:id:youandi:20121214:p1
今日困ったのは、64bitOS上で32bitバイナリを作成するMakefileをどうすれば生成できるのか。

gcc - Configure fails to detect proper ld on a 64-bit system with 32-bit userland - Stack Overflow
http://stackoverflow.com/questions/12828687/configure-fails-to-detect-proper-ld-on-a-64-bit-system-with-32-bit-userland

上記では、configureの引数でビルドターゲットを指定しろってレスが付いてました。

$ ./configure \
 --host=i686-unknown-linux-gnu \
 --build=i686-unknown-linux-gnu \
 --target=i686-unknown-linux-gnu

この方法だけでは足りない感じ。

$ CXX="g++ -m32" ./configure \
 --host=i686-unknown-linux-gnu \
 --build=i686-unknown-linux-gnu \
 --target=i686-unknown-linux-gnu

コンパイラに32bitバイナリ生成オプションを付けたら、ひとまず32bitバイナリは出来たけども、生成されたMakefileには64bit版のヘッダーパスやライブラリパスが設定されてしまっていた。
他の方法としては、コンパイラに32bit指定を付けるのではなく、CFLAGSやCXXFLAGSに指定する方法があるけど違いはなかった。