[swift-users] hi every one ,who can help me? 3Q ~

Ankit Agarwal ankit at ankit.im
Fri Jan 29 01:33:11 CST 2016


You'll need to create a module map to import C modules. In practise it'll
be easier to use swiftpm for such things. I had written a tutorial for this
:

http://ankit.im/swift/2015/12/27/ship-c-code-with-swift-packages-using-swift-package-manager/

On Friday 29 January 2016, Suipengfei via swift-users <swift-users at swift.org>
wrote:

> Hi all, I want to make a simple emample to show swift can call c library.
>
>
>
> So ,I make a simple example,like this:
>
>
>
> $ cat a.c
>
> int add(int a,int b){
>
>         return a + b;
>
> }
>
>
>
> And I make a lib,
>
> $  gcc -o a.o -c a.c
>
> $  ar rcs libmylib.a a.o
>
>
>
> And I put libmylib.a in the same director with the main.swift
>
>
>
> $ cat main.swift
>
> import mylib
>
> var b = add(10,20)
>
> print(b)
>
>
>
> when I compile :
>
> $ swiftc  main.swift
>
> main.swift:1:8: error: no such module 'mylib'
>
> import mylib
>
>        ^
>
>
>
>
>
> I am just confused with this. Can you explain that with you pressure time.
> And what should I do?  Thank you a lot ~
>
>
>
>
>


-- 
Ankit
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160129/51a674e5/attachment.html>


More information about the swift-users mailing list