Compiling with C++ code

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi,

   

I'm trying to add C++ files to the sample projects and am getting a linker error when compiling.  In "Tool Settings" there is:

   

"ARM Sourcery Windows GCC C++ Compiler" (additional Compiler setting)

   

"ARM Sourcery Windows GCC C++ Linker" (replaces "ARM Sourcery Windows GCC C Linker)

   

I've tried to copy all the linker settings from the sample C projects, but must still be missing something.

   

Here is the error:

   

'Building target: AFProfileSensor.elf'
'Invoking: ARM Sourcery Windows GCC C++ Linker'
arm-none-eabi-gcc -T"C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\/firmware/common/fx3.ld" -nostartfiles -Xlinker --gc-sections -Wl,-Map,AFProfileSensor.map -Wl,-d -Wl,--no-wchar-size-warning -Wl,--entry,CyU3PFirmwareEntry "C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\/firmware/u3p_firmware/lib/fx3_release/cyu3lpp.a" "C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\/firmware/u3p_firmware/lib/fx3_release/cyfxapi.a" "C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\/firmware/u3p_firmware/lib/fx3_release/cyu3threadx.a" "C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\/arm-none-eabi/lib/libc.a" "C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\/lib/gcc/arm-none-eabi/4.5.2/libgcc.a" -mcpu=arm926ej-s -mthumb-interwork -o "AFProfileSensor.elf"  ./af_analyze.o ./cyfx_gcc_startup.o ./cyfxtx.o ./cyfxusbenumdscr.o ./cyfxusbspiregmode.o   
./cyfxusbspiregmode.o: In function `main':
cyfxusbspiregmode.c:(.text.main+0xa8): undefined reference to `CyU3PDeviceConfigureIOMatrix'
cyfxusbspiregmode.c:(.text.main+0xb4): undefined reference to `_tx_initialize_kernel_enter'
collect2: ld returned 1 exit status
cs-make: *** [AFProfileSensor.elf] Error 1

   

**** Build Finished ****

   

Here is the original good build with only C files:

   

'Building target: UsbSpiRegMode.elf'
'Invoking: ARM Sourcery Windows GCC C Linker'
arm-none-eabi-gcc  ./cyfx_gcc_startup.o ./cyfxtx.o ./cyfxusbenumdscr.o ./cyfxusbspiregmode.o    -T"C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\/firmware/common/fx3.ld" -nostartfiles -Xlinker --gc-sections -Wl,-Map,UsbSpiRegMode.map -Wl,-d -Wl,--no-wchar-size-warning -Wl,--entry,CyU3PFirmwareEntry "C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\/firmware/u3p_firmware/lib/fx3_release/cyu3lpp.a" "C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\/firmware/u3p_firmware/lib/fx3_release/cyfxapi.a" "C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\/firmware/u3p_firmware/lib/fx3_release/cyu3threadx.a" "C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\/arm-none-eabi/lib/libc.a" "C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\/lib/gcc/arm-none-eabi/4.5.2/libgcc.a" -mcpu=arm926ej-s -mthumb-interwork -o "UsbSpiRegMode.elf"
'Finished building target: UsbSpiRegMode.elf'
' '
cs-make --no-print-directory post-build
'Generate boot-loadable binary image'
'C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\/util/elf2img/elf2img.exe' -i UsbSpiRegMode.elf -o UsbSpiRegMode.img
Note: 256 bytes of interrupt vector code have been removed from the image.
      Use the "-vectorload yes" option to retain this code.

   

' '
'Invoking: ARM Sourcery Windows GNU Print Size'
arm-none-eabi-size  --format=berkeley UsbSpiRegMode.elf
   text       data        bss        dec        hex    filename
  82536        660      11588      94784      17240    UsbSpiRegMode.elf
'Finished building: UsbSpiRegMode.siz'
' '

   

**** Build Finished ****

   

 

   

Which .a file contains CyU3PDeviceConfigureIOMatrix?

   

Thanks for any help.

0 Likes
4 Replies
Anonymous
Not applicable

Hi,

   

 

   

The CyU3pDeviceConfigureIOMatrix API is present in the  libcyfxapi.a library. In the build with error it is not linking this library. In the other instance, it is linking.

   

 

   

Regards

   

Dhritiman

0 Likes
Anonymous
Not applicable

Hi Dhritiman,

   

Both builds are linking to cyfxapi.a here -- "C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\/firmware/u3p_firmware/lib/fx3_release/cyfxapi.a".  Am I missing something else?

   

Is `_tx_initialize_kernel_enter' also in cyfxapi.a?

   

I also tried running the fx3cpp.ld script instead of the fx3.ld script under ARM Sourcery Windows GCC C++ Linker-> General->Script file (-T) but see the same linker errors.

   

Thanks.

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hi Dhritiman,

   

Attached is the entire output from the problem build.

   

Thanks for your help.

0 Likes
Anonymous
Not applicable

I copied the BulkLpAutoCpp sample and replaced the source files with mine and was able to compile.

   

Thanks for your help!

0 Likes