Qt error: LNK1181: cannot open input file 'debug \ main.obj'

Qt creator worked well, but unexpectedly error: LNK1181: cannot open input file 'debug\main.obj' .
This problem always manifests itself with any type of application, with a GUI or console .
I uninstalled Qt and installed again, but the problem still exists.
I did not do anything in the settings of the creator of Qt, left the default settings.

The following application is a simple console application that has the same problem in it.

 //main.cpp #include <QCoreApplication> int main(int argc, char *argv[]){ QCoreApplication a(argc, argv); return a.exec(); } 

Note : I am using Qt 5.1.1 for 32-bit Windows (VS 2010, OpenGL).

+6
source share
7 answers

The problem is resolved.

The problem was that when creating a new project ( GUI or Console ) all the source files belonging to this new project accept the wrong ex: main.cp , but it is assumed that the correct extension will be ex: main.cpp . And when changing all the extensions of the source files from .cp to .cpp worked fine.

Or change the default source file extension from [Tools → Option → C ++] .
enter image description here

+1
source

This problem also occurs if the path of your project (the name of any folder) contains a space.

+5
source

Well, finally, we have a real answer for this generalized problem, and not an OPO problem if it does not unlock you.

Actual problem (black box perspective): Auto-completion of the Build directory entry is interrupted for projects inside scrollable directories. Qt Creator actually forbids you and tells you not to use spaces when creating new projects. You can close the new project and rename it to add a space, and Qt Creator will handle it gracefully. If you copy the assembly directory, even with a space in it, and paste it into the field, replacing the broken automatically generated path (mine used relative paths), then the JOM will start working correctly, since QMake does not cause any errors. I can not speak for other Make tools.

  • Make or clone your project with spaces
  • Download it in Qt Creator
  • Launch QMAKE
  • Select the "Project" button on the left.
  • Make sure you are on the Create tab
  • Select Browse, and then re-select the shadow directory QMAKE made

This should unlock you if it was not an easy problem to delete old created QMAKE folders , which is the most common problem that people face with this particular error when developing inside Qt Creator.

+2
source

hmm If I remember correctly when I encountered such problems, using your similar setup (QtCreator and Windows) running QMAKE, and restoring the project again helped me solve this linker error.

0
source

Run Clean and qMake and rebuild .
I have such a problem and it helped me.

0
source

I got an error because of this:

 HEADERS += \ \ $$PWD/QOakTreeViewRecursiveModel.h 

instead:

 HEADERS += \ $$PWD/QOakTreeViewRecursiveModel.h 
0
source

This problem also occurs if there is something like in the .pro or .pri files:

HEADERS + = \\

or

SOURCES + = \\

0
source

Source: https://habr.com/ru/post/1500417/


All Articles