Menu

"Undefined symbols for architecture x86_64" Linking error in Xcode C++ Project

2022-11-27
2022-12-06
  • Robert McInnes

    Robert McInnes - 2022-11-27

    What an amazing package SimpleXlsxEWriter is: Great work, you guys...
    My first pass at a project: adding the ablity to create and pass Trend Data to an Excel Workbook.
    I had previously reached the point where I am able to create the data as a text file, open with Excel, and add a line chart.
    Next I searched for a way to write directly to Excel, and SimpleXlsxEWriter is a perfect fit...

    My project in Apple Xcode C++ compiles OK, no errors, but fails to link, please refer to the attached log.

    Any ideas, please, am at a loss to know how to get this sorted right now.
    Thanks, in anticipation.
    Robert.
    iMac iMac (Retina 5K, 27-inch, Late 2014) 3.5 GHz Quad-Core Intel Core i5
    Xcode 13.2.1 (13C100)
    macOS Big Sur 11.7.2 (20G1011)

     

    Last edit: Robert McInnes 2022-11-27
  • Alexandr Belyak

    Alexandr Belyak - 2022-11-27

    Hi,
    Thanks for your kind words and detailed explanation.
    It looks like the linker doesn't see the library's object files. Can you see the object files "Worksheet.o" or "Workbook.o"? Are they in the same directory as "main.o" ?
    Maybe they are in different directories and you need to specify them explicitly to the linker.

     
  • Robert McInnes

    Robert McInnes - 2022-11-27

    I created a new Xcode C++ Project of the Scientific.cpp, and see exactly the same errors.
    Am not familiar with Xcode, but could not find any object files in the" build" folder, except for "Objects-normal,x86+64,PathManager.o and Scientific.o"

     
  • Alexandr Belyak

    Alexandr Belyak - 2022-11-27

    It looks like the cpp files from the directories "scratch", "Xlsx", "XLSXColors" and "Zip" are not compiled. Have all cpp files been added to the Xcode C++ Project?

     
  • Robert McInnes

    Robert McInnes - 2022-11-27

    Yes, I can confirm that all the files have been added to the Project. I have left them in their appropriate folders, since the example Scientific.cpp is expecting to find them in the folders. I assume, reviewing the headers that this is the correct way, and Xcode C++ compiler does understand #include "../PathManager.hpp" and "XLSXColors/XLSXColorLib.h"
    I did not include "scratch", since I do not need matrix access.
    Nor Zip, but adding Zip made no differnce; still the same 14 errors.

     

    Last edit: Robert McInnes 2022-11-27
  • Robert McInnes

    Robert McInnes - 2022-11-27

    Here are the 14 error I am seeing...

     
  • Robert McInnes

    Robert McInnes - 2022-11-28

    Ah, I removed all refernces to the .h and .cpp files from the project, and the associated folders.
    Then added all the files back at the root of the project, and bingo.
    No complier errors, and Scientific.cpp ran to completion.
    Am still looking for the Excel WorkBook!

    Have some Buildtime issues, but no Runtime errors...
    (23) Semantic issues in zip.cpp "Possible miss use of comma"
    (10) Conversion issues, also in zip.cpp "long to unsigned int"
    (50) Documentation issues, the likes of which I have seen before, in other projects, harmless.
    (01) Depreciation, 'syscall' in macOS since versio 10.12.

    Thanks for your help.
    I will get back to you when I have found the "successfully saved workbook"?

     
  • Robert McInnes

    Robert McInnes - 2022-11-28

    Oh, and I forgot to mention it earlier: am working with Microsoft Excel for Mac (Version 16.61.1).

    I found the "successfully saved workbook" Workbook.
    It was buried in the Project Build folder... And it looks perfect....
    /Users/rmcinnes/Library/Developer/Xcode/DerivedData/SimpleXlsx_Example-gaogkxwwiinxwhakgyuxjlafejny/Build/Products/Debug/Scientific SimpleXlsx Test.xlsx
    Changed the path name an now it pops up in my project folder, just fine.

    Again, thank for your help; if you wish to follow up to tidy up the remaining Buildtime Sematic and Conversion issues, please let me know, am keen to help, if you have the need.

    Robert.

     
  • Alexandr Belyak

    Alexandr Belyak - 2022-12-01

    Hi,
    Thanks again for the detailed information. If it doesn't bother you, attach the compiler output here after building the project. Maybe I can eliminate some compiler warnings.
    If you are very concerned about compiler messages, then you can compile the library separately using CMAKE and use resulting object file to your project. It will also speed up the build of your project.
    I also want to note that Microsoft Excel is not required to use this library.

     
    • Robert McInnes

      Robert McInnes - 2022-12-01

      Hi Alexander,
      Ooops, I should have been clearer in my earlier post.
      The projects in Xcode C++ are now compiling and running properly.
      Thanks for you help.
      You were right, the Compiler was not finding UTF8Encoder.hpp, PathManager.hpp, etc that are not in the subfolders of the SimpleXlsx package. When I rebuilt the Project with all the SimpleXlsx functions at the same level, the Compiler and Object Linker were happy.

      As I said, i do see the warnings, Documentation, Sematics etc that does not effect runtime.

       
  • Robert McInnes

    Robert McInnes - 2022-12-02

    OK, I have now managed to get the Xcode C++ Project sorted:
    Within Xcode, I have created Groups (without Folder) which has enabled me to tidy up (and protect) the SimpleXlsx project files which the compiler clearly does understand.
    Previously, I had added the SimpleXlsx Folders to the Project, and it would appear the compiler was unable to properly interpret the #include "../UTF8Encoder.hpp" code. There probably is a way to rewrite the #include... in Xcode C++ to look into Folders (but I am not yet aware of it).
    The Group without Folder works fine, so am happy to get on with my Xcode Porject using SimpleXlsx...

     
    • Alexandr Belyak

      Alexandr Belyak - 2022-12-04

      Hi Robert,
      Perhaps there is some feature of working with Xcode and nested directories. Maybe a similar problem is described here (see the most popular answer)?
      https://stackoverflow.com/questions/21958759/subfolders-in-xcode-linking

      #include "../UTF8Encoder.hpp" should work correctly. At least I tested it under Linux and Windows with the GCC compiler.

       
      • Robert McInnes

        Robert McInnes - 2022-12-06

        Alexandr,
        Am beginning to get comfortable with Xcode C++ Projects, so thank you for your support and for being patient.
        I did discover the ability to Create a Group of Files, which the compiler is happy to work with, which does tidy up the structure within the Project Navigator.
        That is the same as the solution you referred me to in you previous post, thank you.
        A Group of Files is grey, a Folder is blue...
        So I am happy to go along with this for now, SimpleXlsx is working as it should.
        Xcode does provide the ability to define the Search Paths for Headers and Libaries,
        To quote form Xcode Help: Header Search Paths...
        "This is a list of paths to folders to be searched by the compiler for included or imported header files when compiling C, Objective-C, C++, or Objective-C++. Paths are delimited by whitespace, so any paths with spaces in them need to be properly quoted.

         

Log in to post a comment.

MongoDB Logo MongoDB