Reimond Hill
Reimond Hill

Reputation: 4760

Undefined symbols for architecture arm64 with .a Library Xcode in Swift Project

I have an Static C Library ohNetCoreFatEntotem.a and I have imported it into an existing projects originally written in ObjctiveC. Now the project is almost Swift.

When I try to build the project I get the following error:

enter image description here

The Library is a fat Library compiled for arm64, armv7 and x86

What does this error mean?

Thank you

EDITED I might not have enough deep knowledge about compilers and libraries... Sorry for that.

I have build a library from https://github.com/openhome/ohNet and I generated the compressed file like the one you can find Here.

The structure is:

enter image description here

I created a Fat library with all the fileLib.a from different structures that also can be found Here.

I have a created a folder with the fat libraries and the headers. enter image description here

How do I Declare them in xcode?

Upvotes: 1

Views: 2885

Answers (3)

Reimond Hill
Reimond Hill

Reputation: 4760

I think I have figured out the issue. Note: This solution is for importing a .a Fat, or not Library into a swift project.

From the the last folder structure defined in the question:

  1. Follow the following link:Here
  2. Create a C++ file in xcode and make sure the "Create Header" is Selected
  3. Create Bridging Header and import the .hpp header
  4. In the .hpp file the import the Headers.

As shown in the last picture from the question, The root folder where the .a are defined also have an include folder. The headers declared in the .hpp are these headers. Depending How you solved point 1, the path might vary.

I hope It can be helpful.

Upvotes: 0

Goswin von Brederlow
Goswin von Brederlow

Reputation: 12322

Symbols starting with __cxa_ are part of the c++ runtime.

For example libcxxabi.llvm.org/spec.html says about __cxa_guard_abort: "This function is called if the initialization terminates by throwing an exception."

The c++ runtime is automatically linked into your program IF you link it using the c++ compiler. On the other hand if you link the object files using ld directly, cc, obj-c or other languages compilers then the necessary C++ runtime libraries are not added to the linker call.

If you link object files from multiple languages then care must be taken to include all the necessary language runtime supports and that can get complicated. Otherwise always use the compiler used to compile the object files to later link them.

Upvotes: 2

ryyker
ryyker

Reputation: 23208

From HERE, two of the main topics (likely related to what you are seeing) are shown below in summarized form. Go to the linked page for many more details on the topic. (Embarcadero is Borland specific, but much of the information in this tutorial is generally applicable)

UNDEFINED SYMBOL AT COMPILE TIME
An undefined symbol at compile time indicates that the named identifier was used in the named source file, but had no definition in the source file. This is usually caused by a misspelled identifier name, or missing declaration of the identifier used. (examples follow)

Or

UNDEFINED SYMBOL AT LINK TIME
When linking multi-file projects, the linker must resolve all references to functions and global variables shared between modules. When these references cannot be resolved, the linker generates an "undefined symbol" error message. This means that after searching all of the object files and libraries which are included in the link, the linker was unable to find a declaration for the identifier you were using. This can be caused by... (read more...)

Upvotes: 2

Related Questions