<div dir="ltr">I got this working by generating dylib for the C source <a href="https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/CreatingDynamicLibraries.html">https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/CreatingDynamicLibraries.html</a><div><br></div><div>Steps: </div><div><br></div><div>$ cd Fixtures/ClangModules/CLibrarySources/Sources</div><div>$ swift build</div><div>$ cp ../.build/debug/CLibrarySources.build/module.modulemap . #copy the module map</div><div>$ clang -dynamiclib -std=gnu99 Foo.c -current_version 1.0 -compatibility_version 1.0 -fvisibility=hidden -o libFoo.dylib</div><div>$ swift -I include -L. -lFoo<br></div><div>1> import CLibrarySources<br></div><div>2> foo()<br></div><div>$R0: Int32 = 5<br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 26, 2016 at 1:13 AM, Daniel Dunbar via swift-build-dev <span dir="ltr"><<a href="mailto:swift-build-dev@swift.org" target="_blank">swift-build-dev@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Unfortunately, the error reporting isn't very good when LLVM tries to load a library (inside the JIT) and fails.<div><br></div><div>This is probably worth reporting as a bug. I'm not sure offhand and actually investigating this currently requires digging in to what is actually happening under the covers between the Swift importer and the LLVM JIT.</div><div><br></div><div> - Daniel</div><div><br></div><div><div><blockquote type="cite"><div><div class="h5"><div>On May 25, 2016, at 12:38 PM, bhargav gurlanka via swift-build-dev <<a href="mailto:swift-build-dev@swift.org" target="_blank">swift-build-dev@swift.org</a>> wrote:</div><br></div></div><div><div><div class="h5"><div dir="ltr"><div>Hi,</div><div><br></div><div>I have a swift package with following layout:</div><div><div><font face="monospace, monospace">.</font></div><div><font face="monospace, monospace">├── Package.swift</font></div><div><font face="monospace, monospace">├── Sources</font></div><div><font face="monospace, monospace">│ ├── BarCModule</font></div><div><font face="monospace, monospace">│ │ ├── Bar.c</font></div><div><font face="monospace, monospace">│ │ └── include</font></div><div><font face="monospace, monospace">│ │ └── Bar.h</font></div><div><font face="monospace, monospace">│ └── MyApp</font></div><div><font face="monospace, monospace">│ └── main.swift</font></div><div><font face="monospace, monospace">└── Tests</font></div></div><div><font face="monospace, monospace"><br></font></div><div><div>After running <font face="monospace, monospace">swift build</font>, I can see <font face="monospace, monospace">libBarCModule.so</font> under <font face="monospace, monospace">.build/debug</font>. How can I use this library in REPL?</div><div><br></div><div>I've tried:</div><div><br></div><div><font face="monospace, monospace">$ swift -I.build/debug -L.build/debug -lBarCModule<br></font></div><div><font face="monospace, monospace">$ LD_LIBRARY_PATH=.build/debug swift -I.build/debug -L.build/debug -lBarCModule</font><br></div><div><br></div><div>But in both cases, I couldn't call a function defined inside my C Module.</div><div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">1> import BarCModule</font></div><div><font face="monospace, monospace">2> say_hi</font></div><div><font face="monospace, monospace">error: Couldn't lookup symbols:</font></div><div><font face="monospace, monospace"> _say_hi</font></div></div><div><br></div><div><br></div><div><br></div><div><br></div><div>Regards,</div><div>Bhargav Gurlanka</div><div></div></div></div></div></div>
_______________________________________________<br>swift-build-dev mailing list<br><a href="mailto:swift-build-dev@swift.org" target="_blank">swift-build-dev@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-build-dev" target="_blank">https://lists.swift.org/mailman/listinfo/swift-build-dev</a><br></div></blockquote></div><br></div></div><br>_______________________________________________<br>
swift-build-dev mailing list<br>
<a href="mailto:swift-build-dev@swift.org">swift-build-dev@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-build-dev" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-build-dev</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Ankit<br><br></div>
</div>