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

Suipengfei suipengfei at huawei.com
Fri Jan 29 01:03:11 CST 2016

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)


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 ~

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

More information about the swift-users mailing list