0

I have a very specific case of Linker error :

'Invoking: GCC C++ Linker 4 [arm-linux-gnueabihf]' arm-linux-gnueabihf-g++ -lpthread ./src/FPGA_Peripherals/AUX_IMU/AUX_IMU_functions.o
./src/main.o: In function main': ../src/main.cpp:7: undefined reference to `function()'

the error output is truncated for purpose of this post. The error and the object, where the function definitions lies, is highlighted.

The code is compiled and linked using DS-5 C/C++ Eclipse Platform, with the GCC 4.x [arm-linux-gnueabihd] (DS-5 built-in) tool-chain :

  • GCC C++ Compiler 4 [arm-linux-gnueabihf]
  • GCC C Compiler 4 [arm-linux-gnueabihf]
  • GCC Assembler 4 [arm-linux-gnueabihf]
  • GCC C Linker 4 [arm-linux-gnueabihf]
  • GCC C++ Linker 4 [arm-linux-gnueabihf]
  • GCC Archiver 4 [arm-linux-gnueabihf]

With Gnu Make Builder.


Source code is structured in folders :

  • src

    main.cpp

    • FPGA_peripherals

      • AUX_IMU

      header.h

      AUX_IMU_functions.c


Minimalistic code producing the error :

main.cpp

#include "header.h"

int main() {
    function();
    return 0;
}

header.h

void function(void);

AUX_IMU_functions.c

#include "header.h" 

void function(void){
    int i = 3;
};

The code has to be a mix of C and C++ code. The C code is correctly compiled using GCC C Compiler 4 [arm-linux-gnueabihf]. The C++ code (other files, not included within this example), are correctly compiled using GCC C++ Linker 4 [arm-linux-gnueabihf].


This is apparently not a Linker related problem, what else to check, if Linker still produces this error ?

  • @dasblinkenlight I have investigated, and the error doesnt seem to be related to the Linker, even though the Linker error still persists. Any ideas ? – new_stacker Jan 13 '18 at 09:20
  • This is not commonly a linker problem, it's usually a build problem (e.g. missing `.o` in the list of files that you pass to linker). – Sergey Kalinichenko Jan 13 '18 at 09:22
  • @dasblinkenlight Agree, I am using DS-5 IDE based on eclipse. As you may see, the object AUX_IMU_functions.o is created. What other way I can influence the linking process from eclipse based IDE ? – new_stacker Jan 13 '18 at 09:25
  • @dasblinkenlight If this is not a common linker error, would you mind to re-open the question ? – new_stacker Jan 13 '18 at 09:30
  • I voted to re-open the question (since you removed [c] tag I cannot reopen it by myself any longer; it would take four more votes). Please edit the question with the explanation that you are using DS-5, and the basic structure of the project. – Sergey Kalinichenko Jan 13 '18 at 09:30
  • @dasblinkenlight I appologize for removing "c" tag, I have found out that is should not be related to c/c++ directly (#ifdef, etc), I have edited the question and also added the "c", in case it chenges anything. – new_stacker Jan 13 '18 at 09:50

0 Answers0