Tcpip and caml_startup linker errors

I got the following error today when trying to build a project (Frenetic) that uses the tcpip library. I’m getting different errors on OS X Yosemite and Arch Linux, but I think they have the same root cause.

On Arch Linux, the error is:

/home/basus/src/frenetic/_build/lib/Frenetic_Packet.ml:931: undefined reference to `caml_tcpip_ones_complement_checksum'
/home/basus/.opam/4.04.1/lib/tcpip/tcpip.a(tcpip_checksum.o): In function `camlTcpip_checksum__fun_1272':
:(.text+0xa): undefined reference to `caml_tcpip_ones_complement_checksum_list'
/home/basus/.opam/4.04.1/lib/tcpip/tcpip.a(tcpip_checksum.o): In function `camlTcpip_checksum__fun_1274':
:(.text+0x3a): undefined reference to `caml_tcpip_ones_complement_checksum'
/home/basus/.opam/4.04.1/lib/tcpip/tcpip.a(tcpip_checksum.o): In function `camlTcpip_checksum__2':
:(.data+0x58): undefined reference to `caml_tcpip_ones_complement_checksum_list'
:(.data+0x60): undefined reference to `caml_tcpip_ones_complement_checksum'
collect2: error: ld returned 1 exit status
File "caml_startup", line 1:
Error: Error during linking

On OS X Yosemite the error is:

Undefined symbols for architecture x86_64:
  "_caml_tcpip_ones_complement_checksum", referenced from:
      _camlFrenetic_Packet__marshal_12451 in frenetic.a(Frenetic_Packet.o)
      _camlFrenetic_Packet__marshal_12625 in frenetic.a(Frenetic_Packet.o)
      _camlFrenetic_Packet__marshal_13073 in frenetic.a(Frenetic_Packet.o)
      _camlTcpip_checksum__fun_1274 in tcpip.a(tcpip_checksum.o)
      _camlTcpip_checksum__2 in tcpip.a(tcpip_checksum.o)
  "_caml_tcpip_ones_complement_checksum_list", referenced from:
      _camlFrenetic_Packet__checksum_11645 in frenetic.a(Frenetic_Packet.o)
      _camlTcpip_checksum__fun_1272 in tcpip.a(tcpip_checksum.o)
      _camlTcpip_checksum__2 in tcpip.a(tcpip_checksum.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
File "caml_startup", line 1:
Error: Error during linking
make: *** [build] Error 1

I did opam reinstall tcpip but the get the same error. This happens on both Arch Linux and OS X Yosemite.

This is likely because of the port to jbuilder rearranging the ocamlfind libraries slightly. If you add in an ocamlfind dependency for tcpip.unix is the build fixed? In the meanwhile, a constraint of tcpip {<"3.2.0"} will also unblock the build by using the older version.

Adding the tcpip.unix dependency seems to have fixed things. Thanks!