Is there a simple direct way to compile with libdispatch on Ubuntu?


(Isaac Gouy) #1

I have

    /usr/include/Block.h

    /usr/include/dispatch/dispatch.h

installed and have a program that uses GCD.

Is there a simple direct way to reference libdispatch in the program and on the command line to compile with swiftc?


(francisbailey) #2

Hi Isaac,

I recently came across this issue as well. You can use the command specified in this answer: http://stackoverflow.com/questions/34680816/swift-in-linux-use-of-unresolved-identifier-dispatch-async
Basically adding -Xcc -fblocks should get it to work.

If you're using the swift build command, the latest snapshot 2016-01-25-a, you can now pass in -Xcc args from your Package.swift file. See: https://github.com/apple/swift-package-manager/pull/107 for more details.

···

-------- Original Message --------
Subject: [swift-users] Is there a simple direct way to compile with libdispatch on Ubuntu?
Local Time: January 27, 2016 4:00 pm
UTC Time: January 28, 2016 12:00 AM
From: swift-users@swift.org
To: swift-users@swift.org

I have

/usr/include/Block.h

/usr/include/dispatch/dispatch.h

installed and have a program that uses GCD.

Is there a simple direct way to reference libdispatch in the program and on the command line to compile with swiftc?
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


(Isaac Gouy) #3

I guess I'm still doing something wrong?

module CBlock [system] { header "/usr/include/Block.h"
   link "BlocksRuntime"
   export *
}

module Cdispatch [system] {
   header "/usr/include/dispatch/dispatch.h"
   link "dispatch"
   export *
}

$ ls /usr/include/Block.h
/usr/include/Block.h

$ ls /usr/include/dispatch/dispatch.h
/usr/include/dispatch/dispatch.h

$ ls
CBlock Cdispatch mandelbrot.swift

mandelbrot.swift
    import Glibc
    import CBlock

    import Cdispatch

$ /usr/local/src/swift-2.2-SNAPSHOT-2016-01-25-a-ubuntu15.10/usr/bin/swiftc -o mandelbrot -Ounchecked -whole-module-optimization mandelbrot.swift -Xcc -F-module-map=CBlock/module.modulemap -Xcc -F-module-map=Cdispatch/module.modulemap -Xcc -fblocks -I /usr/include -I ./CBlock -I ./Cdispatch

