cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Contributor
Contributor
370 Views
Registered: ‎05-18-2018

Xilinx SDK Linker error C++ migration from C

Jump to solution

Hi,

I am using v2015.4 Xilinx SDK for my application development on Zynq. Initially I developed on C language. Currently I want to covert everything to C++ domain. My OS platform is Linux.

I have done the following modifications in my existing files

  • Changed all my .h headers to .hpp headers with including
#ifdef __cplusplus
extern "C" {
#endif
.....
#ifdef __cplusplus
}
#endif​
  • Renamed my .c source files to .cpp files
  • Also removed few syntax errors while migration

Now, the linker gives following error 

Invoking: ARM Linux g++ linker
arm-xilinx-linux-gnueabi-g++  -o "mycode.elf"  ./src/uartns550_v3_3/src/xuartns550.o ./src/uartns550_v3_3/src/xuartns550_format.o 
./src/GPIO_Configuration.o ......
./src/GPIO_Configuration.o:(.bss+0x0): multiple definition of `spi1'
./src/DIO_config.o:(.bss+0x0): first defined here
./src/GPIO_Configuration.o:(.bss+0x5c): multiple definition of `spi2'
./src/DIO_config.o:(.bss+0x5c): first defined here

I have not even defined spi1 in GPIO_Configuration.cpp & DIO_config.cpp files, it is in some other file. Still this variable is seen in the .o file

Can someone guide me that my procedure to convert C files to C++ files is correct. Do I need to change any Build settings or anything? It was first arm-xilinx-linux-gnueabi-gcc (in C target language) and now it is arm-xilinx-linux-gnueabi-g++ (in C++ target language)

Thanks

Tags (4)
0 Kudos
1 Solution

Accepted Solutions
Highlighted
Xilinx Employee
Xilinx Employee
302 Views
Registered: ‎10-06-2016

Hi @bhavinlapasia 

As you already noticed the linker is complaining about duplicated definitions of spi1 and spi2 variable. You have mention that you did not define those variable on GPIO_Configuration.cpp & DIO_config.cpp, so most likely you might be defining them on a header file that has been included in the source file or so.

Regards


Ibai
Don’t forget to reply, kudo, and accept as solution.

View solution in original post

0 Kudos
2 Replies
Highlighted
Xilinx Employee
Xilinx Employee
303 Views
Registered: ‎10-06-2016

Hi @bhavinlapasia 

As you already noticed the linker is complaining about duplicated definitions of spi1 and spi2 variable. You have mention that you did not define those variable on GPIO_Configuration.cpp & DIO_config.cpp, so most likely you might be defining them on a header file that has been included in the source file or so.

Regards


Ibai
Don’t forget to reply, kudo, and accept as solution.

View solution in original post

0 Kudos
Highlighted
Contributor
Contributor
291 Views
Registered: ‎05-18-2018

Hi @ibaie ,

Yes I got the problem, as you mentioned in your post, I had declared them in a header file which was being included in multiple files. I moved those variables from header file to respective source file, and if these variables were required in any other source files then I would declare them as extern in that file and use. This resolved the linker issue.

Thanks

0 Kudos