title: how to chose between two implementation code in OCaml
body: <p>I have uploaded the very small exemple project on a <a href="https://github.com/Et7f3/question_on_stackoverflow" rel="nofollow noreferrer">github repository</a></p>
  
  <p>I have a school project. The specifications say that we can enable or disable a component.</p>
  
  <p>I came from the c world in which we can compile c to object and chose the object to link. I try this in OCaml.</p>
  
  <p>I have two source file with the same function but their effect is different.
  I have two folders called "on" with implementation and "off" folder with an empty body</p>
  
  <p>For the test, I have a simple a.ml and a.mli file that only print hello world and b.mli b.ml that call the module a. (so I have on/a.ml and off/a.ml)</p>
  
  <p>I compile the on version and the off with this command:</p>
  
  <pre><code>ocamlc -c -I on on/a.mli on/a.ml -o on/a.cmo
  </code></pre>
  
  <p>then I try to link the C-way</p>
  
  <pre><code>ocamlc on/a.cmo  b.ml -o on_b.exe
  </code></pre>
  
  <p>but I get the error</p>
  
  <pre><code>File "b.ml", line 1, characters 9-15:
  Error: Unbound module A
  </code></pre>
  
  <p>I have then read I should specify the folder to search in with -I.</p>
  
  <pre><code>ocamlc -I on -I off on/a.cmo  b.ml -o on_b.exe
  </code></pre>
  
  <p>I was happy because of that work for the on version</p>
  
  <p>but it will not work for the off version</p>
  
  <pre><code>ocamlc -I on -I off off/a.cmo b.ml -o off_b.exe
  </code></pre>
  
  <p>I get the error</p>
  
  <pre><code>Error: Files b.cmo and off/a.cmo
         make inconsistent assumptions over interface A
  </code></pre>
  
  <p>I have inspected with ocamlobjinfo it seems to build B its searches for the first module called A</p>
  
  <p>In this example, I have only A and B but in future, I will build with some version on and some off... but don't do it manually</p>
  
  <p>A solution found but no really efficient is to clean all .cmo and .cmi files ...</p>
  
  <p>thanks for your reading and your time</p>
  
  <p>EDIT:</p>
  
  <p>I have also test with -open but it seems to work only for standards modules.</p>