Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPM - Undefined symbols for architecture x86_64 #577

Closed
neoneye opened this issue Dec 21, 2016 · 5 comments
Closed

SPM - Undefined symbols for architecture x86_64 #577

neoneye opened this issue Dec 21, 2016 · 5 comments

Comments

@neoneye
Copy link

neoneye commented Dec 21, 2016

I have made a SQLite.swift fork that I have tagged with 0.11.2, so that I can use it with SPM. I have not made any commits.

When I try to build, then I'm getting errors like this:

PROMPT> swift build
Cloning https://github.com/neoneye/SQLite.swift.git
HEAD is now at f6d7593 Merge pull request #572 from stephencelis/where-alias
Resolved version: 0.11.2
Compile SQLiteObjc SQLite-Bridging.m
Linking SQLiteObjc
Undefined symbols for architecture x86_64:
  "_sqlite3_bind_blob", referenced from:
      __SQLiteRegisterTokenizer in SQLite-Bridging.m.o
  "_sqlite3_bind_text", referenced from:
      __SQLiteRegisterTokenizer in SQLite-Bridging.m.o
  "_sqlite3_finalize", referenced from:
      __SQLiteRegisterTokenizer in SQLite-Bridging.m.o
  "_sqlite3_free", referenced from:
      ___SQLiteTokenizerDestroy in SQLite-Bridging.m.o
      ___SQLiteTokenizerClose in SQLite-Bridging.m.o
  "_sqlite3_malloc", referenced from:
      ___SQLiteTokenizerCreate in SQLite-Bridging.m.o
      ___SQLiteTokenizerOpen in SQLite-Bridging.m.o
  "_sqlite3_prepare_v2", referenced from:
      __SQLiteRegisterTokenizer in SQLite-Bridging.m.o
  "_sqlite3_step", referenced from:
      __SQLiteRegisterTokenizer in SQLite-Bridging.m.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
<unknown>:0: error: build had 1 command failures
error: exit(1): /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-build-tool -f /Users/johndoe/MyServer/.build/debug.yaml

Package.swift

import PackageDescription

let package = Package(
	name: "MyServer",
	targets: [],
	dependencies: [
		.Package(url: "https://github.com/PerfectlySoft/Perfect-HTTPServer.git", majorVersion: 2, minor: 0),
//		.Package(url: "https://github.com/stephencelis/SQLite.swift.git", majorVersion: 0)
		.Package(url: "https://github.com/neoneye/SQLite.swift.git", versions: Version(0,11,1)..<Version(0,11,.max))
    ]
)

Setup

  • Xcode 8.1 (8B62)
  • macOS 10.12.1
@jberkel
Copy link
Collaborator

jberkel commented Dec 21, 2016

You need to pass in some linker flags, see the docs:

$ swift build -Xlinker -lsqlite3

Not sure if there's an easy way around that.

@neoneye
Copy link
Author

neoneye commented Dec 21, 2016

This works.

Have a great day @jberkel

@neoneye neoneye closed this as completed Dec 21, 2016
@neoneye
Copy link
Author

neoneye commented Dec 22, 2016

@jberkel I think the linker flag problem has been solved in the Perfect-sqlite3-support project. Maybe useful?

@neoneye neoneye reopened this Dec 22, 2016
@jberkel
Copy link
Collaborator

jberkel commented Dec 22, 2016

Hm, it looks like this is by design, you can't specify linker flags in side the package itself:
swiftlang/swift-package-manager#107

@neoneye neoneye closed this as completed Dec 23, 2016
@TimothyMDean
Copy link

TimothyMDean commented Apr 27, 2017

It seems like this should be possible to avoid in SPM using the approach described in the SPM documentation for depending on a system library. The last comment from @jberkel suggested that this limitation is by design, but reading the history of the linked SPM PR it seems to apply only to additional flags like -fblocks. It seems like simply linking to the sqlite3 system library should be possible without additional flags.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants