I have created a Qt Widgets Application project. In mainwindow.cpp
, I want to add a C
source file (mySource.c
) from a library which includes some rules written in C
language that is not allowed to compile with C++
compiler. One of the error which is appeared is:
error: invalid conversion from ‘const char*’ to ‘gchar* {aka char*}’
When I create a Plain C Application project in Qt, I can simply compile that source. So I need C
compiler.
I also used the following code which does not solve the error:
extern "C" {
#include "mySource.c"
}
When I go to the Tools -> Options -> Kits -> Kits
, I see Desktop Qt 5.12.0 GCC 64bit and after clicking on it I can see the C and C++ compiler as follows:
- C: GCC(C,X86 64bit in /usr/bin)
- C++: GCC(C++,X86 64bit in /usr/bin)
I have searched a lot and tested different solutions but I can not solve the problem. What is the solution? Is it a specific flag that I should enable in .pro?