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.

Linker error: undefined IQmath symbols CCS3.3

Other Parts Discussed in Thread: CONTROLSUITE

I am attempting to retrofit the PID macro found in pid_grando.h of the motor control application library in controlSUITE into some existing code for the F2811. Since the macro implements IQmath, I have added IQmathLib.h, and IQmath.lib to my projects and have created the various memory mappings, include statements, etc. that are needed. Both the header and library file are in my project root and the linker search path is "$(Proj_dir)\". However when I attempt to build my project I am getting the linker error for undefined symbols pasted below. Compounding my confusion is the fact that I use other IQmath functions in my code (_IQ, _IQabs, and _IQint) and don't seem to be getting any errors on those functions. My configuration is:

  • CCS v3.3.38.2
  • DSP\BIOS v5.41.02.14
  • Code Gen Tools v5.2.10
  • IQmath lib v1.6.0

Does anyone have any thoughts as to what may be causing this problem and/or what I could do to resolve it?

 

[Linking...] "C:\Program Files\Texas Instruments\C2000 Code Generation Tools 5.2.10\bin\cl2000" -@"Release.lkf"
<Linking>
 undefined first referenced                                                                                        
  symbol       in file                                                                                            
 --------- ----------------                                                                                       
 ___IQmpy  C:\\Documents and Settings\\XPMUser\\Desktop\\G7612 local from desktop (not svn)\\_release\\wd_loops.obj
 ___IQsat  C:\\Documents and Settings\\XPMUser\\Desktop\\G7612 local from desktop (not svn)\\_release\\wd_loops.obj
error: unresolved symbols remain
error: errors encountered during linking; "./_release/G7612dspMain.out" not
   built
