<div dir="ltr"><div>hi,</div><div>here is my test under mac os x</div><div><br></div><div>simple version</div>$swiftc -emit-module -emit-library greet.swift<div>emit greet.swiftdoc greet.swiftmodule libgreet.dylib</div><div class="gmail_extra">$swiftc -I. -L. -lgreet test.swift</div><div class="gmail_extra">emit test</div><div class="gmail_extra"><br></div><div class="gmail_extra">detailed version</div><div class="gmail_extra">$swiftc -emit-module -emit-library -module-name greet -module-link-name mm -o libmm.dylib  greet.swift<div>emit greet.swiftdoc greet.swiftmodule libmm.dylib</div><div class="gmail_extra">$swiftc -I. -L. -lmm test.swift</div><div class="gmail_extra">emit test</div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-12-12 23:05 GMT+08:00 Bee via swift-users <span dir="ltr">&lt;<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Sorry… I answer my own question. It need -l&lt;module-name&gt; argument. So, the last command should be:<div><br></div><div>$ swiftc test.swift -lgreet</div><div><br></div><div>then it emitted a runnable app. I wonder why does it need an explicit module name in the command line? While there is already an import clause within the source file. Anyway, problem solved.</div><div><br></div><div>Thank you. :)</div><div><br></div></div><div class="gmail_extra"><div><div class="h5"><br><div class="gmail_quote">On Sat, Dec 12, 2015 at 9:53 PM, Bee <span dir="ltr">&lt;<a href="mailto:bee.ography@gmail.com" target="_blank">bee.ography@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Sorry… forgot to say. I&#39;m using Swift v.2.2 on Linux Ubuntu 14.04.<div><br></div></div><div class="gmail_extra"><div><div><br><div class="gmail_quote">On Sat, Dec 12, 2015 at 9:50 PM, Bee <span dir="ltr">&lt;<a href="mailto:bee.ography@gmail.com" target="_blank">bee.ography@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Hi all,<div><br></div><div>I&#39;d like to create my own simple custom module, but I don&#39;t want to use the complicated package manager. Package manager is overkill for a simple single source file module. So, here&#39;s what I&#39;ve tried.</div><div><br></div><div>file: greet.swift</div><div><br></div><div><div>public func askName() {</div><div><span style="white-space:pre-wrap">        </span>print(&quot;What&#39;s your name? &quot;)</div><div><span style="white-space:pre-wrap">        </span>let name = readLine()!</div><div><span style="white-space:pre-wrap">        </span>print(&quot;Hello, \(name)... good to see you!&quot;)</div><div>}</div></div><div><div><br></div><div>file: main.swift</div><div><br></div><div>askName()<br></div><div><br></div><div>terminal:</div><div><br></div><div>$ swiftc -emit-library -emit-object greet.swift -module-name greet <br></div><div><br></div><div>emits greet.o</div><div><br></div><div>$ ar rcs libgreet.a greet.o<br></div><div><br></div><div>emits libgreet.a</div><div><br></div><div>$ swiftc -emit-module greet.swift -module-name greet   <br></div><div><br></div><div>emits greet.swiftmodule and greet.swiftdoc</div><div><br></div><div>All went well, so I think now I already have had the &quot;greet&quot; module. Let&#39;s try to use it…</div><div><br></div><div>file: test.swift</div><div><br></div><div><div>import greet</div><div>askName()</div></div><div><br></div><div>terminal:</div><div><br></div><div><div><div>$ swiftc test.swift </div><div>clang: warning: argument unused during compilation: &#39;-F/home/username&#39;</div><div>/tmp/test-b63aab.o: In function `main&#39;:</div><div>/tmp/test-b63aab.o:(.text+0x41): undefined reference to `_TF5greet7askNameFT_T_&#39;</div><div>clang: error: linker command failed with exit code 1 (use -v to see invocation)</div><div>&lt;unknown&gt;:0: error: link command failed with exit code 1 (use -v to see invocation)</div></div></div><div><br></div><div>What&#39;s happening? What&#39;s wrong? How can I fix it?</div><div><br></div><div>Thank you.</div><div><br></div><div>Regards,</div><span><font color="#888888"><div><br></div>-- <br><div><div dir="ltr"><div>-Bee-<br><br></div></div></div>
</font></span></div></div>
</blockquote></div><br><br clear="all"><div><br></div></div></div><span><font color="#888888">-- <br><div><div dir="ltr"><div>-Bee-<br><br></div></div></div>
</font></span></div>
</blockquote></div><br><br clear="all"><div><br></div></div></div><span class=""><font color="#888888">-- <br><div><div dir="ltr"><div>-Bee-<br><br></div></div></div>
</font></span></div><span class=""><font color="#888888">
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=IbBo19sGbNrXFSWIq2lsYcbgDu2cuXtXeZgAOBrFHEXs-2BN1klh-2B0fik74e-2BrzGldDr4iOQWdAvqfMwASyGP7f2G3vWi5-2Bt9-2BJaPYnnChP0YZcNLu-2BGCbm4MNLtSrvWJOIDeE0n7H8QvrcKxRVHKHffsBdPP-2FUQiWHVzRAQaiKliVuQNhz-2FT-2F2-2Bu0Zi7wMN22L3nTywpvLL-2F5EfR8BZB2KGoI3kC6eQkLK7g4AM-2BFb0s-3D" alt="" width="1" height="1" border="0" style="min-height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;">
</font></span><br>_______________________________________________<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/mailman/listinfo/swift-users</a><br>
<br></blockquote></div><br></div></div>