This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Undefined symbol refererenced by a lib file

Other Parts Discussed in Thread: MSP430F5438A

Hi all,

Thank you for reading and hopefully answering this question

I have read the other posts that have already been answered but they don't solve my problem (either that or I'm not doing it right)

Using CCs v5.2, MSP430F5438A chip

My file structure is as such (important to question only, rest is not shown)

I get the error from the linker when I compile:

undefined              first referenced

symbol                      in file

---------                            ----------------

inv_cosf                         <Project Directory>\core\mpl\libmplmpu.lib<fusion_9axis.obj>

inv_sinf                         <Project Directory>\core\mpl\libmplmpu.lib<fusion_9axis.obj>

The files shown in the structure above along with the .lib file are taken from an external party, and thus should be correct

I have included my lib file in the Project Settings>CCS Build>MSP430 Linker>File Search Path, both the <Include Library or Command File as input> section and the <Add dir to library search path> section as:

"${workspace_loc:/${ProjName}/core/mpl/libmplmpu.lib}"

and

"${workspace_loc:/${ProjName}/core/mpl/}"

respectively

 

inv_cosf inv_sinf  are seemingly declared in the file in the ml_math_func.h and ml_math_func.c in the <mllite> folder

The two files are #include-d in my main program, but I don't think that is going to help much

 

What am I doing wrong?

  • The linker is reporting that it is unable to find "definitions" for those symbols - inv_cosf and inv_sinf. You need to be sure to include whichever file contains the definition for those symbols. If it is a C source file, then the source file should be added to the project, or if it is a library, then the library should be specified using the --library option in the Linker File Search Path option (as you have already done).

    http://processors.wiki.ti.com/index.php/Build_Errors_in_CCS#Error:_unresolved_symbols_remain

  • Thanks for your reply, I was hoping for more responses before I replied.

    I understand needing to add the H or C files and the library for unresolved definitions, but right now it seems like it's my Lib file that is asking for 2 functions that are already included into my project and workspace.

    Removing the Lib file from the build removes the error (and I of course get some "Function declared implicitly" error for the function I wanted to use in the library)

    Am I reading my error wrong? The location of the undefined symbol is listed as

    "<Project location>\core\mpl\libmplmpu.lib<fusion_9axis.obj> "

    libmplmpu.lib is the library I just added

    fusion_9axis.h is the H file that came with the library. No C file is given. I am assuming the OBJ file should be the H file getting compiled into the build?

     

    I have #included the fusion_9axis.h file into my main program files.

    I have added the Library file libmplmpu.lib into the Project Properties> File Search path> Include Library or command file as input

    I have added the folders for the lib and the H files to the Project Properties> File Search path> Add dir to library search path

     

    It almost seems to me that the Library is asking for the file with the inv_cosf and inv_sinf function. Am I to modify the given H file to start coding in the said functions or adding a #include to a file that has those functions?

    I'm confused since I'm not used to a Lib file declaring it is missing function definitions. Me forgetting to include H files in my own project, yes, but a Lib file I just included?

     

  • Jeffrey Jway said:

    The location of the undefined symbol is listed as

    "<Project location>\core\mpl\libmplmpu.lib<fusion_9axis.obj> "

    libmplmpu.lib is the library I just added

    fusion_9axis.h is the H file that came with the library. No C file is given. I am assuming the OBJ file should be the H file getting compiled into the build?

    The .obj is a C or C++ source file compiled into a object file. The .h files are header files that are included in source files but not compiled themselves. The .lib is usually an archive of several object files.

    Jeffrey Jway said:
    It almost seems to me that the Library is asking for the file with the inv_cosf and inv_sinf function.

    Yes, the error message indicates that the obj file fusion_9axis.obj in the library is referencing the inv_cosf and inv_sinf symbols but is not finding a definition for them. Since I am not familiar with the library or other components of this project, I cannot comment on where these symbols should be or are expected to be defined. One more bit of analysis you could do is to use the Name utility (that is part of the compiler toolset) to look at the symbols within a library. That will tell you whether those symbols are defined anywhere in the library or not. The name utility can be run from a command prompt and is described in Chapter 11 of the MSP430 Assembly Language Tools Users Guide.

  • Thank you for your response, I appreciate it.


    The  inv_cosf and inv_sinf functions are declared in another file, ml_math_func.h, and I have both the C and H files but I do not know where I should #include them. Also a point of note is that I *do not* even use these two functions anywhere in my project. they only appear in the ml_math_func.c file where it is defined and the ml_math_func.h where it is declared. No other referrence.

    I have already included them in the project, the path to the files is included in the <Project Properties>MSP430 Linker> File Search Path> Add dir to library search path> section and also (currently) have added the #include of the H file to my Main.c file as I do not know where to add a #include for a file that the library seems to be asking for.

    Do I need to perform some step that I missed? Please educate me, for I am lost.

  • Jeffrey Jway said:
    Also a point of note is that I *do not* even use these two functions anywhere in my project. they only appear in the ml_math_func.c file where it is defined and the ml_math_func.h where it is declared. No other referrence.

    Is it possible that the library itself is referencing them but the definition is not found in the library?

    Would you be able to share the following with us - it might help better understand what is happening here. 
    - save a copy of the CCS build log and attach it here (http://processors.wiki.ti.com/index.php/Build_Errors_in_CCS#General_Tips)
    - attach the library file libmplmpu.lib