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.

CCS: Linking to GSL from CCS

Tool/software: Code Composer Studio

Hello,

I'm trying to get code to compile in CCS that uses that uses the GNU Scientific Library (using the GNU ARM compiler). It appears as though it's recognizing the library files that I've added to the compiler's lib directory and the header files that I've added to the include directory, as it doesn't flag any issues with my include statements. However, the console displays an error for each line that actually uses function defined in the library (for example, "undefined reference to 'gsl_matrix_view_array'"). The full output is below. Any help would be appreciated.

Regards,

Nathaniel

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


**** Build of configuration Debug for project MagNETTest2 ****

"C:\\ti\\ccsv6\\utils\\bin\\gmake" -k all
'Building file: ../main.c'
'Invoking: GNU Compiler'
"C:/ti/ccsv6/tools/compiler/gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-gcc.exe" -c -I"C:/ti/ccsv6/tools/compiler/gcc-arm-none-eabi-4_9-2015q3/arm-none-eabi/include" -g -gdwarf-3 -gstrict-dwarf -Wall -specs="nosys.specs" -MMD -MP -MF"main.d" -MT"main.o" -o"main.o" "../main.c"
'Finished building: ../main.c'
' '
'Building target: MagNETTest2.out'
'Invoking: GNU Linker'
"C:/ti/ccsv6/tools/compiler/gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-gcc.exe" -g -gdwarf-3 -gstrict-dwarf -Wall -specs="nosys.specs" -Wl,-Map,"MagNETTest2.map" -L"C:/ti/ccsv6/tools/compiler/gcc-arm-none-eabi-4_9-2015q3/arm-none-eabi/lib" -o"MagNETTest2.out" "./main.o" -Wl,--start-group -lgsl -lgslcblas -lblas -lm -Wl,--end-group
makefile:144: recipe for target 'MagNETTest2.out' failed
./main.o: In function `control':
C:\Users\Nathaniel\workspace_v6_2\MagNETTest2\Debug/../main.c:20: undefined reference to `gsl_matrix_view_array'
C:\Users\Nathaniel\workspace_v6_2\MagNETTest2\Debug/../main.c:21: undefined reference to `gsl_matrix_view_array'
C:\Users\Nathaniel\workspace_v6_2\MagNETTest2\Debug/../main.c:22: undefined reference to `gsl_matrix_view_array'
C:\Users\Nathaniel\workspace_v6_2\MagNETTest2\Debug/../main.c:23: undefined reference to `gsl_matrix_view_array'
C:\Users\Nathaniel\workspace_v6_2\MagNETTest2\Debug/../main.c:24: undefined reference to `gsl_matrix_view_array'
./main.o:C:\Users\Nathaniel\workspace_v6_2\MagNETTest2\Debug/../main.c:25: more undefined references to `gsl_matrix_view_array' follow
./main.o: In function `control':
C:\Users\Nathaniel\workspace_v6_2\MagNETTest2\Debug/../main.c:28: undefined reference to `gsl_matrix_memcpy'
C:\Users\Nathaniel\workspace_v6_2\MagNETTest2\Debug/../main.c:30: undefined reference to `gsl_blas_dgemm'
C:\Users\Nathaniel\workspace_v6_2\MagNETTest2\Debug/../main.c:35: undefined reference to `gsl_blas_dgemm'
C:\Users\Nathaniel\workspace_v6_2\MagNETTest2\Debug/../main.c:38: undefined reference to `gsl_matrix_scale'
C:\Users\Nathaniel\workspace_v6_2\MagNETTest2\Debug/../main.c:39: undefined reference to `gsl_matrix_add'
C:\Users\Nathaniel\workspace_v6_2\MagNETTest2\Debug/../main.c:40: undefined reference to `gsl_matrix_memcpy'
./main.o: In function `findPos':
C:\Users\Nathaniel\workspace_v6_2\MagNETTest2\Debug/../main.c:53: undefined reference to `gsl_poly_solve_quadratic'
collect2.exe: error: ld returned 1 exit status
gmake: *** [MagNETTest2.out] Error 1
gmake: Target 'all' not remade because of errors.

**** Build Finished ****

  • Hi,

    These are linker errors. It seems one or more libraries or library paths are missing from your linker options.

    Please double-check if the libraries exist and if no paths are missing. Also, make sure the libraries can be used with nosys.specs or if they require rdimon or nano (I have seen this in the past).

    Hope this helps,
    Rafael
  • Hey,

    So I've tried changing the specs parameter to both rdimon.specs and nano.specs, and neither seem to help. As for the libraries, I definitely have library files in the compiler's lib directory for each of the ones that I'm linking (libgsl.a, libgsl.dll.a, libgslcblas.a, libgslcblas.dll.a, etc). I also can confirm that CCS isn't having a problem with linking these library files, as I have been able to get a hello world program to build with all of the specified libraries linked but not used (the problem is when I try to build code that actually leverages functions that should be accessible from the libraries). Is there an easy way to figure out if there are further dependencies beyond what I'm linking to right now (or if maybe there's something wrong with the library files themselves)?

    Thanks,
    Nathaniel
  • Nathaniel,

    >> Is there an easy way to figure out if there are further dependencies beyond what I'm linking to right now (or if maybe there's something wrong with the library files themselves)?

    You can use objdump -t from a command line to find out what symbols are defined by the libraries you are using. For the built-in compiler you should issue something similar to:
    arm-none-eabi-objdump.exe -t libgsl.a > libgsldump.txt

    Reference:
    www.thegeekstuff.com/.../

    If you can find the missing function in the library, then I wonder if there is a problem with the linking order of libraries - gsl should come after gslcblas, etc. Usually this is not necessary, as CCS wraps these libraries with --start-group and --end-group, but you can experiment with it via the linker options in CCS.

    Reference:
    stackoverflow.com/.../why-does-the-order-in-which-libraries-are-linked-sometimes-cause-errors-in-gcc

    Apart from this I don't have much more ideas other than suspecting the library itself is at fault.

    Hope this helps,
    Rafael
  • Hello,

    When I run objdump, I get a series of errors about the format of each of the .o files in the archive (for example, "version.o: File format not recognized"). So there's obviously some problem with using my library files with the GNU ARM compiler. These are library files that I have previously used to build code in Cygwin. I definitely lack experience in this area, but would it make sense that they wouldn't be compatible for use with CCS? If so, do you have any insight as to how I might obtain library files that would be compatible?

    Thanks,
    Nathaniel
  • James Foote said:
    When I run objdump, I get a series of errors about the format of each of the .o files in the archive (for example, "version.o: File format not recognized"). So there's obviously some problem with using my library files with the GNU ARM compiler. These are library files that I have previously used to build code in Cygwin.

    How where the library files built, i.e. which compiler was used?

    My guess is that the object files for which "File format not recognized" were built for x86 COFF format, rather than ARM ELF format.

  • Yeah, I'm pretty sure they're in x86 format. Is there an easy way to convert them to ARM ELF, or do I need to find them somewhere that provides them in the proper format?
  • James Foote said:
    I'm pretty sure they're in x86 format. Is there an easy way to convert them to ARM ELF, or do I need to find them somewhere that provides them in the proper format?

    There isn't a way to convert from x86 format to ARM ELF object files, as they target different processor architectures.

    You need to either find pre-compiled libraries in the proper format, or compile the GSL library from source using the gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-gcc.exe ARM cross-compiler.

    [I haven't researched this myself]