<div dir="ltr"><div><div>I’m trying to get Swift working with X11, and I keep getting this linker error when I try to compile:<br><br><font face="monospace,monospace">~/dev/cloudgen$ swift build -v<br>/usr/bin/lsb_release -r<br>/home/kelvin/devtools/swift-3.1-dev/usr/bin/swiftc --driver-mode=swift -I /home/kelvin/devtools/swift-3.1-dev/usr/lib/swift/pm -L /home/kelvin/devtools/swift-3.1-dev/usr/lib/swift/pm -lPackageDescription /home/kelvin/dev/cloudgen/Package.swift -fileno 5<br>/home/kelvin/devtools/swift-3.1-dev/usr/bin/swift-build-tool -f /home/kelvin/dev/cloudgen/.build/debug.yaml -v<br>&#39;/home/kelvin/devtools/swift-3.1-dev/usr/bin/swiftc&#39; -Xlinker &#39;-rpath=$ORIGIN&#39; -g -L/home/kelvin/dev/cloudgen/.build/debug -o /home/kelvin/dev/cloudgen/.build/debug/cloudgen &#39;-lX11&#39; -emit-executable /home/kelvin/dev/cloudgen/.build/debug/cloudgen.build/main.swift.o<br>/home/kelvin/dev/cloudgen/Sources/cloudgen/main.swift:22: error: undefined reference to &#39;XOpenDisplay&#39;<br>/home/kelvin/dev/cloudgen/Sources/cloudgen/main.swift:29: error: undefined reference to &#39;XDefaultScreenOfDisplay&#39;<br>/home/kelvin/dev/cloudgen/Sources/cloudgen/main.swift:35: error: undefined reference to &#39;XCreateSimpleWindow&#39;<br>/home/kelvin/dev/cloudgen/Sources/cloudgen/main.swift:38: error: undefined reference to &#39;XSelectInput&#39;<br>/home/kelvin/dev/cloudgen/Sources/cloudgen/main.swift:41: error: undefined reference to &#39;XMapWindow&#39;<br>/home/kelvin/dev/cloudgen/Sources/cloudgen/main.swift:47: error: undefined reference to &#39;XNextEvent&#39;<br>/home/kelvin/dev/cloudgen/Sources/cloudgen/main.swift:52: error: undefined reference to &#39;XFillRectangle&#39;<br>/home/kelvin/dev/cloudgen/Sources/cloudgen/main.swift:53: error: undefined reference to &#39;XDrawString&#39;<br>clang: error: linker command failed with exit code 1 (use -v to see invocation)<br>&lt;unknown&gt;:0: error: link command failed with exit code 1 (use -v to see invocation)<br>&lt;unknown&gt;:0: error: build had 1 command failures<br><span style="font-family:arial,helvetica,sans-serif"><br></span></font></div><font face="monospace,monospace"><span style="font-family:arial,helvetica,sans-serif">Here is the module.modulemap file I am using:</span><br><br>module X11 [system] {<br>  module Xlib {<br>    header &quot;/usr/include/X11/Xlib.h&quot;<br>  }<br>  module X {<br>    header &quot;/usr/include/X11/X.h&quot;<br>  }<br>  link &quot;X11&quot;<br>}<br><br></font></div><font face="monospace,monospace"><font face="arial,helvetica,sans-serif">Why is it always this difficult to get something to show up on a screen in Swift…</font><br></font></div>