<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div>see idk how to include the libraries and still make them Importable. And dumping the library sources into the project dir would kind of hamper source distribution…</div><div><br>On Mar 28, 2017, at 7:36 PM, Michael Ilseman &lt;<a href="mailto:milseman@apple.com">milseman@apple.com</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html charset=utf-8">This is into uncharted territory for me, but it seems you’re building with SwiftPM. You’ll probably want to configure extra compiler flags if that’s possible. You could also bite the bullet and build your C libraries with SwiftPM as well. Hopefully someone on swift-build-dev can help you out.<div class=""><br class=""></div><div class="">CC-ing Ankit<div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Mar 28, 2017, at 5:09 PM, Kelvin Ma &lt;<a href="mailto:kelvinsthirteen@gmail.com" class="">kelvinsthirteen@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">How do I compile a project with many modules? My tree looks like this:<br class=""><br class=""><span id="cid:ii_j0u7s58g0_15b1765689e74dba">&lt;Selection_001.png&gt;</span><br class="">​<br class=""></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Mar 28, 2017 at 12:47 PM, Michael Ilseman <span dir="ltr" class="">&lt;<a href="mailto:milseman@apple.com" target="_blank" class="">milseman@apple.com</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class="">Sure! In this example, I have built libgit2. I have a directory called Git, and inside that I have the following module map:</div><div class=""><br class=""></div><div class="">module Git [system] {<br class="">&nbsp; &nbsp; &nbsp; &nbsp;header "&lt;my path&gt;/libgit2/include/git2.h"<br class="">&nbsp; &nbsp; &nbsp; &nbsp;export *<br class="">}<br class=""><br class=""></div><div class="">When I run, I use:</div><div class=""><br class=""></div><div class="">swift -I &lt;path-to-“Git”-directory&gt; -L &lt;path-to-built-libgit2&gt; -lgit2 foo.swift</div><div class=""><br class=""></div><div class="">inside foo.swift I can:</div><div class=""><br class=""></div><div class="">import Git</div><div class="">// … use libGit2</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Read more about how to write a more appropriate module.map file for your purposes at&nbsp;<a href="https://clang.llvm.org/docs/Modules.html" target="_blank" class="">https://clang.llvm.org/<wbr class="">docs/Modules.html</a>. For example, you might be able to define link flags inside the module.map, use umbrella directories, submodules, etc.</div><div class=""><div class="h5"><div class=""><br class=""></div><div class=""><br class=""></div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Mar 28, 2017, at 6:27 AM, Kelvin Ma &lt;<a href="mailto:kelvinsthirteen@gmail.com" target="_blank" class="">kelvinsthirteen@gmail.com</a>&gt; wrote:</div><br class="m_8432716316639870101Apple-interchange-newline"><div class=""><div dir="ltr" class="">Can you give an example?<br class=""></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Mon, Mar 27, 2017 at 3:59 PM, Michael Ilseman <span dir="ltr" class="">&lt;<a href="mailto:milseman@apple.com" target="_blank" class="">milseman@apple.com</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Sure. At a low level, you can create a module.map file and use -L/-l flags in your invocation of Swift. If you want to do so at a higher level, then perhaps SwiftPM can. CCing swift-build-dev for the SwiftPM part.<br class="">
<span class="m_8432716316639870101im m_8432716316639870101HOEnZb"><br class="">
<br class="">
&gt; On Mar 26, 2017, at 3:20 PM, Kelvin Ma via swift-users &lt;<a href="mailto:swift-users@swift.org" target="_blank" class="">swift-users@swift.org</a>&gt; wrote:<br class="">
&gt;<br class="">
&gt; Idk if this has been asked before, but is there a way to import C libraries into a Swift project without creating a local git repo? Preferably something similar to C where you can just `#include` headers and then specify the link flags (in Package.swift?)<br class="">
&gt;<br class="">
&gt; It’s getting very cumbersome to make a bunch of empty git repos just to use libglfw or libcairo.<br class="">
</span><div class="m_8432716316639870101HOEnZb"><div class="m_8432716316639870101h5">&gt; ______________________________<wbr class="">_________________<br class="">
&gt; swift-users mailing list<br class="">
&gt; <a href="mailto:swift-users@swift.org" target="_blank" class="">swift-users@swift.org</a><br class="">
&gt; <a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailma<wbr class="">n/listinfo/swift-users</a><br class="">
<br class="">
</div></div></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></div></div></blockquote></body></html>