>> Compilation failure
  • What are the contents of the file Release.lkf? That should show all the files being passed to the linker and if they have the correct path.

    Also what does the call to IQmpy and IQsat look like in wd_loop.c? Is it similar to the other IQmath functions such as IQabs, IQinit etc?

  • Release.lkf seems to show IQmath.lib being passed to the linker, I have attached the full file in .txt form in case you care to take a look at it. _IQmpy and _IQsat are called in the same manner as the other IQmath functions except that they are part of a macro that is called in wd_loops.c as opposed to being called directly in the file as the other functions.  I don't think this should be a problem though as the macro expansion should occur before the linker runs. Just to be sure, I also tried commenting out the macro call and making the _IQmpy and _IQsat calls directly in wd_loops.c and got the same symbol errors. So you can see how the functions are called, I have pasted the comments of the macro below:

    #define PID_MACRO(v)                    \
                             \
     /* proportional term */                   \
     v.data.up = _IQmpy(v.param.Kr, v.term.Ref) - v.term.Fbk;          \
                             \
     /* integral term */                    \
     v.data.ui = _IQmpy(v.param.Ki, _IQmpy(v.data.w1, (v.term.Ref - v.term.Fbk))) + v.data.i1;  \
     v.data.i1 = v.data.ui;                   \
                             \
     /* derivative term */                    \
     v.data.d2 = _IQmpy(v.param.Kd, _IQmpy(v.term.c1, (_IQmpy(v.term.Ref, v.param.Km) - v.term.Fbk))) - v.data.d2; \
     v.data.ud = v.data.d2 + v.data.d1;                \
     v.data.d1 = _IQmpy(v.data.ud, v.term.c2);              \
                             \
     /* control output */                    \
     v.data.v1 = _IQmpy(v.param.Kp, (v.data.up + v.data.ui + v.data.ud));       \
     v.term.Out= _IQsat(v.data.v1, v.param.Umax, v.param.Umin);          \
     v.data.w1 = (v.term.Out == v.data.v1) ? _IQ(1.0) : _IQ(0.0);         \
     
    #endif // __PID_H__
  • Evan,

    It does sound odd that some functions within IQmath.lib are getting resolved properly while others are not. Could you take a look at the link map file generated (.map) and see if there are references to IQmath.lib routines and which ones they are?

    I also noticed that you are working in a directory with spaces in the path. I doubt that this would have an affect on this specific issue but it might be worth a shot to try a directory without spaces, just to be safe.

  • In the map file I do see a reference to the IQint routine, specifically IQ24int.obj which is a part of IQmath.lib. IQabs does not seem to appear in the map file but on further inspection of the IQmathLib.h file, it is resolved to labs() which would come from the std library and not IQmath. The reference in the map file is:

    IQmath     0    003e3966    00000009     
                      003e3966    00000009     IQmath.lib : IQ24int.obj (IQmath)

    I did try moving the project to C:\G7612_local\, reloading it and did a full build, it completed with the same errors

  • Just as an experiment, I tried replacing all the calls to _IQmpy in my PID macro with the _IQrmpy function. This obviously removes the _IQmpy undefined symbol error as I no longer call the function, but what is interesting is that the _IQrmpy function links correctly and I get no errors. I would try to use this as a work around but rounding each multiplicative step would cause far too much error in my PID controller.

    I can't help but notice that in the IQmath header file, the _IQmpy function only has a define that resolves the _IQmpy(A,B) symbol to the _IQmpy(A,B,GLOBAL_Q). The _IQrmpy, _IQrsmpy, etc functions have similar define statements, but also have and extern function prototype (ex. extern long _IQ24rmpy(long A, long B) ). I obviously don't have access to the source for the IQmath.lib file, but could this be part of the problem and the extern function prototypes for the _IQmpy functions were erroniously excluded from the header file? Then again, this version appears to have been released about a year ago and it seems that the _IQmpy function would be fairly frequently used and thus unlikely that I would be the first to encounter this problem

  • Evan,

    Just as a test have you tried loading the IQmath examples that are included with ControlSuite? They can be found in \controlSUITE\libs\math\IQmath\v160\examples. It looks like the example code makes calls to IQmpy so this could be a good test to see if this works. And then you could likely compare your source file with the one in the example to see if you can spot any differences that might be causing an issue.

  • At your reccomendation, I just loaded the 2812IQsampleC project and built it. I didn't get any errors from the linker, however examination of the map file shows no reference to the IQmpy or IQsat functions in the IQmath section, which I have pasted below. My project does have two configurations, Release and Debug. I only get the errors that have been troubling me when I use the release configuration, however in the debug configuration, while no errors are generated during the build step, IQmpy and IQsat both seem to be missing from the map file. Are these functions different in some way that would make them not appear in the map file when functioning properly?

    IQmath     0    003f8ddc    0000023d     
                      003f8ddc    0000008f     IQmath.lib : atoIQN.obj (IQmath)
                      003f8e6b    00000088                : IQ24atan2PU.obj (IQmath)
                      003f8ef3    00000060                : IQ24mag.obj (IQmath)
                      003f8f53    00000047                : IQ24div.obj (IQmath)
                      003f8f9a    0000003d                : IQ24exp.obj (IQmath)
                      003f8fd7    00000031                : IQ24sin.obj (IQmath)
                      003f9008    00000011                : IQ24mpyI32int.obj (IQmath)
  • Evan Leeson said:
    IQmpy and IQsat both seem to be missing from the map file. Are these functions different in some way that would make them not appear in the map file when functioning properly?

    Yes. I should have realized this before. These are intrinsics, hence they are directly replaced with the corresponding assembly statements instead of making a function call, which is why they do not appear in the link map file. Please take a look at the Compiler Users Guide, section 7.4.5 for the list of supported intrinsics.

    A related post that expands on this a little bit is here.

  • Aarti,

    After our last exchange, I went through my build options for both configurations to see what was different between the two and toggled those changes in my release configuration build options to isolate which option was causing debug to work and release not to. My release configuration had the Disable Intrinsics (-pn) option set and disabling it fixed the problem. As soon as this worked I realized that they must have been intrinsics. I am not sure why that particular option was set by the original author of this particular project, but it looks like my problem is now fixed.

    Many thanks,

    Evan