Saturday, February 14, 2009

Ugh... Annoying X11 Linker Jazz in Cygwin

 Hey guys. I'm wondering if anyone out there can help me with a Linux/Cygwin/X11 problem.

I am trying to use the Graphics library in Ocaml. I am using a Windows machine, so I've got cygwin running (not the Ocaml for Windows thing). When I try to build a new ocaml top-level with the graphics library included, like so:

ocamlmktop -o mytop graphics.cma

I get the following result:

/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: cannot find -lX11
collect2: ld returned 1 exit status
Error while building custom runtime system

I know that X11 works, because I am using xterm and some other applications. I've tried what someone on the internet suggested which is setting the LD library environment variable like so

export LD_LIBRARY_PATH=/usr/X11R6/lib 

But that doesn't help. Other than that, I can't really find any good advice, and I'm kind of a Unix idiot so I don't know what else to try. Anyone have any ideas?


  1. Hey! Nice use of flowcharts. Okay. It seems like that file does not exist on my computer (nor any variants).

    Cygwin has a pretty good package manager, so let me go see what I can find. I report on my status when it changes.

  2. If you ever give up, I can give you an example working project that uses SDL with mlton and runs under windows native (no cygwin or X11), linux, and OS X.

  3. I do feel somewhat guilty for not using SML; I know we have a lot of local experts and Mlton is truly a great compiler, but Ocaml just seems to have better community support, and when you're a non-expert like me, it really helps a lot, e.g., being able to Google for certain syntax that I cannot remember is really helpful.

    Sorry bro. Maybe some day I'll get frustrated and switch back.

  4. Okay, it's true rand. Your advice really helped. I didn't have the actual X11 development package. Which I determined because there was no file like on my computer.

    I went to cygwin, and got the package libx11-devel. After installing that, everything worked fine, including
    ocamlmktop -o mytop graphics.cma

    For people who find this page later on, I will document the solution here: