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

symbol(s) not found for architecture x86_64 #592

Closed
VictorVanDoom opened this issue Jan 16, 2017 · 8 comments
Closed

symbol(s) not found for architecture x86_64 #592

VictorVanDoom opened this issue Jan 16, 2017 · 8 comments

Comments

@VictorVanDoom
Copy link

VictorVanDoom commented Jan 16, 2017

Hi,

when I try to build SQLite using the swift x86_64 compiler on macOS (probably also on Linux, didn't test that yet), I get the following build error:

...
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)
...

The swift-compiler is version 3.0.2-RELEASE. I've tried setting up a new swift project with only the SQLite-dependency to rule out any dependency on my side, but I get the same build-error.

Edit: It does seem to work when I generate the Xcode-project using swift package generate-xcodeproj and enable Modules for the SQLiteObjC target. Unfortunately this does not really help, as, in the end, my build-pipeline will invoke the swift-build command on a Linux machine.

@iNoles
Copy link

iNoles commented Jan 16, 2017

I think it is looking for Xcode in module maps.

@jberkel
Copy link
Collaborator

jberkel commented Jan 16, 2017

you'll need to add the linker option:

$ swift build -Xlinker -lsqlite3

@VictorVanDoom
Copy link
Author

Thank you. That does seem to do the trick, at least on my macOS machine.
I'll give it a run on my pipeline.

@jberkel
Copy link
Collaborator

jberkel commented Jan 17, 2017

OK, but Linux might not work out of the box (yet).

@VictorVanDoom
Copy link
Author

VictorVanDoom commented Jan 17, 2017

Unfortunately, you are right :-(
My build environment crashes somewhere when trying to compile SQliteObjc's SQlite-Bridging.m file. Judging by this issue 315, it still might take some time until a fix is available.
Anyhow, thank you for the help.

@jberkel
Copy link
Collaborator

jberkel commented Jan 17, 2017

@VictorVanDoom Linux support shouldn't be too tricky to add. @stephencelis, can you give me write access to https://github.com/stephencelis/CSQlite?

@stephencelis
Copy link
Owner

@jberkel Done!

@TianhaoHarryZhang
Copy link

Hi experts, when compiling something similar in my Qt Creator IDE, I got similar error as below:

Undefined symbols for architecture x86_64:
"_sqlite3_errmsg", referenced from:
Database::create_database(sqlite3*) in Sqlite.cpp.o
"_sqlite3_exec", referenced from:
Database::create_table(sqlite3*) in Sqlite.cpp.o
"_sqlite3_free", referenced from:
Database::create_table(sqlite3*) in Sqlite.cpp.o
"_sqlite3_open", referenced from:
Database::create_database(sqlite3*) in Sqlite.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
16:34:32: The process "/Users/harryzhang/Qt/Tools/CMake/CMake.app/Contents/bin/cmake" exited with code 1.
Error while building/deploying project test (kit: Qt 6.5.1 for macOS)
The kit Qt 6.5.1 for macOS has configuration issues which might be the root cause for this problem.
When executing step "Build"

I guess it means the compiler failed to find the sqlite dependency/framwork. Can anyone advise how to add code in CMakelists.txt file? The code was compilable in Mac terminal with g++ but failed in Qt Creator

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

5 participants