mandelbrot.swift:23:20: error: use of undeclared type 'dispatch_io_t'
func writeLine(io: dispatch_io_t, _ data: dispatch_data_t, _ queue: dispatch_queue_t, _ last: Bool) {
^~~~~~~~~~~~~
mandelbrot.swift:23:43: error: use of undeclared type 'dispatch_data_t'
func writeLine(io: dispatch_io_t, _ data: dispatch_data_t, _ queue: dispatch_queue_t, _ last: Bool) {
^~~~~~~~~~~~~~~
mandelbrot.swift:24:5: error: use of unresolved identifier 'dispatch_io_write'
dispatch_io_write(io, 0, data, queue) {
^~~~~~~~~~~~~~~~~

etc etc

···

On Wednesday, January 27, 2016 9:57 PM, francisbailey <francisbailey@protonmail.com> wrote:

I recently came across this issue as well. You can use the command specified in this answer: http://stackoverflow.com/questions/34680816/swift-in-linux-use-of-unresolved-identifier-dispatch-async

Basically adding -Xcc -fblocks should get it to work.


(Max Howell) #4

Looks fine to me. Can you zip it up and mail me?

Hopefully I can diagnose the problems. Platform?

···

On Jan 29, 2016, at 12:09 PM, Isaac Gouy via swift-users <swift-users@swift.org> wrote:

I guess I'm still doing something wrong?

module CBlock [system] { header "/usr/include/Block.h"
  link "BlocksRuntime"
  export *
}

module Cdispatch [system] {
  header "/usr/include/dispatch/dispatch.h"
  link "dispatch"
  export *
}

$ ls /usr/include/Block.h
/usr/include/Block.h

$ ls /usr/include/dispatch/dispatch.h
/usr/include/dispatch/dispatch.h

$ ls
CBlock Cdispatch mandelbrot.swift

mandelbrot.swift
   import Glibc
   import CBlock

   import Cdispatch

$ /usr/local/src/swift-2.2-SNAPSHOT-2016-01-25-a-ubuntu15.10/usr/bin/swiftc -o mandelbrot -Ounchecked -whole-module-optimization mandelbrot.swift -Xcc -F-module-map=CBlock/module.modulemap -Xcc -F-module-map=Cdispatch/module.modulemap -Xcc -fblocks -I /usr/include -I ./CBlock -I ./Cdispatch

mandelbrot.swift:23:20: error: use of undeclared type 'dispatch_io_t'
func writeLine(io: dispatch_io_t, _ data: dispatch_data_t, _ queue: dispatch_queue_t, _ last: Bool) {
^~~~~~~~~~~~~
mandelbrot.swift:23:43: error: use of undeclared type 'dispatch_data_t'
func writeLine(io: dispatch_io_t, _ data: dispatch_data_t, _ queue: dispatch_queue_t, _ last: Bool) {
^~~~~~~~~~~~~~~
mandelbrot.swift:24:5: error: use of unresolved identifier 'dispatch_io_write'
dispatch_io_write(io, 0, data, queue) {
^~~~~~~~~~~~~~~~~

etc etc

On Wednesday, January 27, 2016 9:57 PM, francisbailey <francisbailey@protonmail.com> wrote:

I recently came across this issue as well. You can use the command specified in this answer: http://stackoverflow.com/questions/34680816/swift-in-linux-use-of-unresolved-identifier-dispatch-async

Basically adding -Xcc -fblocks should get it to work.

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


(Max Howell) #5

Apparently Ubuntu 15.10’s lib dispatch doesn’t come with dispatch/io.h

So those symbols indeed don’t exist in any headers here.

I’m not familiar enough with the lib dispatch distribution to say if this is expected or not.

···

On Jan 29, 2016, at 2:33 PM, Isaac Gouy <igouy2@yahoo.com> wrote:

Looks fine to me. Can you zip it up and mail me?

Hopefully I can diagnose the problems. Platform?

Ubuntu 15.10

Linux x64 4.2.0-25-generic #30-Ubuntu SMP<swift_test.zip>


(Isaac Gouy) #6

Thank you for investigating the problem for me and finding an answer I can understand.

···

On Friday, January 29, 2016 4:18 PM, Max Howell <max.howell@apple.com> wrote:

> Apparently Ubuntu 15.10’s lib dispatch doesn’t come with dispatch/io.h

So those symbols indeed don’t exist in any headers here.

I’m not familiar enough with the lib dispatch distribution to say if this is

expected or not.


(Isaac Gouy) #7

On Friday, January 29, 2016 4:18 PM, Max Howell

Apparently Ubuntu 15.10’s lib dispatch doesn’t come with dispatch/io.h

So those symbols indeed don’t exist in any headers here.

So I fetched the source:

    https://github.com/apple/swift-corelibs-libdispatch

:and built the libraries.

It now seems like I'm missing something that isn't libdispatch related -- or should I have chosen one of those --with-apple- options when I built?

   mandelbrot.swift-2.swift:78:40: error: use of unresolved identifier 'NSUTF8StringEncoding'

See
http://benchmarksgame.alioth.debian.org/u64q/program.php?test=mandelbrot&lang=swift&id=2#log


(francisbailey) #8

I believe NSUTF8StringEncoding is part of the Foindation library which isn't fully implemented yet on Linux. You can see the status for it here:
https://github.com/apple/swift-corelibs-foundation/blob/master/Docs/Status.md

On Friday, January 29, 2016 4:18 PM, Max Howell

Apparently Ubuntu 15.10’s lib dispatch doesn’t come with dispatch/io.h

So those symbols indeed don’t exist in any headers here.

So I fetched the source:

https://github.com/apple/swift-corelibs-libdispatch

:and built the libraries.

It now seems like I'm missing something that isn't libdispatch related -- or should I have chosen one of those --with-apple- options when I built?

mandelbrot.swift-2.swift:78:40: error: use of unresolved identifier 'NSUTF8StringEncoding'

See
http://benchmarksgame.alioth.debian.org/u64q/program.php?test=mandelbrot&lang=swift&id=2#log

···

On Wed, Feb 3, 2016 at 09:44, Isaac Gouy via swift-users <'swift-users@swift.org'> wrote:
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


(Isaac Gouy) #9

Is use of libdispatch in Swift on linux, dependent on the Foundation library, or is there a way to use libdispatch without stuff like 'NSUTF8StringEncoding' ?

On Wednesday, February 3, 2016 10:03 AM, francisbailey

···

I believe NSUTF8StringEncoding is part of the Foindation library which isn't fully implemented yet on Linux. You can see the status for it here:
https://github.com/apple/swift-corelibs-foundation/blob/master/Docs/Status.md

On Wed, Feb 3, 2016 at 09:44, Isaac Gouy via swift-users <'swift-users@swift.org'> wrote:

So I fetched the source:

https://github.com/apple/swift-corelibs-libdispatch

:and built the libraries.

It now seems like I'm missing something that isn't libdispatch related -- or should I have chosen one of those --with-apple- options when I built?

mandelbrot.swift-2.swift:78:40: error: use of unresolved identifier 'NSUTF8StringEncoding'

See
http://benchmarksgame.alioth.debian.org/u64q/program.php?test=mandelbrot&lang=swift&id=2#log


(Tom Sheffler) #10

I have used libdispatch without Foundation - but that was on Ubuntu 14.04 and using the libdispatch from the distribution. (I did not compile it.)

-T

···

On Feb 3, 2016, at 10:24 AM, Isaac Gouy via swift-users <swift-users@swift.org> wrote:

Is use of libdispatch in Swift on linux, dependent on the Foundation library, or is there a way to use libdispatch without stuff like 'NSUTF8StringEncoding' ?

On Wednesday, February 3, 2016 10:03 AM, francisbailey

I believe NSUTF8StringEncoding is part of the Foindation library which isn't fully implemented yet on Linux. You can see the status for it here:
https://github.com/apple/swift-corelibs-foundation/blob/master/Docs/Status.md

On Wed, Feb 3, 2016 at 09:44, Isaac Gouy via swift-users <'swift-users@swift.org'> wrote:

So I fetched the source:

https://github.com/apple/swift-corelibs-libdispatch

:and built the libraries.

It now seems like I'm missing something that isn't libdispatch related -- or should I have chosen one of those --with-apple- options when I built?

mandelbrot.swift-2.swift:78:40: error: use of unresolved identifier 'NSUTF8StringEncoding'

See
http://benchmarksgame.alioth.debian.org/u64q/program.php?test=mandelbrot&lang=swift&id=2#log

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


(Isaac Gouy) #11

After much patient work by Ralph Ganszky I now have a working install and working command-line for libdispatch on Ubuntu:

http://benchmarksgame.alioth.debian.org/u64q/program.php?test=mandelbrot&lang=swift&id=2#log

···

On Wednesday, February 3, 2016 10:03 AM, francisbailey

I believe NSUTF8StringEncoding is part of the Foindation library which

isn't fully implemented yet on Linux. You can see the status for it here:

https://github.com/apple/swift-corelibs-foundation/blob/master/Docs/Status.md

On Wed, Feb 3, 2016 at 09:44, Isaac Gouy via swift-users > <'swift-users@swift.org'> wrote:

So I fetched the source:

https://github.com/apple/swift-corelibs-libdispatch

:and built the libraries.

It now seems like I'm missing something that isn't libdispatch

related -- or should I have chosen one of those --with-apple- options when I
built?

mandelbrot.swift-2.swift:78:40: error: use of unresolved identifier

'NSUTF8StringEncoding'