ClassHandle of Wrapped Monotouch class returns null - objective-c

I am wrapping an Objective-c library in Monotouch. The problem is that, after generating the DLL using btouch, and when I try to use some the classes from the DLL in a sample application, the classHandle of most of the classes return 0x0. I debugged the issue and I discovered that class_ptr, which is used by Messaging class, returns 0x0 as well.
I checked the build output (after building the project in MonoDevelop) and it looks it links my native library but I still get the same error. The build output is included below. The issue is that I have a protocol GDiOSDelegate defined as follows
#protocol GDiOSDelegate
#required
- (void)handleEvent:(GDAppEvent*)anEvent;
#end
This protocol is used by GDiOS class (that I also included) but it also needs to interact with UIApplicationDelegate as HandleEvent method needs to communicate with some objects from UIApplicationDelegate (The equivalent sample code that uses the library, in Objective-C, had a class A : NSObject ).
The way I had it was that in the binding of GDiOSDelegate I set the typeof property to UIApplicationDelegate instead of NSObject
[BaseType(typeof(UIApplicationDelegate))]
So, coming back to the error I was having after I use some methods from the Monotouch binding DLL, it was throwing an exception saying AppDelegate does not implement UIApplicationDelegate.
[Register ("AppDelegate")]
public partial class AppDelegate : GDiOSDelegate
{...}
This happens even if I put UIApplicationDelegate instead of GDiOSDelegate as base class.
The build output:
Building: GDBinding (Debug)
Build started 7/16/2012 9:03:46 AM.
__________________________________________________
Project "/Users/thabetkacem/Projects/GDBinding/GDBinding/GDBinding.csproj" (Build target(s)):
Target CreateGeneratedSourcesDir:
Created directory "obj/Debug/ios/"
Target PrepareForBuild:
Configuration: Debug Platform: AnyCPU
Target CopyFilesMarkedCopyLocal:
Copying file from '/Users/thabetkacem/Desktop/GDExtended/GDBinding.dll' to '/Users/thabetkacem/Projects/GDBinding/GDBinding/bin/Debug/GDBinding.dll'
Target GenerateSatelliteAssemblies:
No input files were specified for target GenerateSatelliteAssemblies, skipping.
Target GenerateBindings:
Tool /Developer/MonoTouch/usr/bin/btouch execution started with arguments: /d:DEBUG GDBinding.cs /s:StructsAndEnums.cs /tmpdir:obj/Debug/ios/ /sourceonly:obj/Debug/ios//sources.list
GDBinding.cs(642,22): warning CS0465: Introducing `Finalize' method can interfere with destructor invocation. Did you intend to declare a destructor?
Target CoreCompile:
Tool /Developer/MonoTouch/usr/bin/smcs execution started with arguments: /noconfig /debug:full /debug+ /optimize- /out:obj/Debug/GDBinding.dll /resource:libGD.a libGD.linkwith.cs Extra.cs AssemblyInfo.cs StructsAndEnums.cs obj/Debug/ios/ObjCRuntime/Messaging.g.cs obj/Debug/ios/GDBinding/GDCReadStream.g.cs obj/Debug/ios/GDBinding/GDCWriteStream.g.cs obj/Debug/ios/GDBinding/GDPersistentStoreCoordinator.g.cs obj/Debug/ios/GDBinding/GDFileSystem.g.cs obj/Debug/ios/GDBinding/GDDirectByteBuffer.g.cs obj/Debug/ios/GDBinding/GDSocketDelegate.g.cs obj/Debug/ios/GDBinding/GDSocket.g.cs obj/Debug/ios/GDBinding/GDHttpRequestDelegate.g.cs obj/Debug/ios/GDBinding/GDHttpRequest.g.cs obj/Debug/ios/GDBinding/NSURLCache.g.cs obj/Debug/ios/GDBinding/GDURLLoadingSystem.g.cs obj/Debug/ios/GDBinding/GDCacheController.g.cs obj/Debug/ios/GDBinding/GDPushConnectionDelegate.g.cs obj/Debug/ios/GDBinding/GDPushConnection.g.cs obj/Debug/ios/GDBinding/GDPushChannelDelegate.g.cs obj/Debug/ios/GDBinding/GDPushChannel.g.cs obj/Debug/ios/GDBinding/GDSecureDocs.g.cs obj/Debug/ios/GDBinding/GDAppEvent.g.cs obj/Debug/ios/GDBinding/GDiOSDelegate.g.cs obj/Debug/ios/GDBinding/GDiOS.g.cs obj/Debug/ios/GDBinding/NSMutableURLRequest.g.cs /target:library /unsafe+ /define:DEBUG /reference:/Developer/MonoTouch/usr/lib/mono/2.1/System.dll /reference:/Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll /reference:../../../Desktop/GDExtended/GDBinding.dll /reference:/Developer/MonoTouch/usr/lib/mono/2.1/System.Core.dll /reference:/Developer/MonoTouch/usr/lib/mono/2.1/mscorlib.dll /warn:4
obj/Debug/ios/GDBinding/GDSocket.g.cs(273,53): warning CS0436: The type `GDBinding.GDSocketDelegate' conflicts with the imported type of same name'. Ignoring the imported type definition
/Users/thabetkacem/Desktop/GDExtended/GDBinding.dll (Location of the symbol related to previous warning)
obj/Debug/ios/GDBinding/GDHttpRequest.g.cs(541,58): warning CS0436: The type `GDBinding.GDHttpRequestDelegate' conflicts with the imported type of same name'. Ignoring the imported type definition
/Users/thabetkacem/Desktop/GDExtended/GDBinding.dll (Location of the symbol related to previous warning)
obj/Debug/ios/GDBinding/GDPushConnection.g.cs(180,61): warning CS0436: The type `GDBinding.GDPushConnectionDelegate' conflicts with the imported type of same name'. Ignoring the imported type definition
/Users/thabetkacem/Desktop/GDExtended/GDBinding.dll (Location of the symbol related to previous warning)
obj/Debug/ios/GDBinding/GDPushChannel.g.cs(175,58): warning CS0436: The type `GDBinding.GDPushChannelDelegate' conflicts with the imported type of same name'. Ignoring the imported type definition
/Users/thabetkacem/Desktop/GDExtended/GDBinding.dll (Location of the symbol related to previous warning)
obj/Debug/ios/GDBinding/GDiOS.g.cs(393,50): warning CS0436: The type `GDBinding.GDiOSDelegate' conflicts with the imported type of same name'. Ignoring the imported type definition
/Users/thabetkacem/Desktop/GDExtended/GDBinding.dll (Location of the symbol related to previous warning)
obj/Debug/ios/ObjCRuntime/Messaging.g.cs(53,134): warning CS0436: The type `GDBinding.GDFileStat' conflicts with the imported type of same name'. Ignoring the imported type definition
/Users/thabetkacem/Desktop/GDExtended/GDBinding.dll (Location of the symbol related to previous warning)
obj/Debug/ios/GDBinding/GDFileSystem.g.cs(159,31): warning CS0436: The type `GDBinding.GDCReadStream' conflicts with the imported type of same name'. Ignoring the imported type definition
/Users/thabetkacem/Desktop/GDExtended/GDBinding.dll (Location of the symbol related to previous warning)
obj/Debug/ios/GDBinding/GDFileSystem.g.cs(181,31): warning CS0436: The type `GDBinding.GDCWriteStream' conflicts with the imported type of same name'. Ignoring the imported type definition
/Users/thabetkacem/Desktop/GDExtended/GDBinding.dll (Location of the symbol related to previous warning)
obj/Debug/ios/GDBinding/GDDirectByteBuffer.g.cs(139,46): warning CS0108: `GDBinding.GDDirectByteBuffer.Init' hides inherited member `MonoTouch.Foundation.NSObject.Init()'. Use the new keyword if hiding was intended
/Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll (Location of the symbol related to previous warning)
obj/Debug/ios/GDBinding/GDSocket.g.cs(177,32): warning CS0436: The type `GDBinding.GDDirectByteBuffer' conflicts with the imported type of same name'. Ignoring the imported type definition
/Users/thabetkacem/Desktop/GDExtended/GDBinding.dll (Location of the symbol related to previous warning)
obj/Debug/ios/GDBinding/GDHttpRequest.g.cs(377,46): warning CS0108: `GDBinding.GDHttpRequest.Init' hides inherited member `MonoTouch.Foundation.NSObject.Init()'. Use the new keyword if hiding was intended
/Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll (Location of the symbol related to previous warning)
obj/Debug/ios/GDBinding/GDHttpRequest.g.cs(449,32): warning CS0436: The type `GDBinding.GDHttpRequest_state_t' conflicts with the imported type of same name'. Ignoring the imported type definition
/Users/thabetkacem/Desktop/GDExtended/GDBinding.dll (Location of the symbol related to previous warning)
obj/Debug/ios/GDBinding/NSURLCache.g.cs(79,57): warning CS0436: The type `GDBinding.NSURLCache' conflicts with the imported type of same name'. Ignoring the imported type definition
/Users/thabetkacem/Desktop/GDExtended/GDBinding.dll (Location of the symbol related to previous warning)
obj/Debug/ios/GDBinding/GDPushConnection.g.cs(84,31): warning CS0436: The type `GDBinding.GDPushConnection' conflicts with the imported type of same name'. Ignoring the imported type definition
/Users/thabetkacem/Desktop/GDExtended/GDBinding.dll (Location of the symbol related to previous warning)
obj/Debug/ios/GDBinding/GDPushChannel.g.cs(148,46): warning CS0108: `GDBinding.GDPushChannel.Init' hides inherited member `MonoTouch.Foundation.NSObject.Init()'. Use the new keyword if hiding was intended
/Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll (Location of the symbol related to previous warning)
obj/Debug/ios/GDBinding/GDSecureDocs.g.cs(101,85): warning CS0436: The type `GDBinding.SendFileSuccessBlock' conflicts with the imported type of same name'. Ignoring the imported type definition
/Users/thabetkacem/Desktop/GDExtended/GDBinding.dll (Location of the symbol related to previous warning)
obj/Debug/ios/GDBinding/GDAppEvent.g.cs(82,32): warning CS0436: The type `GDBinding.GDAppResultCode' conflicts with the imported type of same name'. Ignoring the imported type definition
/Users/thabetkacem/Desktop/GDExtended/GDBinding.dll (Location of the symbol related to previous warning)
obj/Debug/ios/GDBinding/GDAppEvent.g.cs(102,32): warning CS0436: The type `GDBinding.GDAppEventType' conflicts with the imported type of same name'. Ignoring the imported type definition
/Users/thabetkacem/Desktop/GDExtended/GDBinding.dll (Location of the symbol related to previous warning)
obj/Debug/ios/GDBinding/GDiOSDelegate.g.cs(76,51): warning CS0436: The type `GDBinding.GDAppEvent' conflicts with the imported type of same name'. Ignoring the imported type definition
/Users/thabetkacem/Desktop/GDExtended/GDBinding.dll (Location of the symbol related to previous warning)
obj/Debug/ios/GDBinding/GDiOS.g.cs(139,36): warning CS0465: Introducing `Finalize' method can interfere with destructor invocation. Did you intend to declare a destructor?
obj/Debug/ios/GDBinding/GDiOS.g.cs(163,31): warning CS0436: The type `GDBinding.GDiOS' conflicts with the imported type of same name'. Ignoring the imported type definition
/Users/thabetkacem/Desktop/GDExtended/GDBinding.dll (Location of the symbol related to previous warning)
obj/Debug/ios/GDBinding/GDiOS.g.cs(281,94): warning CS0436: The type `GDBinding.GDUIColorTheme' conflicts with the imported type of same name'. Ignoring the imported type definition
/Users/thabetkacem/Desktop/GDExtended/GDBinding.dll (Location of the symbol related to previous warning)
obj/Debug/ios/GDBinding/NSMutableURLRequest.g.cs(83,67): warning CS0436: The type `GDBinding.NSMutableURLRequest' conflicts with the imported type of same name'. Ignoring the imported type definition
/Users/thabetkacem/Desktop/GDExtended/GDBinding.dll (Location of the symbol related to previous warning)
obj/Debug/ios/ObjCRuntime/Messaging.g.cs(44,84): warning CS0436: The type `GDBinding.Messaging' conflicts with the imported type of same name'. Ignoring the imported type definition
/Users/thabetkacem/Desktop/GDExtended/GDBinding.dll (Location of the symbol related to previous warning)
Target DeployOutputFiles:
Copying file from '/Users/thabetkacem/Projects/GDBinding/GDBinding/obj/Debug/GDBinding.dll.mdb' to '/Users/thabetkacem/Projects/GDBinding/GDBinding/bin/Debug/GDBinding.dll.mdb'
Copying file from '/Users/thabetkacem/Projects/GDBinding/GDBinding/obj/Debug/GDBinding.dll' to '/Users/thabetkacem/Projects/GDBinding/GDBinding/bin/Debug/GDBinding.dll'
Done building project "/Users/thabetkacem/Projects/GDBinding/GDBinding/GDBinding.csproj".
Build succeeded.
Warnings:
/Users/thabetkacem/Projects/GDBinding/GDBinding/GDBinding.csproj (Build) -> /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Xamarin.ObjcBinding.CSharp.targets
(GenerateBindings target) ->
GDBinding.cs(642,22): warning CS0465: Introducing `Finalize' method can interfere with destructor invocation. Did you intend to declare a destructor?
/Users/thabetkacem/Projects/GDBinding/GDBinding/GDBinding.csproj (Build) ->
/Library/Frameworks/Mono.framework/Versions/2.10.9/lib/mono/4.0/Microsoft.CSharp.Targets (CoreCompile target) ->
obj/Debug/ios/GDBinding/GDSocket.g.cs(273,53): warning CS0436: The type `GDBinding.GDSocketDelegate' conflicts with the imported type of same name'. Ignoring the imported type definition
obj/Debug/ios/GDBinding/GDHttpRequest.g.cs(541,58): warning CS0436: The type `GDBinding.GDHttpRequestDelegate' conflicts with the imported type of same name'. Ignoring the imported type definition
obj/Debug/ios/GDBinding/GDPushConnection.g.cs(180,61): warning CS0436: The type `GDBinding.GDPushConnectionDelegate' conflicts with the imported type of same name'. Ignoring the imported type definition
obj/Debug/ios/GDBinding/GDPushChannel.g.cs(175,58): warning CS0436: The type `GDBinding.GDPushChannelDelegate' conflicts with the imported type of same name'. Ignoring the imported type definition
obj/Debug/ios/GDBinding/GDiOS.g.cs(393,50): warning CS0436: The type `GDBinding.GDiOSDelegate' conflicts with the imported type of same name'. Ignoring the imported type definition
obj/Debug/ios/ObjCRuntime/Messaging.g.cs(53,134): warning CS0436: The type `GDBinding.GDFileStat' conflicts with the imported type of same name'. Ignoring the imported type definition
obj/Debug/ios/GDBinding/GDFileSystem.g.cs(159,31): warning CS0436: The type `GDBinding.GDCReadStream' conflicts with the imported type of same name'. Ignoring the imported type definition
obj/Debug/ios/GDBinding/GDFileSystem.g.cs(181,31): warning CS0436: The type `GDBinding.GDCWriteStream' conflicts with the imported type of same name'. Ignoring the imported type definition
obj/Debug/ios/GDBinding/GDDirectByteBuffer.g.cs(139,46): warning CS0108: `GDBinding.GDDirectByteBuffer.Init' hides inherited member `MonoTouch.Foundation.NSObject.Init()'. Use the new keyword if hiding was intended
obj/Debug/ios/GDBinding/GDSocket.g.cs(177,32): warning CS0436: The type `GDBinding.GDDirectByteBuffer' conflicts with the imported type of same name'. Ignoring the imported type definition
obj/Debug/ios/GDBinding/GDHttpRequest.g.cs(377,46): warning CS0108: `GDBinding.GDHttpRequest.Init' hides inherited member `MonoTouch.Foundation.NSObject.Init()'. Use the new keyword if hiding was intended
obj/Debug/ios/GDBinding/GDHttpRequest.g.cs(449,32): warning CS0436: The type `GDBinding.GDHttpRequest_state_t' conflicts with the imported type of same name'. Ignoring the imported type definition
obj/Debug/ios/GDBinding/NSURLCache.g.cs(79,57): warning CS0436: The type `GDBinding.NSURLCache' conflicts with the imported type of same name'. Ignoring the imported type definition
obj/Debug/ios/GDBinding/GDPushConnection.g.cs(84,31): warning CS0436: The type `GDBinding.GDPushConnection' conflicts with the imported type of same name'. Ignoring the imported type definition
obj/Debug/ios/GDBinding/GDPushChannel.g.cs(148,46): warning CS0108: `GDBinding.GDPushChannel.Init' hides inherited member `MonoTouch.Foundation.NSObject.Init()'. Use the new keyword if hiding was intended
obj/Debug/ios/GDBinding/GDSecureDocs.g.cs(101,85): warning CS0436: The type `GDBinding.SendFileSuccessBlock' conflicts with the imported type of same name'. Ignoring the imported type definition
obj/Debug/ios/GDBinding/GDAppEvent.g.cs(82,32): warning CS0436: The type `GDBinding.GDAppResultCode' conflicts with the imported type of same name'. Ignoring the imported type definition
obj/Debug/ios/GDBinding/GDAppEvent.g.cs(102,32): warning CS0436: The type `GDBinding.GDAppEventType' conflicts with the imported type of same name'. Ignoring the imported type definition
obj/Debug/ios/GDBinding/GDiOSDelegate.g.cs(76,51): warning CS0436: The type `GDBinding.GDAppEvent' conflicts with the imported type of same name'. Ignoring the imported type definition
obj/Debug/ios/GDBinding/GDiOS.g.cs(139,36): warning CS0465: Introducing `Finalize' method can interfere with destructor invocation. Did you intend to declare a destructor?
obj/Debug/ios/GDBinding/GDiOS.g.cs(163,31): warning CS0436: The type `GDBinding.GDiOS' conflicts with the imported type of same name'. Ignoring the imported type definition
obj/Debug/ios/GDBinding/GDiOS.g.cs(281,94): warning CS0436: The type `GDBinding.GDUIColorTheme' conflicts with the imported type of same name'. Ignoring the imported type definition
obj/Debug/ios/GDBinding/NSMutableURLRequest.g.cs(83,67): warning CS0436: The type `GDBinding.NSMutableURLRequest' conflicts with the imported type of same name'. Ignoring the imported type definition
obj/Debug/ios/ObjCRuntime/Messaging.g.cs(44,84): warning CS0436: The type `GDBinding.Messaging' conflicts with the imported type of same name'. Ignoring the imported type definition
25 Warning(s)
0 Error(s)
Time Elapsed 00:00:05.0845450
---------------------- Done ----------------------
Build: 0 errors, 25 warnings
Any help would be greatly appreciated.

This can occur if you do not link, manually or (better) with [LinkWith] attribute, the native library (that you binded) with your application.
In such case the selectors message won't reach the native code and will return null (which will show handles (instance or class) to be 0x0.
To confirm this look at your Build Output (inside MonoDevelop) and see if your libX.a is being linked to your application.
Also try this on the simulator (i386) and devices (armv6 and/or armv7) since it's possible that your native library architecture is not available (in your .a).

Related

What is the list of valid #SuppressWarnings warning names in Gosu?

What is the list of valid #SuppressWarnings warning names in Gosu?
The bit that comes in between the ("") in #SuppressWarnings("").
There is already an SO answer for Java but I'm interested in suppressing the warning that my variable type can be inferred (passing an inferred block variable as a function parameter does not compile so I'm using an explicitly typed variable).
Java answer: What is the list of valid #SuppressWarnings warning names in Java?

What library in OpenDDS contains "OpenDDS::DCPS::operator<<"?

I'm having an issue linking my shared library against an OpenDDS (v3.9) static library because I am unable to find where this method signature is located.
Here's the error.
[exec] libs/mylib/ABTypeSupportImpl.cpp:74: error: undefined reference to 'OpenDDS::DCPS::operator<<(OpenDDS::DCPS::Serializer&, short)'
[exec] collect2: error: ld returned 1 exit status
[exec] make: *** [/tmp/mybuild/lib_ab/obj/local/armeabi-v7a/lib_ab.so] Error 1
ABTypeSupportImpl.cpp is auto generated from compiling the IDL. More of the same errors follow. Because of the namespace (OpenDDS::DCPS), I would think this would be found within the library libOpenDDS_Dcps.a, but using nm on this lib and then grep'ing for "operator" or "<<", produces no results. Could it be that name mangling is a bit stranger for overloaded operators? I ran this on every library file within $DDS_ROOT/lib, but found nothing.
And if I recompile the IDL and remove member fields of structs with datatypes such as short or long, then there are no errors and everything links fine.
Anyone know what library this method signature might be located?
These operators are declared in 'dds/DCPS/Serializer.h' but implemented inline in Serializer.inl. Probably you compile OpenDDS with inlining enabled (its default) but when you compile your application you compile with inlining disabled.

OCaml module types and separate compilation

I am reading through OCaml lead designer's 1994 paper on modules, types, and separate compilation. (kindly pointed to me by Norman Ramsey in another question ). I understand that the paper discusses the origins of OCaml's present module type / signature system. It it, the author proposes opaque interpretation of type declarations in signatures (to allow separate compilation) together with manifest type declarations (for expressiveness). Attempting to put together some examples of my own to demonstrate the kind of problems the OCaml module signature notation is trying to tackle I wrote the following code in two files:
In file ordering.ml (or .mli — I've tried both) (file A):
module type ORDERING = sig
type t
val isLess : t -> t -> bool
end
and in file useOrdering.ml (file B):
open Ordering
module StringOrdering : ORDERING
let main () =
Printf.printf "%b" StringOrdering.isLess "a" "b"
main ()
The idea being to expect the compiler to complain (when compiling the second file) that not enough type information is available on module StringOrdering to typecheck the StringOrdering.isLess application (and thus motivate the need for the with type syntax).
However, although file A compiles as expected, file B causes the 3.11.2 ocamlc to complain for a syntax error. I understood that signatures were meant to allow someone to write code based on the module signature, without access to the implementation (the module structure).
I confess that I am not sure about the syntax: module A : B which I encountered in this rather old paper on separate compilation but it makes me wonder whether such or similar syntax exists (without involving functors) to allow someone to write code based only on the module type, with the actual module structure provided at linking time, similar to how one can use *.h and *.c files in C/C++. Without such an ability it would seem to be that module types / signatures are basically for sealing / hiding the internals of modules or more explicit type checking / annotations but not for separate / independent compilation.
Actually, looking at the OCaml manual section on modules and separate compilation it seems that my analogy with C compilation units is broken because the OCaml manual defines the OCaml compilation unit to be the A.ml and A.mli duo, whereas in C/C++ the .h files are pasted to the compilation unit of any importing .c file.
The right way to do such a thing is to do the following:
In ordering.mli write:
(* This define the signature *)
module type ORDERING = sig
type t
val isLess : t -> t -> bool
end
(* This define a module having ORDERING as signature *)
module StringOrdering : ORDERING
Compile the file: ocamlc -c ordering.mli
In another file, refer to the compiled signature:
open Ordering
let main () =
Printf.printf "%b" (StringOrdering.isLess "a" "b")
let () = main ()
When you compile the file, you get the expected type error (ie. string is not compatible with Ordering.StringOrdering.t). If you want to remove the type error, you should add the with type t = string constraint to the definition of StringOrdering in ordering.mli.
So answer to you second question: yes, in bytecode mode the compiler just needs to know about the interfaces your are depending on, and you can choose which implementation to use at link time. By default, that's not true for native code compilation (because of inter-module optimizations) but you can disable it.
You are probably just confused by the relation between explicit module and signature definitions, and the implicit definition of modules through .ml/.mli files.
Basically, if you have a file a.ml and use it inside some other file, then it is as if you had written
module A =
struct
(* content of file a.ml *)
end
If you also have a.mli, then it is as if you had written
module A :
sig
(* content of file a.mli *)
end =
struct
(* content of file a.ml *)
end
Note that this only defines a module named A, not a module type. A's signature cannot be given a name through this mechanism.
Another file using A can be compiled against a.mli alone, without providing a.ml at all. However, you want to make sure that all type information is made transparent where needed. For example, suppose you are to define a map over integers:
(* intMap.mli *)
type key = int
type 'a map
val empty : 'a map
val add : key -> 'a -> 'a map -> 'a map
val lookup : key -> 'a map -> 'a option
...
Here, key is made transparent, because any client code (of the module IntMap that this signature describes) needs to know what it is to be able to add something to the map. The map type itself, however, can (and should) be kept abstract, because a client shouldn't mess with its implementation details.
The relation to C header files is that those basically only allow transparent types. In Ocaml, you have the choice.
module StringOrdering : ORDERING is a module declaration. You can use this in a signature, to say that the signature contains a module field called StringOrdering and having the signature ORDERING. It doesn't make sense in a module.
You need to define a module somewhere that implements the operations you need. The module definition can be something like
module StringOrderingImplementation = struct
type t = string
let isLess x y = x <= y
end
If you want to hide the definition of the type t, you need to make a different module where the definition is abstract. The operation to make a new module out of an old one is called sealing, and is expressed through the : operator.
module StringOrderingAbstract = (StringOrdering : ORDERING)
Then StringOrderingImplementation.isLess "a" "b" is well-typed, whereas StringOrderingAbstract.isLess "a" "b" cannot be typed since StringOrderingAbstract.t is an abstract type, which is not compatible with string or any other preexisting type. In fact, it's impossible to build a value of type StringOrderingAbstract.t, since the module does not include any constructor.
When you have a compilation unit foo.ml, it is a module Foo, and the signature of this module is given by the interface file foo.mli. That is, the files foo.ml and foo.mli are equivalent to the module definition
module Foo = (struct (*…contents of foo.ml…*) end :
sig (*…contents of foo.mli…*) end)
When compiling a module that uses Foo, the compiler only looks at foo.mli (or rather the result of its compilation: foo.cmi), not at foo.ml¹. This is how interfaces and separate compilation fit together. C needs #include <foo.h> because it lacks any form of namespace; in OCaml, Foo.bar automatically refers to a bar defined in the compilation unit foo if there is no other module called Foo in scope.
¹ Actually, the native code compiler looks at the implementation of Foo to perform optimizations (inlining). The type checker never looks at anything but what is in the interface.

Bootstrapping mono on an OCTEON (mips64) gives a working runtime, but gmcs doesn't work

I'm trying to compile mono (from git) for a Cavium OCTEON (mips64) running Debian Sid.
If I try to compile entirely on the OCTEON, (without any kind of existing mono install), it gets as far as the mcs directory and then hits trouble. The problems relate to not having a functional gmcs. The suggested path of make get-monolite-latest doesn't work (wrong core versions, still no gmcs, etc).
To combat this, I tried the processes for cross-compiling mono for ARM. Of course, I have fast MIPs hardware to hand, so I don't use scratchbox.
The split build process gives no errors. Once installed on the OCTEON, I can run C# programs that have already been compiled (via gmcs on the x86_64 system). However, I cannot compile from source on the OCTEON. So, the IL runtime seems to work, but the compiler doesn't.
For example, compiling the simple hello world from http://www.mono-project.com/Mono_Basics gives the following:
root#OCTEON:~# gmcs helloWorld.cs
error CS0518: The predefined type `System.Object' is not defined or imported
error CS0518: The predefined type `System.ValueType' is not defined or imported
error CS0518: The predefined type `System.Attribute' is not defined or imported
error CS0518: The predefined type `System.Int32' is not defined or imported
error CS0518: The predefined type `System.UInt32' is not defined or imported
error CS0518: The predefined type `System.Int64' is not defined or imported
error CS0518: The predefined type `System.UInt64' is not defined or imported
error CS0518: The predefined type `System.Single' is not defined or imported
error CS0518: The predefined type `System.Double' is not defined or imported
error CS0518: The predefined type `System.Char' is not defined or imported
error CS0518: The predefined type `System.Int16' is not defined or imported
error CS0518: The predefined type `System.Decimal' is not defined or imported
error CS0518: The predefined type `System.Boolean' is not defined or imported
error CS0518: The predefined type `System.SByte' is not defined or imported
error CS0518: The predefined type `System.Byte' is not defined or imported
error CS0518: The predefined type `System.UInt16' is not defined or imported
error CS0518: The predefined type `System.String' is not defined or imported
error CS0518: The predefined type `System.Enum' is not defined or imported
error CS0518: The predefined type `System.Delegate' is not defined or imported
error CS0518: The predefined type `System.MulticastDelegate' is not defined or imported
error CS0518: The predefined type `System.Void' is not defined or imported
error CS0518: The predefined type `System.Array' is not defined or imported
error CS0518: The predefined type `System.Type' is not defined or imported
error CS0518: The predefined type `System.Collections.IEnumerator' is not defined or imported
error CS0518: The predefined type `System.Collections.IEnumerable' is not defined or imported
error CS0518: The predefined type `System.IDisposable' is not defined or imported
error CS0518: The predefined type `System.IntPtr' is not defined or imported
error CS0518: The predefined type `System.UIntPtr' is not defined or imported
error CS0518: The predefined type `System.RuntimeFieldHandle' is not defined or imported
error CS0518: The predefined type `System.RuntimeTypeHandle' is not defined or imported
error CS0518: The predefined type `System.Exception' is not defined or imported
Compilation failed: 31 error(s), 0 warnings
I feel like I'm close, but missing a step. It's as if it's not finding mscorelib.dll. Yet, that file does seem to be present under the prefix path:
root#OCTEON# find . | grep -i mscor
./2.0/mscorlib.dll
./2.0/mscorlib.dll.mdb
./2.0/mscorlib.dll.so
./4.5/mscorlib.dll
./4.5/mscorlib.dll.mdb
./4.5/mscorlib.dll.so
./4.0/mscorlib.dll
./4.0/mscorlib.dll.mdb
Before I start delving into the mcs code to understand its flow and what's going wrong, I was hoping that someone on here might be able to shed some light on the problem and point me in the right direction. Have I missed something? Is there some obvious fix?

