caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Compiling with Xcode
@ 2009-03-16 13:47 John Whitington
       [not found] ` <4B569876-16E1-4289-9D69-F11FBAFD7A0B@gmail.com>
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: John Whitington @ 2009-03-16 13:47 UTC (permalink / raw)
  To: caml-list

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/




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] Compiling with Xcode
       [not found] ` <4B569876-16E1-4289-9D69-F11FBAFD7A0B@gmail.com>
@ 2009-03-16 13:58   ` John Whitington
  0 siblings, 0 replies; 4+ messages in thread
From: John Whitington @ 2009-03-16 13:58 UTC (permalink / raw)
  To: Joel Reymont; +Cc: caml-list

Hi,

On 16 Mar 2009, at 13:52, Joel Reymont wrote:
> I don't think you are linking against the OCaml runtime.

That happens here, though, in the production of cpdflib.a...

>> cp /usr/local/lib/ocaml/libasmrun.a cpdflib.a;
>> ar r cpdflib.a cpdflibc.o cpdflibwrapper.o


Certainly there's no second linking with the ocaml runtime in the  
original main program compile-and-link, which works fine:

> cc -L'/usr/local/lib/ocaml' -lunix -lbigarray -lstr -lz -o test  
> cpdflibc-test.c zlibstubs.o cpdflib.a

With Thanks,

-- 
John Whitington
Coherent Graphics Ltd
http://www.coherentpdf.com/




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Compiling with Xcode
  2009-03-16 13:47 Compiling with Xcode John Whitington
       [not found] ` <4B569876-16E1-4289-9D69-F11FBAFD7A0B@gmail.com>
@ 2009-03-16 18:56 ` Jeffrey Scofield
  2009-03-17  3:09 ` [Caml-list] " Jon Harrop
  2 siblings, 0 replies; 4+ messages in thread
From: Jeffrey Scofield @ 2009-03-16 18:56 UTC (permalink / raw)
  To: caml-list

John Whitington <john@coherentgraphics.co.uk> writes:

>     /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: ...

Well, caml_atom_table is defined in libasmrun.a, which you have
copied and augmented with your own object files.

A lot of the unsatisfied references are from cpdflib.a itself.  The
normal ways to handle this problem are to tsort the .o files in the
archive (old fashioned way) or to add a symbol table to the archive
with ranlib. Perhaps you need to run ranlib on it after adding your .o
files?

Regards,

Jeff Scofield
Seattle


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] Compiling with Xcode
  2009-03-16 13:47 Compiling with Xcode John Whitington
       [not found] ` <4B569876-16E1-4289-9D69-F11FBAFD7A0B@gmail.com>
  2009-03-16 18:56 ` Jeffrey Scofield
@ 2009-03-17  3:09 ` Jon Harrop
  2 siblings, 0 replies; 4+ messages in thread
From: Jon Harrop @ 2009-03-17  3:09 UTC (permalink / raw)
  To: caml-list

On Monday 16 March 2009 13:47:59 John Whitington wrote:
> 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.

Can we expect CamlPDF for Mac OS X next? :-)

-- 
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?e


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-03-17  3:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-16 13:47 Compiling with Xcode John Whitington
     [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

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).