hi, here is my test under mac os x simple version $swiftc -emit-module -emit-library greet.swift emit greet.swiftdoc greet.swiftmodule libgreet.dylib $swiftc -I. -L. -lgreet test.swift emit test
detailed version $swiftc -emit-module -emit-library -module-name greet -module-link-name mm -o libmm.dylib greet.swift emit greet.swiftdoc greet.swiftmodule libmm.dylib $swiftc -I. -L. -lmm test.swift emit test 2015-12-12 23:05 GMT+08:00 Bee via swift-users <[email protected]>: > Sorry… I answer my own question. It need -l<module-name> argument. So, the > last command should be: > > $ swiftc test.swift -lgreet > > 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. > > Thank you. :) > > > On Sat, Dec 12, 2015 at 9:53 PM, Bee <[email protected]> wrote: > >> Sorry… forgot to say. I'm using Swift v.2.2 on Linux Ubuntu 14.04. >> >> >> On Sat, Dec 12, 2015 at 9:50 PM, Bee <[email protected]> wrote: >> >>> Hi all, >>> >>> I'd like to create my own simple custom module, but I don't want to use >>> the complicated package manager. Package manager is overkill for a simple >>> single source file module. So, here's what I've tried. >>> >>> file: greet.swift >>> >>> public func askName() { >>> print("What's your name? ") >>> let name = readLine()! >>> print("Hello, \(name)... good to see you!") >>> } >>> >>> file: main.swift >>> >>> askName() >>> >>> terminal: >>> >>> $ swiftc -emit-library -emit-object greet.swift -module-name greet >>> >>> emits greet.o >>> >>> $ ar rcs libgreet.a greet.o >>> >>> emits libgreet.a >>> >>> $ swiftc -emit-module greet.swift -module-name greet >>> >>> emits greet.swiftmodule and greet.swiftdoc >>> >>> All went well, so I think now I already have had the "greet" module. >>> Let's try to use it… >>> >>> file: test.swift >>> >>> import greet >>> askName() >>> >>> terminal: >>> >>> $ swiftc test.swift >>> clang: warning: argument unused during compilation: '-F/home/username' >>> /tmp/test-b63aab.o: In function `main': >>> /tmp/test-b63aab.o:(.text+0x41): undefined reference to >>> `_TF5greet7askNameFT_T_' >>> clang: error: linker command failed with exit code 1 (use -v to see >>> invocation) >>> <unknown>:0: error: link command failed with exit code 1 (use -v to see >>> invocation) >>> >>> What's happening? What's wrong? How can I fix it? >>> >>> Thank you. >>> >>> Regards, >>> >>> -- >>> -Bee- >>> >>> >> >> >> -- >> -Bee- >> >> > > > -- > -Bee- > > > _______________________________________________ > swift-users mailing list > [email protected] > https://lists.swift.org/mailman/listinfo/swift-users > >
_______________________________________________ swift-users mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-users
