Xcode duplicate symbol error

后端 未结 5 438
轻奢々
轻奢々 2020-12-21 08:30

I am getting \"Apple Mach-O Linker (Id) Error\":

ld: duplicate symbol _matrixIdentity in /BlahBlah/Corridor.o and /Blahblah/Drawable.o for architecture i386
         


        
5条回答
  •  借酒劲吻你
    2020-12-21 09:22

    From your description, utils.h declares and implements a variable, the implementation of which is compiled in corridor.h and Drawable.h by virtue of utils.h being included in both (indirectly through Drawable.h in the case of Corridor.h). Thus both compilation units contain an implementation for _matrixIdentity, and the linker complains.

    Move the implementation of _matrixIdentity into a new module utils.m to ensure there is only one definition of the symbol.

提交回复
热议问题