<div dir="ltr">Hi Michael,<div><br></div><div>The attachment is the packages I created for testing purpose.</div><div>You can check it.</div><div><br></div><div>Thanks for the help,</div><div><br></div><div>Yang</div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-12-30 18:15 GMT-06:00 Michael Gottesman <span dir="ltr"><<a href="mailto:mgottesman@apple.com" target="_blank">mgottesman@apple.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Can you create a quick tarball of the swiftpm project. Would expedite the answering of the question.<br>
<br>
Michael<br>
<div><div class="h5"><br>
> On Dec 30, 2016, at 11:17 AM, Yang Yang via swift-users <<a href="mailto:swift-users@swift.org">swift-users@swift.org</a>> wrote:<br>
><br>
> I try to wrap a c library in swift package named Test.<br>
> The code looks like this:<br>
><br>
> Test1.h<br>
><br>
> struct MyParams {<br>
> int (*func)();<br>
> };<br>
><br>
> typedef struct MyParams MyParams;<br>
><br>
> Test2.h<br>
> #include "Test1.h"<br>
><br>
> static int test(){<br>
> return 0;<br>
> }<br>
><br>
> void myTest()<br>
> {<br>
> MyParams params;<br>
> params.func = test;<br>
> }<br>
><br>
><br>
> Then I try to import the package into swift code and use<br>
> in Test.swift.<br>
> ************************<br>
> import Test<br>
><br>
> class TestSwift {<br>
> func runtest(){<br>
> myTest()<br>
> }<br>
> }<br>
><br>
> However, the compiler report link error:<br>
> function myTest: error: undefined reference to 'test'<br>
><br>
> If I comment out<br>
> "params.func = test;" in myTest.<br>
><br>
> It successfully build. How should I handle this situation?<br>
><br>
> Thanks,<br>
><br>
> Yang<br>
</div></div>> ______________________________<wbr>_________________<br>
> swift-users mailing list<br>
> <a href="mailto:swift-users@swift.org">swift-users@swift.org</a><br>
> <a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-users</a><br>
<br>
</blockquote></div><br></div>