<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 12 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:宋体;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"\@宋体";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:宋体;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:宋体;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="ZH-CN" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D">Hi ankit,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D">Really thank you very very much. I can’t solve these problem for a lot of time.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D">You document is very clear and easy to understand.
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D">Thank you again~<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span style="font-size:10.0pt">发件人<span lang="EN-US">:</span></span></b><span lang="EN-US" style="font-size:10.0pt"> Ankit Agarwal [mailto:ankit.spd@gmail.com]
<br>
</span><b><span style="font-size:10.0pt">发送时间<span lang="EN-US">:</span></span></b><span lang="EN-US" style="font-size:10.0pt"> 2016</span><span style="font-size:10.0pt">年<span lang="EN-US">1</span>月<span lang="EN-US">29</span>日<span lang="EN-US"> 15:32<br>
</span><b>收件人<span lang="EN-US">:</span></b><span lang="EN-US"> Suipengfei<br>
</span><b>抄送<span lang="EN-US">:</span></b><span lang="EN-US"> swift-users@swift.org<br>
</span><b>主题<span lang="EN-US">:</span></b><span lang="EN-US"> Re: [swift-users] hi every one
</span>,<span lang="EN-US">who can help me? </span>3Q ~<span lang="EN-US"><o:p></o:p></span></span></p>
</div>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">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 :<o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US"><a href="http://ankit.im/swift/2015/12/27/ship-c-code-with-swift-packages-using-swift-package-manager/">http://ankit.im/swift/2015/12/27/ship-c-code-with-swift-packages-using-swift-package-manager/</a><br>
<br>
On Friday 29 January 2016, Suipengfei via swift-users <<a href="mailto:swift-users@swift.org">swift-users@swift.org</a>> wrote:<o:p></o:p></span></p>
<div>
<div>
<p><span lang="EN-US">Hi all, I want to make a simple emample to show swift can call c library.
<o:p></o:p></span></p>
<p><span lang="EN-US"> <o:p></o:p></span></p>
<p><span lang="EN-US">So ,I make a simple example,like this:<o:p></o:p></span></p>
<p><span lang="EN-US"> <o:p></o:p></span></p>
<p><span lang="EN-US">$ cat a.c<o:p></o:p></span></p>
<p><span lang="EN-US">int add(int a,int b){<o:p></o:p></span></p>
<p><span lang="EN-US"> return a + b;<o:p></o:p></span></p>
<p><span lang="EN-US">}<o:p></o:p></span></p>
<p><span lang="EN-US"> <o:p></o:p></span></p>
<p><span lang="EN-US">And I make a lib,<o:p></o:p></span></p>
<p><span lang="EN-US">$ gcc -o a.o -c a.c<o:p></o:p></span></p>
<p><span lang="EN-US">$ ar rcs libmylib.a a.o<o:p></o:p></span></p>
<p><span lang="EN-US"> <o:p></o:p></span></p>
<p><span lang="EN-US">And I put libmylib.a in the same director with the main.swift
<o:p></o:p></span></p>
<p><span lang="EN-US"> <o:p></o:p></span></p>
<p><span lang="EN-US">$ cat main.swift<o:p></o:p></span></p>
<p><span lang="EN-US">import mylib<o:p></o:p></span></p>
<p><span lang="EN-US">var b = add(10,20)<o:p></o:p></span></p>
<p><span lang="EN-US">print(b)<o:p></o:p></span></p>
<p><span lang="EN-US"> <o:p></o:p></span></p>
<p><span lang="EN-US">when I compile : <o:p></o:p></span></p>
<p><span lang="EN-US">$ swiftc main.swift<o:p></o:p></span></p>
<p><span lang="EN-US">main.swift:1:8: error: no such module 'mylib'<o:p></o:p></span></p>
<p><span lang="EN-US">import mylib<o:p></o:p></span></p>
<p><span lang="EN-US"> ^<o:p></o:p></span></p>
<p><span lang="EN-US"> <o:p></o:p></span></p>
<p><span lang="EN-US"> <o:p></o:p></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 ~<o:p></o:p></span></p>
<p><span lang="EN-US"> <o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span lang="EN-US"> <o:p></o:p></span></p>
</div>
</div>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span lang="EN-US"><br>
<br>
-- <br>
Ankit<br>
<br>
<o:p></o:p></span></p>
</div>
</body>
</html>