Version française
Home     About     Download     Resources     Contact us    
Browse thread
Compiling with Xcode
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: John Whitington <john@c...>
Subject: Compiling with Xcode
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/