<div dir="ltr"><div>Hi Daniel </div><div><br></div><div>I just found the bug report [SR-1503] on the new issue I reported (&#39;multiple definition of main&#39;).   I&#39;ll follow the progress on that.  But otherwise the directory structure fix seems to have worked.</div><div><br></div><div>Thanks</div><div>Greg</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 24, 2016 at 1:28 PM, G J <span dir="ltr">&lt;<a href="mailto:fishpesce@gmail.com" target="_blank">fishpesce@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Daniel <div><br></div><div>Thanks for filing the bug.  I fixed the directory structure per your comments.</div><div><br></div><div>Package.swift (with module name WindFarmIRR)</div><div>Sources</div><div>Sources/main.swift</div><div>Sources/.....</div><div>Tests</div><div>Tests/LinuxMain.swift</div><div>Tests/WindFarmIRR</div><div>Tests/WIndFarmIRR/WindFarmIRRTests.swift</div><div><br></div><div>in LinuxMain I have &quot;@testable import WindFarmIRRTestSuite&quot;</div><div>in WindFarmIRRTests.swift I have &quot;@testable import WindFarmIRR&quot;</div><div><br></div><div>but now I get an error referring to multiple definitions of &#39;main&#39;:</div><div>---------</div><div><div>Linking .build/debug/WindFarmIRRTests.xctest</div><div>/home/greg/Dropbox/common_files/Programming/Swift/commercial/WindFutureLLC/WindFarmIRR/linux/WindFarmIRR-SwiftPM/.build/debug/WindFarmIRR.build/main.swift.o: In function `main&#39;:</div><div>/home/greg/Dropbox/common_files/Programming/Swift/commercial/WindFutureLLC/WindFarmIRR/linux/WindFarmIRR-SwiftPM/Sources/main.swift:(.text+0x0): multiple definition of `main&#39;</div><div>/tmp/LinuxMain-4748b9.o:/home/greg/Dropbox/common_files/Programming/Swift/commercial/WindFutureLLC/WindFarmIRR/linux/WindFarmIRR-SwiftPM/Tests/LinuxMain.swift:(.text+0x0): first defined here</div><span class=""><div>clang-3.8: error: linker command failed with exit code 1 (use -v to see invocation)</div></span></div><div>----------</div><div><br></div><div>so as best I can piece this together, the executable WindFarmIRR module is now being found and its &#39;main&#39; is in conflict with the entry point in LinuxMain.swift.  I suspect I still have something not quite right with the naming conventions and directory layout.  </div><div><br></div><div>I am on an up-to-date archlinux system, with packages clang-3.8.0-1 and swift-development-DEVELOPMENT.SNAPSHOT.2016.05.09.a-2 (from AUR)</div><div><br></div><div><br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 24, 2016 at 11:47 AM, Daniel Dunbar <span dir="ltr">&lt;<a href="mailto:daniel_dunbar@apple.com" target="_blank">daniel_dunbar@apple.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Currently your Tests subdirectory needs to be named WindFarmIRR, which is not something we do a good job of diagnosing. I filed:<br>
  <a href="https://bugs.swift.org/browse/SR-1607" rel="noreferrer" target="_blank">https://bugs.swift.org/browse/SR-1607</a><br>
to track fixing this.<br>
<br>
 - Daniel<br>
<div><div><br>
&gt; On May 24, 2016, at 7:05 AM, G J via swift-build-dev &lt;<a href="mailto:swift-build-dev@swift.org" target="_blank">swift-build-dev@swift.org</a>&gt; wrote:<br>
&gt;<br>
&gt; I am attempting to use unit tests on a swift project in linux with Swift DEVELOPMENT.SNAPSHOT.2016.05.09.a.<br>
&gt;<br>
&gt; The executable is built in a module named WindFarmIRR with directory structure:<br>
&gt;<br>
&gt; Package.swift<br>
&gt; Sources (D)<br>
&gt;       main.swift<br>
&gt;       irr.swift<br>
&gt;       stringHelpers.swift<br>
&gt; Tests (D)<br>
&gt;       LinuxMain.swift<br>
&gt;       WindFarmIRRTests (D)<br>
&gt;              WindFarmIRRTests.swift<br>
&gt;<br>
&gt;<br>
&gt; my test file, WindFarmIRRTests.swift, includes a line to import the WindFarmIRR module:    @testable import WindFarmIRR.<br>
&gt;<br>
&gt; I am able to build the module successfully.   When I run swift test, however, the build fails with an &#39;undefined reference to&#39; error.   Sample output is:<br>
&gt;<br>
&gt; swift test<br>
&gt; Compile Swift Module &#39;WindFarmIRRTestsTestSuite&#39; (1 sources)<br>
&gt; Linking .build/debug/WindFarmIRRTests.xctest<br>
&gt; /home/greg/Dropbox/common_files/Programming/Swift/commercial/WindFutureLLC/WindFarmIRR/linux/WindFarmIRR-SwiftPM/.build/debug/WindFarmIRRTestsTestSuite.build/WindFarmIRRTests.swift.o: In function `_TFC25WindFarmIRRTestsTestSuite16WindFarmIRRTests26testCashFlowStructCashFlowfT_T_&#39;:<br>
&gt; /home/greg/Dropbox/common_files/Programming/Swift/commercial/WindFutureLLC/WindFarmIRR/linux/WindFarmIRR-SwiftPM/Tests/WindFarmIRRTests/WindFarmIRRTests.swift:19: undefined reference to `_TFV11WindFarmIRR8CashFlowCfT_S0_&#39;<br>
&gt; /home/greg/Dropbox/common_files/Programming/Swift/commercial/WindFutureLLC/WindFarmIRR/linux/WindFarmIRR-SwiftPM/.build/debug/WindFarmIRRTestsTestSuite.build/WindFarmIRRTests.swift.o: In function `_TFFC25WindFarmIRRTestsTestSuite16WindFarmIRRTests26testCashFlowStructCashFlowFT_T_u_KzT_GSqSd_&#39;:<br>
&gt; /home/greg/Dropbox/common_files/Programming/Swift/commercial/WindFutureLLC/WindFarmIRR/linux/WindFarmIRR-SwiftPM/Tests/WindFarmIRRTests/WindFarmIRRTests.swift:26: undefined reference to `_TFV11WindFarmIRR8CashFlow8cashFlowfT_Sd&#39;<br>
&gt; clang-3.8: error: linker command failed with exit code 1 (use -v to see invocation)<br>
&gt; &lt;unknown&gt;:0: error: link command failed with exit code 1 (use -v to see invocation)<br>
&gt; &lt;unknown&gt;:0: error: build had 1 command failures<br>
&gt; error: exit(1): /usr/bin/swift-build-tool -f /home/greg/Dropbox/common_files/Programming/Swift/commercial/WindFutureLLC/WindFarmIRR/linux/WindFarmIRR-SwiftPM/.build/debug.yaml test<br>
&gt;<br>
&gt; Text of LinuxMain.swift is:<br>
&gt; ------------------<br>
&gt; import XCTest<br>
&gt;<br>
&gt; @testable import WindFarmIRRTestsTestSuite<br>
&gt;<br>
&gt; XCTMain([<br>
&gt;     testCase(WindFarmIRRTests.allTests)<br>
&gt; ])<br>
&gt; -------------------<br>
&gt;<br>
&gt; Text of WindFarmIRRTests.swift is:<br>
&gt; --------------------<br>
&gt; #if os(Linux)<br>
&gt; extension WindFarmIRRTests {<br>
&gt;      static var allTests : [(String, (WindFarmIRRTests) -&gt; () throws -&gt; Void)] {<br>
&gt;         return [<br>
&gt;             (&quot;testCashFlowStructCashFlow&quot;, testCashFlowStructCashFlow)<br>
&gt;         ]<br>
&gt;     }<br>
&gt; }<br>
&gt; #endif<br>
&gt;<br>
&gt; import XCTest<br>
&gt; @testable import WindFarmIRR<br>
&gt;<br>
&gt; class WindFarmIRRTests: XCTestCase {<br>
&gt;<br>
&gt;<br>
&gt;     func testCashFlowStructCashFlow(){<br>
&gt;<br>
&gt;         var cf = CashFlow()<br>
&gt;         cf.electricitySaleIncome = 100<br>
&gt;         cf.capitalCosts = 0<br>
&gt;         cf.oAndMCosts = 0<br>
&gt;         cf.transmissionCosts = 0<br>
&gt;<br>
&gt;<br>
&gt;         XCTAssertEqual(cf.cashFlow(),100)<br>
&gt;<br>
&gt;<br>
&gt;     }<br>
&gt;<br>
&gt; }<br>
&gt; ---------------------------<br>
&gt;<br>
&gt;<br>
&gt; The problem appears to be that the linker cannot find the executable module to resolve the relevant symbols.<br>
&gt;<br>
&gt; I would appreciate suggestions on what I am missing in the setup.<br>
&gt;<br>
&gt;<br>
&gt; Thanks<br>
&gt;<br>
</div></div>&gt; _______________________________________________<br>
&gt; swift-build-dev mailing list<br>
&gt; <a href="mailto:swift-build-dev@swift.org" target="_blank">swift-build-dev@swift.org</a><br>
&gt; <a href="https://lists.swift.org/mailman/listinfo/swift-build-dev" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-build-dev</a><br>
<br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>