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

Linux support? #315

Closed
honghaoz opened this issue Jan 9, 2016 · 24 comments
Closed

Linux support? #315

honghaoz opened this issue Jan 9, 2016 · 24 comments

Comments

@honghaoz
Copy link

honghaoz commented Jan 9, 2016

Do we have plan for supporting Linux platform? Just like this https://github.com/Zewo/PostgreSQL

@mikemee
Copy link
Collaborator

mikemee commented Jan 9, 2016

Personally I can't wait to start using the Swift Package Manager, but don't yet have it running myself on Linux. I'm sure @stephencelis would be happy to take a PR 👍

@stephencelis
Copy link
Owner

Yup! I'd love headway here 😄

@mikemee
Copy link
Collaborator

mikemee commented Jan 11, 2016

Added to Feature Requests.

@mikemee mikemee closed this as completed Jan 11, 2016
sauliusgrigaitis added a commit to necolt/SQLite.swift that referenced this issue Mar 14, 2016
@zmeyc
Copy link

zmeyc commented Apr 12, 2016

@sauliusgrigaitis were you able to build the lib on Linux?

@sauliusgrigaitis
Copy link

@zmeyc, yes, I built Swift libdispatch and was able to build SQLite.swift on Linux. So next step would be to get tests running on Linux to make sure that everything works correctly.

@zmeyc
Copy link

zmeyc commented Apr 12, 2016

@sauliusgrigaitis I compiled libdispatch following the steps from IBM Kitura's README.md and almost built the SQLite.swift, but there are two errors left, probably because CSQLite module links to /usr/include/sqlite3.h which is too old on Ubuntu 14. Did you encounter this problem?

Compiling Swift Module 'SQLite' (17 sources)
/home/user/SQLite.swift/SQLite/Core/Connection.swift:533:22: error: use of unresolved identifier 'SQLITE_DETERMINISTIC'
            flags |= SQLITE_DETERMINISTIC
                     ^~~~~~~~~~~~~~~~~~~~

@zmeyc
Copy link

zmeyc commented Apr 12, 2016

@sauliusgrigaitis I finally built it this way:

Installed sqlite3 from source with
configure --prefix=/usr/local
make install

Then in CSQLite's modulemap referenced the header from /usr/local:
header "/usr/local/include/sqlite3.h"
https://github.com/zmeyc/CSQLite/blob/master/module.modulemap

Then built the project with the new library version:
swift build -Xcc -fblocks -Xlinker -L/usr/local/lib

It also works without -L, but probably links to older library version from /usr.

@sauliusgrigaitis
Copy link

@zmeyc I use Ubuntu 15.10, that's why I didn't have issues with sqlite headers. Did you get tests running?

@zmeyc
Copy link

zmeyc commented Apr 26, 2016

@sauliusgrigaitis Not yet, I'm in process of porting it to Swift 3 (DEVELOPMENT-SNAPSHOT-2016-04-12-a) on OS X. I think it makes sense to use the latest Swift build for SPM package, other projects like Zewo already switched to it. I wonder how to submit PR to @stephencelis , Swift Package Manager can't clone branches yet. It can only clone tags from master, but this needs to be a separate branch...

@sauliusgrigaitis
Copy link

sauliusgrigaitis commented Apr 26, 2016

@zmeyc I don't think that there will be easy way to merge your branch into @stephencelis master, because this project targets iOS Swift 2. Probably easiest would be to keep your port in your fork until Swift 3 is released. People will be able to install your fork via SPM.

@zmeyc
Copy link

zmeyc commented Apr 28, 2016

@sauliusgrigaitis @stephencelis Ported everything except FTS4 (which relies on .m file which I didn't find a way to compile) to DEVELOPMENT-SNAPSHOT-2016-04-12-a, tests also run (I only commented out FTS4). Also added sqlite3.c to not depend on system one. Didn't tried it on Linux yet, only OS X:
https://github.com/zmeyc/SQLite.swift

After generating Xcode project with 'swift build -X', add "Sources/CSQLite" to Import Path in Build Settings to fix "import CSQLite - module not found" error.

upd: Maybe it's possible to move Swift-3 development to master and keep the old version in 'stable' branch? I think it's possible to make the 'stable' branch the default one on Github.

@zmeyc
Copy link

zmeyc commented Apr 28, 2016

@sauliusgrigaitis @stephencelis Added build instructions to fork's README.md and fixed compilation errors on Linux. Tests won't run on Linux because 'swift test' doesn't support -X flag which is needed for libdispatch.

@sauliusgrigaitis
Copy link

@zmeyc thanks, I'll check when I have opportunity. SPM is progressing fast, so there should be way to pass flags soon.

@sauliusgrigaitis
Copy link

@zmeyc check https://github.com/Zewo/URI , this project has tests running on Linux and it also has compiled dependency.

@zmeyc
Copy link

zmeyc commented May 9, 2016

@sauliusgrigaitis It doesn't use libdispatch. It's trivial to add LinuxMain.swift to run the tests on Linux, but the problem is SQLite uses libdispatch which requires swift build -Xcc -fblocks -Xlinker -ldispatch flags. swift test doesn't accept the flags (yet).

@sauliusgrigaitis
Copy link

@zmeyc I'm not about LinuxMain.swift, I'm more about fact that https://github.com/Zewo/URI depends on https://github.com/Zewo/CURIParser which is C library automatically compiled during SPM build. So maybe it's possible to have same structure where SQLite.swift depends on external libdispatch package which is automatically compiled with SPM, I believe that also should solve swift test issue.

@zmeyc
Copy link

zmeyc commented May 9, 2016

@sauliusgrigaitis C modules are very limited in current version and it's not possible to compile a project which requires Makefile. Or at least I don't know how. :)

@iNoles
Copy link

iNoles commented May 9, 2016

SPM doesn't use Makefile.

@sauliusgrigaitis
Copy link

Hm... I think I saw somewhere a way to run Swift tests directly without SPM somewhere, maybe this way would allow to pass flags.

@wadetregaskis
Copy link
Contributor

FYI I went through the exercise of making this work properly, and seem to have succeeded (https://github.com/wadetregaskis/SQLite.swift/tree/prepare-0.11.1). Pull request #548.

@jberkel
Copy link
Collaborator

jberkel commented Dec 20, 2016

@zmeyc there's now Package manager support in master, thanks to @wadetregaskis. Maybe it would be a good moment to integrate your changes as well?

@zmeyc
Copy link

zmeyc commented Dec 20, 2016

@jberkel I think they're outdated now. Compiling libdispatch manually is no longer required as well as most compatibility fixes.

@jberkel
Copy link
Collaborator

jberkel commented Dec 20, 2016

@zmeyc Ok, good to know. I don't have Linux installed so hoping somebody will come along and submit the necessary patches.

@jberkel
Copy link
Collaborator

jberkel commented Jan 17, 2017

#594 (WIP)

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

No branches or pull requests

8 participants