Migrating Gecko 1.9 to 2.0 - Lot of errors

OK, after migrated to Gecko 2.0 for my XPCOM Component,
I fixed a couple of thg like below:
1. Replacing #include "nsIGenericFactory.h" to #include "mozilla/ModuleUtils.h"
2. Replacing xpcomglue_s.lib to xpcomglue_s_nomozalloc.lib
3. Adding #include "mozilla-config.h" to xpcom-config.h header file
4. And as well as remove a couple of unused header file eg: nsReadableUtils.h, nsEventQueueUtils.h, nsIExtensionManager.h
5. Replacing NS_DEFINE_STATIC_IID_ACCESSOR(IMYPROGRAM_IID) to NS_DEFINE_STATIC_IID_ACCESSOR(IMyProgram, IMYPROGRAM_IID)
Reduced from 200+ errors to 20+ now, below are a few more errors which i have no idea what is that, any expert here encounter problem like below?
error C3254: 'IMyProgram' : class contains explicit override 'kIID' but does not derive from an interface that contains the function declaration
error C2838: 'kIID' : illegal qualified name in member declaration
error C3857: 'IMyProgram::kIID': multiple template parameter lists are not allowed
error C2084: function 'void nsTraceRefcnt::LogAddRef(void *,nsrefcnt,const char *,PRUint32)' already has a body
error C2084: function 'void nsTraceRefcnt::LogRelease(void *,nsrefcnt,const char *)' already has a body
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2143: syntax error : missing ',' before '*'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2143: syntax error : missing ',' before '*'
error C2146: syntax error : missing ';' before identifier 'components'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2440: 'initializing' : cannot convert from 'const char [13]' to 'int'
error C2078: too many initializers
error C2448: 'NS_IMPL_NSGETMODULE' : function-style initializer appears to be a function definition
error C2143: syntax error : missing ';' before '__stdcall'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2143: syntax error : missing ',' before '*'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2556: 'int MyProgramRegistration(nsIComponentManager *,nsIFile *,const char *,const char *,const int)' : overloaded function differs only by return type from 'nsresult MyProgramRegistration(nsIComponentManager *,nsIFile *,const char *,const char *,const int)'
error C2371: 'MyProgramRegistration' : redefinition; different basic types
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2143: syntax error : missing ',' before '*'
error C3254: 'IMyProgram' : class contains explicit override 'kIID' but does not derive from an interface that contains the function declaration
error C2838: 'kIID' : illegal qualified name in member declaration
error C3857: 'IMyProgram::kIID': multiple template parameter lists are not allowed
At the very least it looks as if you are missing an NS_DECLARE_STATIC_IID_ACCESSOR(IMYPROGRAM_IID) in your interface (xpidl would have generated that for you automatically.) Some of the other errors are a bit harder to figure out without source code, but the chances are that you haven't quite managed to update your module registration code correctly.