From: John Whitington <john@coherentgraphics.co.uk>
To: caml-list@yquem.inria.fr
Subject: Compiling with Xcode
Date: Mon, 16 Mar 2009 13:47:59 +0000 [thread overview]
Message-ID: <F58161A2-D684-433F-A145-15D27B2F651C@coherentgraphics.co.uk> (raw)
Hi Folks,
I'm building an Ocaml library with interface to be used from C main
program, as per the instructions in the manual.
Stage 1. Build the mixed C/OCaml library
ocamlc cpdf.mli;
ocamlopt -I . unix.cmxa str.cmxa bigarray.cmxa cgutil.cmxa
camlpdf.cmxa cpdf.ml;
ocamlc cpdflib.mli;
ocamlopt -I . unix.cmxa str.cmxa bigarray.cmxa cgutil.cmxa
camlpdf.cmxa cpdf.cmx cpdflib.ml;
ocamlc cpdflibc.mli;
ocamlopt -I . unix.cmxa str.cmxa bigarray.cmxa cgutil.cmxa
camlpdf.cmxa cpdf.cmx cpdflib.cmx cpdflibc.ml;
ocamlc cpdflibwrapper.c;
ocamlopt -output-obj -o cpdflibc.o unix.cmxa str.cmxa bigarray.cmxa
cgutil.cmxa camlpdf.cmxa cpdf.cmx cpdflib.cmx cpdflibc.cmx;
cp /usr/local/lib/ocaml/libasmrun.a cpdflib.a;
ar r cpdflib.a cpdflibc.o cpdflibwrapper.o
Stage 2. Then compiling and linking the main program:
cc -L'/usr/local/lib/ocaml' -lunix -lbigarray -lstr -lz -o test
cpdflibc-test.c zlibstubs.o cpdflib.a
Which all works fine.
I'm now trying to compile this with XCode - eventually as part of a
Cocoa/Objective C program, but for now, just as a plain C project.
Stage (1) above will still be done outside xcode, just the main
program compilation and link in xcode.
Below is the compilation of a simple Hello World C project in Xcode to
achieve the same aim as stage (2) of the compilation above. It picks
up all the ocaml libraries ok, and cpdflib.a and zlibstubs.o. But it
fails the final link stage.
Can anyone explain the failure or suggest what to try? One of the
extra flags Xcode is adding?
---------------------------------------------------------------------------
Building target “Cversion” of project “Cversion” with configuration
“Debug”
Checking Dependencies
CompileC build/Cversion.build/Debug/Cversion.build/Objects-normal/i386/
main.o /Users/john/Desktop/Cversion/main.c normal i386 c
com.apple.compilers.gcc.4_0
cd /Users/john/Desktop/Cversion
/Developer/usr/bin/gcc-4.0 -x c -arch i386 -fmessage-length=0 -pipe
-std=c99 -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -
Wreturn-type
-Wunused-variable -isysroot /Developer/SDKs/MacOSX10.5.sdk
-mfix-and-continue -mmacosx-version-min=10.5 -gdwarf-2
-iquote /Users/john/Desktop/Cversion/build/Cversion.build/Debug/
Cversion.build/Cversion-generated-files.hmap
-I/Users/john/Desktop/Cversion/build/Cversion.build/Debug/
Cversion.build/Cversion-own-target-headers.hmap
-I/Users/john/Desktop/Cversion/build/Cversion.build/Debug/
Cversion.build/Cversion-all-target-headers.hmap
-iquote /Users/john/Desktop/Cversion/build/Cversion.build/Debug/
Cversion.build/Cversion-project-headers.hmap
-F/Users/john/Desktop/Cversion/build/Debug
-I/Users/john/Desktop/Cversion/build/Debug/include
-I/Developer/SDKs/MacOSX10.5.sdk/usr/local/lib/ocaml
-I/Users/john/svnrepos/trunk
-I/Users/john/Desktop/Cversion/build/Cversion.build/Debug/
Cversion.build/DerivedSources
-c /Users/john/Desktop/Cversion/main.c
-o /Users/john/Desktop/Cversion/build/Cversion.build/Debug/
Cversion.build/Objects-normal/i386/main.o
Ld /Users/john/Desktop/Cversion/build/Debug/Cversion normal i386
cd /Users/john/Desktop/Cversion
setenv MACOSX_DEPLOYMENT_TARGET 10.5
/Developer/usr/bin/gcc-4.0 -arch i386
-isysroot /Developer/SDKs/MacOSX10.5.sdk
-L/Users/john/Desktop/Cversion/build/Debug
-L/Developer/SDKs/MacOSX10.5.sdk/usr/local/lib/ocaml
-L/Users/john/svnrepos/trunk
-L/Users/john/Desktop/Cversion/../../svnrepos/trunk
-F/Users/john/Desktop/Cversion/build/Debug
-filelist /Users/john/Desktop/Cversion/build/Cversion.build/Debug/
Cversion.build/Objects-normal/i386/Cversion.LinkFileList
-mmacosx-version-min=10.5
-L/usr/local/lib/ocaml -lunix -lbigarray -lstr -lz
/Users/john/Desktop/Cversion/../../svnrepos/trunk/cpdflib.a
/Users/john/Desktop/Cversion/../../svnrepos/trunk/zlibstubs.o
-o /Users/john/Desktop/Cversion/build/Debug/Cversion
Undefined symbols:
"_caml_atom_table", referenced from:
_caml_atom_table$non_lazy_ptr in cpdflib.a(alloc.o)
_caml_atom_table$non_lazy_ptr in cpdflib.a(intern.o)
_caml_atom_table$non_lazy_ptr in libunix.a(gethost.o)
_caml_atom_table$non_lazy_ptr in cpdflib.a(array.o)
_caml_atom_table$non_lazy_ptr in libstr.a(strstubs.o)
_caml_atom_table$non_lazy_ptr in cpdflib.a(obj.o)
"_caml_code_area_start", referenced from:
_caml_code_area_start$non_lazy_ptr in cpdflib.a(intern.o)
_caml_code_area_start$non_lazy_ptr in cpdflib.a(extern.o)
_caml_code_area_start$non_lazy_ptr in cpdflib.a(signals_asm.o)
"_caml_code_area_end", referenced from:
_caml_code_area_end$non_lazy_ptr in cpdflib.a(intern.o)
_caml_code_area_end$non_lazy_ptr in cpdflib.a(extern.o)
_caml_code_area_end$non_lazy_ptr in cpdflib.a(signals_asm.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
(The -filelist contains the file main.o)
With Thanks,
--
John Whitington
Coherent Graphics Ltd
http://www.coherentpdf.com/
next reply other threads:[~2009-03-16 13:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-16 13:47 John Whitington [this message]
[not found] ` <4B569876-16E1-4289-9D69-F11FBAFD7A0B@gmail.com>
2009-03-16 13:58 ` [Caml-list] " John Whitington
2009-03-16 18:56 ` Jeffrey Scofield
2009-03-17 3:09 ` [Caml-list] " Jon Harrop
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=F58161A2-D684-433F-A145-15D27B2F651C@coherentgraphics.co.uk \
--to=john@coherentgraphics.co.uk \
--cc=caml-list@yquem.inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).