2

I am trying to call this C library from my Swift code. I dragged the source files into my project and created a module.map file and added the directory containing the module map to Build Settings->Search Paths->Import Paths.

It seems to work. I can import the library and the name even shows up in autocomplete:

import library

And I can access functions from the library and again autocomplete knows they are there:

autocomplete function

But when I build, I get this error:

error

This name, "_mtex2MML_parse", is the same as the name of C function I'm trying to call except prefixed with an underscore.

I've gotten this same error before in similar circumstances trying to get cmark to work, but fixed it there by making sure that the .c file was included in the Target Membership, and then everything was fine. When I fiddled with doing that in this project, I've not had any luck. And in that case, autocomplete didn't even know about the function.

I've tried cleaning, deleting derived data, quitting Xcode, restarting computer, etc. I've tried on Xcode 8.3.3 Swift 3.1 and on Xcode 9b4, Swift 4.0. I'm on macOS 10.12.6. There is no other thing in the project besides this.

Can anyone offer any advice on how to proceed? Thanks.

4
  • Since it is the linker that is complaining, this indicates that the library cannot be found at link time.
    – ryantxr
    Commented Aug 13, 2017 at 3:32
  • From the GitHub page, Bison and Flex are needed to build the library as configured with CMake. You can't just copy the C source files and expect the library to build properly (or at all). Commented Aug 13, 2017 at 14:59
  • Bison and Flex are included already in Xcode.
    – proxpero
    Commented Aug 14, 2017 at 15:26
  • Add pre-built library into Link Binary For Libraries under Build Phases of your target. Commented Nov 15, 2017 at 14:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.