0

I have two files in one folder.

a.cc

b.cc

everyone have:

int main(int argc, char *argv[]) {
    QCoreApplication application(argc, argv);

    return 0;
}

One Cmake file with:

find_package(Qt5 COMPONENTS Core REQUIRED)
add_executable(a a.cc)
add_executable(b b.cc)

The problem is: In a.cc my #include <QCoreApplication> is fine and everything okay. I can even change it to #include <QtCore/QCoreApplication> which is more convenient. But In b.cc my IDE "says" that #include <QCoreApplication> not exists and I should change it to #include <QtCore/QCoreApplication>. During compile I get those errors:

b.cc undefined reference to `_imp___ZN16QCoreApplicationC1ERiPPci'
b.cc undefined reference to `_imp___ZN16QCoreApplicationD1Ev'
b.cc undefined reference to `_imp___ZN16QCoreApplicationD1Ev'

Project is much bigger but I can't find anything that can relative with this problem.

Addition:

I know what is "undefined reference to" and I'm not a new to this problem

  • Welcome to Stack Overflow! It looks like you are trying to add Qt to your applications, but your question title mentions adding MinGW? What does this have to do with the question? You are missing a semicolon in your `return` statement in `main`, that may cause issues. Also, you haven't linked Qt to your CMake targets `a` and `b`, so they will not know about Qt at all. Also, please be *specific* about what question you are asking. Is this about undefined references **or** include files not being found? – Kevin Mar 20 '20 at 17:34
  • Thank You. Yes I use `MinGW`. And i have `set(CMAKE_PREFIX_PATH /opt/Qt/5.13.2/x86_64-w64-mingw32/)`. And it work and I can successfully compile `a.cc` but in case when I remove `b.cc`. – Vlad Lebowski Mar 20 '20 at 17:45
  • **More details** are needed for being able to help you. See [ask]. – Tsyvarev Mar 20 '20 at 20:02

0 Answers0