Adding C++ files and compiling it in wiced 6.1

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

cross mob
sugac_3385211
Level 3
Level 3
5 likes given First like given

I want to add some c++ files in wiced 6.1. Just to check that for c++ compilation,I renamed (apps/snip/)scan.c to scan.cpp and modified scan.mk ,and I found that it fails to compile.

Please let me know the correct way to add and compile c++ files in WICED 6.1.

What I tried is below :

1. Renamed (apps/snip/)scan.c to (apps/snip/)scan.cpp

2. Updated Makefile as following :

*****************************************************************************************************************************

scan.mk

NAME := App_Scan

$(NAME)_SOURCES := scan.cpp

*****************************************************************************************************************************

3.Make Command : snip.scan-XYZ-FreeRTOS-LwIP-SDIO

Build Error

*****************************************************************************************************************************

make.exe[1]: *** No rule to make target 'apps/snip/scan/scan.c', needed by 'build/snip.scan-XYZ-FreeRTOS-LwIP-SDIO/Modules/apps/snip/scan/scan.o'.  Stop.

make.exe[1]: *** Waiting for unfinished jobs....

Building Bootloader

Finished Building Bootloader

make: *** [main_app] Error 2

Makefile:349: recipe for target 'main_app' failed

*****************************************************************************************************************************

Note : It compiles properly without above changes.i.e if compiled as c file.

0 Likes
1 Solution
Anonymous
Not applicable

Short:

Clean the project and then rebuild it.

A little bit longer:

If you create a project with a .c file and you build it, its object file is created depending on the .c file. If you rename the .c file to .cpp the dependency between the source and object file breaks and your error gets raised.

This seems to be a makefile problem since there shouldn't be a persisting dependency between source and object file after the build process.

View solution in original post

1 Reply
Anonymous
Not applicable

Short:

Clean the project and then rebuild it.

A little bit longer:

If you create a project with a .c file and you build it, its object file is created depending on the .c file. If you rename the .c file to .cpp the dependency between the source and object file breaks and your error gets raised.

This seems to be a makefile problem since there shouldn't be a persisting dependency between source and object file after the build process.