<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 ('multiple definition of main'). I'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"><<a href="mailto:fishpesce@gmail.com" target="_blank">fishpesce@gmail.com</a>></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 "@testable import WindFarmIRRTestSuite"</div><div>in WindFarmIRRTests.swift I have "@testable import WindFarmIRR"</div><div><br></div><div>but now I get an error referring to multiple definitions of 'main':</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':</div><div>/home/greg/Dropbox/common_files/Programming/Swift/commercial/WindFutureLLC/WindFarmIRR/linux/WindFarmIRR-SwiftPM/Sources/main.swift:(.text+0x0): multiple definition of `main'</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 'main' 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"><<a href="mailto:daniel_dunbar@apple.com" target="_blank">daniel_dunbar@apple.com</a>></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>
> On May 24, 2016, at 7:05 AM, G J via swift-build-dev <<a href="mailto:swift-build-dev@swift.org" target="_blank">swift-build-dev@swift.org</a>> wrote:<br>
><br>
> I am attempting to use unit tests on a swift project in linux with Swift DEVELOPMENT.SNAPSHOT.2016.05.09.a.<br>
><br>
> The executable is built in a module named WindFarmIRR with directory structure:<br>
><br>
> Package.swift<br>
> Sources (D)<br>
> main.swift<br>
> irr.swift<br>
> stringHelpers.swift<br>
> Tests (D)<br>
> LinuxMain.swift<br>
> WindFarmIRRTests (D)<br>
> WindFarmIRRTests.swift<br>
><br>
><br>
> my test file, WindFarmIRRTests.swift, includes a line to import the WindFarmIRR module: @testable import WindFarmIRR.<br>
><br>
> I am able to build the module successfully. When I run swift test, however, the build fails with an 'undefined reference to' error. Sample output is:<br>
><br>
> swift test<br>
> Compile Swift Module 'WindFarmIRRTestsTestSuite' (1 sources)<br>
> Linking .build/debug/WindFarmIRRTests.xctest<br>
> /home/greg/Dropbox/common_files/Programming/Swift/commercial/WindFutureLLC/WindFarmIRR/linux/WindFarmIRR-SwiftPM/.build/debug/WindFarmIRRTestsTestSuite.build/WindFarmIRRTests.swift.o: In function `_TFC25WindFarmIRRTestsTestSuite16WindFarmIRRTests26testCashFlowStructCashFlowfT_T_':<br>
> /home/greg/Dropbox/common_files/Programming/Swift/commercial/WindFutureLLC/WindFarmIRR/linux/WindFarmIRR-SwiftPM/Tests/WindFarmIRRTests/WindFarmIRRTests.swift:19: undefined reference to `_TFV11WindFarmIRR8CashFlowCfT_S0_'<br>
> /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_':<br>
> /home/greg/Dropbox/common_files/Programming/Swift/commercial/WindFutureLLC/WindFarmIRR/linux/WindFarmIRR-SwiftPM/Tests/WindFarmIRRTests/WindFarmIRRTests.swift:26: undefined reference to `_TFV11WindFarmIRR8CashFlow8cashFlowfT_Sd'<br>
> clang-3.8: error: linker command failed with exit code 1 (use -v to see invocation)<br>
> <unknown>:0: error: link command failed with exit code 1 (use -v to see invocation)<br>
> <unknown>:0: error: build had 1 command failures<br>
> 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>
><br>
> Text of LinuxMain.swift is:<br>
> ------------------<br>
> import XCTest<br>
><br>
> @testable import WindFarmIRRTestsTestSuite<br>
><br>
> XCTMain([<br>
> testCase(WindFarmIRRTests.allTests)<br>
> ])<br>
> -------------------<br>
><br>
> Text of WindFarmIRRTests.swift is:<br>
> --------------------<br>
> #if os(Linux)<br>
> extension WindFarmIRRTests {<br>
> static var allTests : [(String, (WindFarmIRRTests) -> () throws -> Void)] {<br>
> return [<br>
> ("testCashFlowStructCashFlow", testCashFlowStructCashFlow)<br>
> ]<br>
> }<br>
> }<br>
> #endif<br>
><br>
> import XCTest<br>
> @testable import WindFarmIRR<br>
><br>
> class WindFarmIRRTests: XCTestCase {<br>
><br>
><br>
> func testCashFlowStructCashFlow(){<br>
><br>
> var cf = CashFlow()<br>
> cf.electricitySaleIncome = 100<br>
> cf.capitalCosts = 0<br>
> cf.oAndMCosts = 0<br>
> cf.transmissionCosts = 0<br>
><br>
><br>
> XCTAssertEqual(cf.cashFlow(),100)<br>
><br>
><br>
> }<br>
><br>
> }<br>
> ---------------------------<br>
><br>
><br>
> The problem appears to be that the linker cannot find the executable module to resolve the relevant symbols.<br>
><br>
> I would appreciate suggestions on what I am missing in the setup.<br>
><br>
><br>
> Thanks<br>
><br>
</div></div>> _______________________________________________<br>
> swift-build-dev mailing list<br>
> <a href="mailto:swift-build-dev@swift.org" target="_blank">swift-build-dev@swift.org</a><br>
> <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>