.hsコードとメインの.cプログラムを取得するプロジェクトをセットアップし、LLVMコンパイラーを使用して静的にリンクされた実行可能ファイルを作成したいと思います。ghcコマンドラインオプションを使用して、.hsを構築し、スタブを生成し、ghcを完全に使用してドライバーアプリケーションをコンパイルおよびリンクすることができます。ただし、Xcode内でさまざまな問題が発生します。
私の最初の問題は、もちろんXcodeで32ビットのコンパイル環境を使用する必要があるということでした。それが解決したので、HsFFI.hを明示的に含めるためにパスをいじる必要がありました。これで解決し、リンカーエラーが発生します。
Ld "build/Debug/FFI Test.app/Contents/MacOS/FFI Test" normal i386
cd "/Users/rcl/TestXCodeProjects/FFI Test"
setenv MACOSX_DEPLOYMENT_TARGET 10.6
/Developer/usr/bin/clang -arch i386
-isysroot /Developer/SDKs/MacOSX10.6.sdk
"-L/Users/rcl/TestXCodeProjects/FFI Test/build/Debug"
"-L/Users/rcl/TestXCodeProjects/FFI Test/FFI Test"
"-F/Users/rcl/TestXCodeProjects/FFI Test/build/Debug"
-filelist "/Users/rcl/TestXCodeProjects/FFI Test/build/FFI Test.build/
Debug/FFI Test.build/Objects-normal/i386/FFI Test.LinkFileList"
-mmacosx-version-min=10.6 -framework Cocoa
"/Users/rcl/TestXCodeProjects/FFI Test/FFI Test/ForeignExportCost.a"
-o "/Users/rcl/TestXCodeProjects/FFI Test/build/Debug/FFI Test.app/
Contents/MacOS/FFI Test"
Undefined symbols for architecture i386:
"_hs_init", referenced from:
-[FFI_TestAppDelegate applicationDidFinishLaunching:] in FFI_TestAppDelegate.o
"_simpleFunction", referenced from:
-[FFI_TestAppDelegate applicationDidFinishLaunching:] in FFI_TestAppDelegate.o
"_hs_exit", referenced from:
-[FFI_TestAppDelegate applicationDidFinishLaunching:] in FFI_TestAppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
「simpleFunction」は「ForeignExportCost.a」ライブラリにあり、次のようにghcを使用してコンパイルします。
ghc -no-hs-main -fPIC -c ForeignExportCost.hs
ghc -no-hs-main -shared ForeignExportCost.o -o ForeignExportCost.a
私は何が欠けているか、間違っていますか?