<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 21 May 2017, at 20:48, Kelvin Ma via swift-users <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class=""><div class="">I’m trying to get Swift working with X11, and I keep getting this linker error when I try to compile:<br class=""><br class=""><font face="monospace,monospace" class="">~/dev/cloudgen$ swift build -v<br class="">/usr/bin/lsb_release -r<br class="">/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 class="">/home/kelvin/devtools/swift-3.1-dev/usr/bin/swift-build-tool -f /home/kelvin/dev/cloudgen/.build/debug.yaml -v<br class="">'/home/kelvin/devtools/swift-3.1-dev/usr/bin/swiftc' -Xlinker '-rpath=$ORIGIN' -g -L/home/kelvin/dev/cloudgen/.build/debug -o /home/kelvin/dev/cloudgen/.build/debug/cloudgen '-lX11' -emit-executable /home/kelvin/dev/cloudgen/.build/debug/cloudgen.build/main.swift.o<br class="">/home/kelvin/dev/cloudgen/Sources/cloudgen/main.swift:22: error: undefined reference to 'XOpenDisplay'<br class="">/home/kelvin/dev/cloudgen/Sources/cloudgen/main.swift:29: error: undefined reference to 'XDefaultScreenOfDisplay'<br class="">/home/kelvin/dev/cloudgen/Sources/cloudgen/main.swift:35: error: undefined reference to 'XCreateSimpleWindow'<br class="">/home/kelvin/dev/cloudgen/Sources/cloudgen/main.swift:38: error: undefined reference to 'XSelectInput'<br class="">/home/kelvin/dev/cloudgen/Sources/cloudgen/main.swift:41: error: undefined reference to 'XMapWindow'<br class="">/home/kelvin/dev/cloudgen/Sources/cloudgen/main.swift:47: error: undefined reference to 'XNextEvent'<br class="">/home/kelvin/dev/cloudgen/Sources/cloudgen/main.swift:52: error: undefined reference to 'XFillRectangle'<br class="">/home/kelvin/dev/cloudgen/Sources/cloudgen/main.swift:53: error: undefined reference to 'XDrawString'<br class="">clang: error: linker command failed with exit code 1 (use -v to see invocation)<br class=""><unknown>:0: error: link command failed with exit code 1 (use -v to see invocation)<br class=""><unknown>:0: error: build had 1 command failures<br class=""><span style="font-family:arial,helvetica,sans-serif" class=""><br class=""></span></font></div><font face="monospace,monospace" class=""><span style="font-family:arial,helvetica,sans-serif" class="">Here is the module.modulemap file I am using:</span><br class=""><br class="">module X11 [system] {<br class=""> module Xlib {<br class=""> header "/usr/include/X11/Xlib.h"<br class=""> }<br class=""> module X {<br class=""> header "/usr/include/X11/X.h"<br class=""> }<br class=""> link "X11"<br class="">}<br class=""></font></div></div></div></blockquote><br class=""></div><div>If they are umbrella headers that include other header file dependencies, you may need an 'export *' in order to make them visible -- otherwise you only get the contents of that header file.</div><div><br class=""></div><div><a href="http://clang.llvm.org/docs/Modules.html#export-declaration" class="">http://clang.llvm.org/docs/Modules.html#export-declaration</a></div><div><br class=""></div><div>Alex</div><br class=""></body></html>