[swift-users] Undefined symbols preventing build

Kilian Koeltzsch me at kilian.io
Tue Dec 8 14:36:57 CST 2015


Hello all,

I've tried using the Swift 2.2 compiler from swift.org to compile a
simple sample project locally on OS X containing nothing besides a
hello-world example and a basic Package.swift but am failing to do so
due to several "Undefined symbols for architecture x86_64". 

The sample project is as simple as possible with only a Package.swift
and a Sources directory containing a main.swift with nothing but a
print() statement. There is nothing declared in the Package.swift
besides the name of the module and an empty dependencies array.

This is the complete output from running `swift build`:

Compiling Swift Module 'foo' (1 sources)
Linking Executable:  .build/debug/foo
Undefined symbols for architecture x86_64:
  "__TFSSCfT21_builtinStringLiteralBp8byteSizeBw7isASCIIBi1__SS",
  referenced from:
      _main in main.swift.o
  "__TFs5printFTGSaP__9separatorSS10terminatorSS_T_", referenced from:
      _main in main.swift.o
  "__TIFs5printFTGSaP__9separatorSS10terminatorSS_T_A0_", referenced
  from:
      _main in main.swift.o
  "__TIFs5printFTGSaP__9separatorSS10terminatorSS_T_A1_", referenced
  from:
      _main in main.swift.o
  "__TMSS", referenced from:
      _main in main.swift.o
  "__TTSg5P____TFs27_allocateUninitializedArrayurFBwTGSax_Bp_",
  referenced from:
      _main in main.swift.o
  "__TZvOs7Process11_unsafeArgvGSpGSpVs4Int8__", referenced from:
      _main in main.swift.o
  "__TZvOs7Process5_argcVs5Int32", referenced from:
      _main in main.swift.o
  "_globalinit_33_1BDF70FFC18749BAB495A73B459ED2F0_func5", referenced
  from:
      _main in main.swift.o
  "_globalinit_33_1BDF70FFC18749BAB495A73B459ED2F0_token5", referenced
  from:
      _main in main.swift.o
ld: symbol(s) not found for architecture x86_64
<unknown>:0: error: build had 1 command failures
swift-build: exit(1):
["/Library/Developer/Toolchains/swift-2.2-SNAPSHOT-2015-12-01-a.xctoolchain/usr/bin/swift-build-tool",
"-f", "/Users/kilian/Desktop/foo/.build/debug/foo.o/llbuild.yaml"]

This minimal example seems to be working fine on other installs of OS X
and also inside an Ubuntu VM.

Any help on how to fix this would be much appreciated. Anything I can
find online on this refers to adjusting Xcode build setting to link with
external libraries.

There's also a StackOverflow question for this here[0].

Thank you very much in advance!


[0]
http://stackoverflow.com/questions/34162636/swift-2-2-undefined-symbols-preventing-build


More information about the swift-users mailing list