Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Error while building project on windows 64 bit
i am new in QT while running existing project getting error
collect2.exe: error: ld returned 1 exit status
i searched a lot but unable to fix this.
quick response would help much more.
Hi and welcome to devnet,
Can you show your .pro file ?
sorry to report wrong error but the real bug is The process "QT_Set_Up\Tools\mingw492_32\bin\mingw32-make.exe" exited with code 2.
this might be related to any project setup configuration . I have 5.5 version of qt library , qt creator version 4.2.1 and default compiler MINGW 4.9.2 .
i am trying to build an existing QT project in creator , i do not know the previous configuration of set up . help me to fix it . I have a source code how i would be able to get know about previous configuration.
QT_Set_Up\Tools\mingw492_32\bin\mingw32-make.exe" exited with code 2
This is probably not the real error. The real error should be somewhere before that line. Can you show the whole build log?
./Workflow/xyz.h:365:37: error: 'MainPortionActive' is not a class or namespace
enum MainPortionActive active = MainPortionActive::patient_info;
../Workflow/xyz.h:369:42: error: 'LeftPanelOption' is not a class or namespace
enum LeftPanelOption leftActiveTab = LeftPanelOption::create_patient;
Makefile.Debug:5366: recipe for target 'debug/main.o' failed
mingw32-make: Leaving directory '/build-abc-Desktop_Qt_5_5_1_MinGW_32bit-Debug'
mingw32-make: *** [debug/main.o] Error 1
makefile:34: recipe for target 'debug' failed
mingw32-make: *** [debug] Error 2
these are the lines showing above that line.
MainPortionActive and LeftPanelOption are unknown where they are used. Did you forget to include header files where those types are declared?
@jsulm No , same code is working on other machine on ubuntu but it is not able to compile on windows 64. I am new to QT and c++ also. No other change except than set up configuration.
@rajeshgoswami2025 You should check Workflow/xyz.h - as the compiler tells you it does not know what MainPortionActive and LeftPanelOption are. I don't know why it works on Ubuntu - could be a different C++ compiler version.
One note: you are building your app as 32bit (this is fine even on Windows 64bit).
@jsulm I can not change in existing working code , i can search for same compatible compiler for windows also . can u help me to know the existing configuration of QT project so that i would be able to set up same replica in my system as well.
@rajeshgoswami2025 It would be actually better to try to find out why it doesn't build on Windows. Using another MinGW compiler can be tricky. What is the compiler version on Ubuntu and what is the MinGW version you're using? Are you building from a fresh source code without any build artefacts from Ubuntu?
@jsulm GCC version 5.7.0 64 bit is the compiler on Ubuntu, MinGW 4.9.2 32 bit compiler i am using and yes it is a fresh code.
@rajeshgoswami2025 My guess is that the code just doesn't compile with GCC 4.9.
You could try to use a newer MinGW, but probably you will need to rebuild Qt with that compiler.
As alternative you could use VC++ from Microsoft. You can install Visual Studio 2015 Community edition (don't forget to select C++ components during the set-up) for free (even for small commercial projects) and Qt for VC++2015. If you don't want the whole Visual Studio you can install just the build tools - I don't remember how Microsoft calls it, you can search for it.