<div dir="ltr"><div>Thanks.</div>It compiled successfully now under linux.<div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-01-04 12:29 GMT-06:00 Joe Groff <span dir="ltr"><<a href="mailto:jgroff@apple.com" target="_blank">jgroff@apple.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><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>
</span><div><div class="h5">> 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>
</div></div>Try making `test` static inline instead of just static.<br>
<span class="HOEnZb"><font color="#888888"><br>
-Joe<br>
<br>
</font></span></blockquote></div><br></div>