<font size="2"><span style="background-color:rgba(255,255,255,0)">You'll need to create a module map to import C modules. In practise it'll be easier to use swiftpm for such things. I had written a tutorial for this :</span></font><div><font size="2"><span style="background-color:rgba(255,255,255,0)"><br></span></font></div><div><a href="http://ankit.im/swift/2015/12/27/ship-c-code-with-swift-packages-using-swift-package-manager/" target="_blank" style="background-color:rgba(255,255,255,0)"><font color="#000000" size="2">http://ankit.im/swift/2015/12/27/ship-c-code-with-swift-packages-using-swift-package-manager/</font></a></div><br>On Friday 29 January 2016, Suipengfei via swift-users <<a href="mailto:swift-users@swift.org">swift-users@swift.org</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="ZH-CN" link="blue" vlink="purple">
<div>
<p><span lang="EN-US">Hi all, I want to make a simple emample to show swift can call c library.
<u></u><u></u></span></p>
<p><span lang="EN-US"><u></u> <u></u></span></p>
<p><span lang="EN-US">So ,I make a simple example,like this:<u></u><u></u></span></p>
<p><span lang="EN-US"><u></u> <u></u></span></p>
<p><span lang="EN-US">$ cat a.c<u></u><u></u></span></p>
<p><span lang="EN-US">int add(int a,int b){<u></u><u></u></span></p>
<p><span lang="EN-US"> return a + b;<u></u><u></u></span></p>
<p><span lang="EN-US">}<u></u><u></u></span></p>
<p><span lang="EN-US"><u></u> <u></u></span></p>
<p><span lang="EN-US">And I make a lib,<u></u><u></u></span></p>
<p><span lang="EN-US">$ gcc -o a.o -c a.c<u></u><u></u></span></p>
<p><span lang="EN-US">$ ar rcs libmylib.a a.o<u></u><u></u></span></p>
<p><span lang="EN-US"><u></u> <u></u></span></p>
<p><span lang="EN-US">And I put libmylib.a in the same director with the main.swift
<u></u><u></u></span></p>
<p><span lang="EN-US"><u></u> <u></u></span></p>
<p><span lang="EN-US">$ cat main.swift<u></u><u></u></span></p>
<p><span lang="EN-US">import mylib<u></u><u></u></span></p>
<p><span lang="EN-US">var b = add(10,20)<u></u><u></u></span></p>
<p><span lang="EN-US">print(b)<u></u><u></u></span></p>
<p><span lang="EN-US"><u></u> <u></u></span></p>
<p><span lang="EN-US">when I compile : <u></u><u></u></span></p>
<p><span lang="EN-US">$ swiftc main.swift<u></u><u></u></span></p>
<p><span lang="EN-US">main.swift:1:8: error: no such module 'mylib'<u></u><u></u></span></p>
<p><span lang="EN-US">import mylib<u></u><u></u></span></p>
<p><span lang="EN-US"> ^<u></u><u></u></span></p>
<p><span lang="EN-US"><u></u> <u></u></span></p>
<p><span lang="EN-US"><u></u> <u></u></span></p>
<p><span lang="EN-US">I am just confused with this. Can you explain that with you pressure time. And what should I do? Thank you a lot ~<u></u><u></u></span></p>
<p><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
</div>
</div>
</blockquote><br><br>-- <br>Ankit<br><br><br>