This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Linking errors while mixing C and C++ source files in Keil uV5

Hello.

I'm getting linking errors while mixing C and C++ source files in my Keil uVision Project.
First the overview of the tools and configuration that i'm using.

IDE-Version:
µVision V5.25.2.0
Copyright (C) 2018 ARM Ltd and ARM Germany GmbH. All rights reserved.

Tool Version Numbers:
Toolchain: MDK-Lite Version: 5.25.2.0
Toolchain Path: I:\Keil\ARM\ARMCC\Bin
C Compiler: Armcc.exe V5.06 update 6 (build 750)
Assembler: Armasm.exe V5.06 update 6 (build 750)
Linker/Locator: ArmLink.exe V5.06 update 6 (build 750)
Library Manager: ArmAr.exe V5.06 update 6 (build 750)
Hex Converter: FromElf.exe V5.06 update 6 (build 750)
CPU DLL: SARMCM3.DLL V5.25.2.0
Dialog DLL: DARMCM1.DLL V1.19.1.0
Target DLL: UL2CM3.DLL V1.160.12.0
Dialog DLL: TARMCM1.DLL V1.14.0.0

I'm using the standard peripheral libraries provided below.
www.st.com/.../stsw-stm32048.html

In that I'm using the template project provided.
The template project creates a C source project for Stm32f030c8 controller (in my case).

I need to use a library which is in C++.
Things that i did.
Deleted the main.c from the project and created main.cpp as i need to use the library function in main. So made main as Cpp source file.

Added --cpp11 flag in the arguments of Misc control.

Unchecked use Microlib as it was giving a warning.
The include paths for the Source and Header files are properly given for C++ library that i need to use.

Now the execution part.
main.h contains 2 header includes suppose A.h and B.h.
The fucntions which are declared in these header files are all C functions.
A.c and B.c both includes main.h which has A.h and B.h.
Now the library is C.cpp with C.h.
I want to use the fucntions in A.c and B.c in C.cpp.

So at the top of C.cpp i did this --> extern "C"{main.h}
#include "C.h"

Now in C.cpp when i call a fucntion which is defined in A.c for eg. void foo (void) ; code compiles without any warnings/ errors but the linker gives the particular errors.
.\Objects\Project.axf: Error: L6218E: Undefined symbol foo (referred from C.o).
Not enough information to list image symbols.
Not enough information to list load addresses in the image map.

My question is
1. Is this linking error related to the way in which i'm including the files
2. Are my configurations of Keil proper to run a Project with both C and C++ source files?

Please help me understand the mistakes that i'm making as this if my first time mixing C and C++ files in Keil.

Regards,
Nishit.