Have a 32-64bit problem with OpenCV and Qt












1














I have used OpenCV 3.2.0 since a long time ago.
Recently, I need to implement face detection with landmark detection so I decided to build the OpenCV again with extra OpenCV modules.
However, it seems that OpenCV 3.2.0 is not compatible with the latest extra OpenCV modules so I have to build it with the latest OpenCV (which is 4.0.0)



The problem is, I'm in a Catch 22 situation.



1. If I use mingw 32bit 5.1.0 to build OpenCV (which is a compiler bundled with Qt), I have a following error




CMakeFilesopencv_core.dir/objects.a: member
CMakeFilesopencv_core.dir/objects.a(vs_version.rc.obj) in archive is
not an object




2. If I use mingw 64bit 8.1.0 to build OpenCV, it works fine. However there are two situations that give me an error.



2.1. If I use mingw 32bit 5.1.0 to build a Qt Project with those OpenCV libs, it gives a following error.




D:opencv-buildbinlibopencv_core400.dll:-1: error: file not
recognized: File format not recognized




I suspect that this has something to do with 32-64bit problem. The compiler may expect 32bit libs, but the libs are 64bit format because the compiler used to build OpenCV was 64bit mingw.



file format pei-i386
file format pei-x86-64


The first one is the file format of the OpenCV 3.2.0 libs which I used in the past and worked fine with Qt.
The second one is the file format of the OpenCV 4.0.0 libs newly built.



2.2 If I use mingw 64bit 8.1.0 to build a Qt Project with those OpenCV libs, it gives a following error.




collect2.exe: error: ld returned 5 exit status




I suspect that this occurred because basically Qt is for 32-bit, not 64-bit.



What I want to do is that building OpenCV 4.0.0 so that somehow the file format of those OpenCV libs is pei-i386, not pei-x86-64.
How can I achieve this?










share|improve this question
























  • collect2.exe: error: ld returned 5 exit status is not a diagnostic. It is GCC saying "Your linkage failed :( Bye.". The linker's diagnostics precede this farewell in the buildlog, and they are what you need to post to get help with the linkage failure. Just post the complete buildlog, verbatim.
    – Mike Kinghan
    Nov 12 at 16:02










  • also you know you can download the opencv_contrib for version 3.2.0? better to use the latest version, though
    – Miki
    Nov 12 at 17:17






  • 1




    Your assumption regarding the Qt libs is correct. I would recommend you to build Qt yourself with the mingw 64 8.1.0
    – Felix
    Nov 12 at 18:14










  • @Mike Kinghan It was the only error message. Is there a way for me to get the verbose buildlog in that case?
    – James
    Nov 13 at 1:08










  • @James Probably, but I don't know what your build-system is or how you are running it.
    – Mike Kinghan
    Nov 13 at 7:35
















1














I have used OpenCV 3.2.0 since a long time ago.
Recently, I need to implement face detection with landmark detection so I decided to build the OpenCV again with extra OpenCV modules.
However, it seems that OpenCV 3.2.0 is not compatible with the latest extra OpenCV modules so I have to build it with the latest OpenCV (which is 4.0.0)



The problem is, I'm in a Catch 22 situation.



1. If I use mingw 32bit 5.1.0 to build OpenCV (which is a compiler bundled with Qt), I have a following error




CMakeFilesopencv_core.dir/objects.a: member
CMakeFilesopencv_core.dir/objects.a(vs_version.rc.obj) in archive is
not an object




2. If I use mingw 64bit 8.1.0 to build OpenCV, it works fine. However there are two situations that give me an error.



2.1. If I use mingw 32bit 5.1.0 to build a Qt Project with those OpenCV libs, it gives a following error.




D:opencv-buildbinlibopencv_core400.dll:-1: error: file not
recognized: File format not recognized




I suspect that this has something to do with 32-64bit problem. The compiler may expect 32bit libs, but the libs are 64bit format because the compiler used to build OpenCV was 64bit mingw.



file format pei-i386
file format pei-x86-64


The first one is the file format of the OpenCV 3.2.0 libs which I used in the past and worked fine with Qt.
The second one is the file format of the OpenCV 4.0.0 libs newly built.



2.2 If I use mingw 64bit 8.1.0 to build a Qt Project with those OpenCV libs, it gives a following error.




collect2.exe: error: ld returned 5 exit status




I suspect that this occurred because basically Qt is for 32-bit, not 64-bit.



What I want to do is that building OpenCV 4.0.0 so that somehow the file format of those OpenCV libs is pei-i386, not pei-x86-64.
How can I achieve this?










share|improve this question
























  • collect2.exe: error: ld returned 5 exit status is not a diagnostic. It is GCC saying "Your linkage failed :( Bye.". The linker's diagnostics precede this farewell in the buildlog, and they are what you need to post to get help with the linkage failure. Just post the complete buildlog, verbatim.
    – Mike Kinghan
    Nov 12 at 16:02










  • also you know you can download the opencv_contrib for version 3.2.0? better to use the latest version, though
    – Miki
    Nov 12 at 17:17






  • 1




    Your assumption regarding the Qt libs is correct. I would recommend you to build Qt yourself with the mingw 64 8.1.0
    – Felix
    Nov 12 at 18:14










  • @Mike Kinghan It was the only error message. Is there a way for me to get the verbose buildlog in that case?
    – James
    Nov 13 at 1:08










  • @James Probably, but I don't know what your build-system is or how you are running it.
    – Mike Kinghan
    Nov 13 at 7:35














1












1








1







I have used OpenCV 3.2.0 since a long time ago.
Recently, I need to implement face detection with landmark detection so I decided to build the OpenCV again with extra OpenCV modules.
However, it seems that OpenCV 3.2.0 is not compatible with the latest extra OpenCV modules so I have to build it with the latest OpenCV (which is 4.0.0)



The problem is, I'm in a Catch 22 situation.



1. If I use mingw 32bit 5.1.0 to build OpenCV (which is a compiler bundled with Qt), I have a following error




CMakeFilesopencv_core.dir/objects.a: member
CMakeFilesopencv_core.dir/objects.a(vs_version.rc.obj) in archive is
not an object




2. If I use mingw 64bit 8.1.0 to build OpenCV, it works fine. However there are two situations that give me an error.



2.1. If I use mingw 32bit 5.1.0 to build a Qt Project with those OpenCV libs, it gives a following error.




D:opencv-buildbinlibopencv_core400.dll:-1: error: file not
recognized: File format not recognized




I suspect that this has something to do with 32-64bit problem. The compiler may expect 32bit libs, but the libs are 64bit format because the compiler used to build OpenCV was 64bit mingw.



file format pei-i386
file format pei-x86-64


The first one is the file format of the OpenCV 3.2.0 libs which I used in the past and worked fine with Qt.
The second one is the file format of the OpenCV 4.0.0 libs newly built.



2.2 If I use mingw 64bit 8.1.0 to build a Qt Project with those OpenCV libs, it gives a following error.




collect2.exe: error: ld returned 5 exit status




I suspect that this occurred because basically Qt is for 32-bit, not 64-bit.



What I want to do is that building OpenCV 4.0.0 so that somehow the file format of those OpenCV libs is pei-i386, not pei-x86-64.
How can I achieve this?










share|improve this question















I have used OpenCV 3.2.0 since a long time ago.
Recently, I need to implement face detection with landmark detection so I decided to build the OpenCV again with extra OpenCV modules.
However, it seems that OpenCV 3.2.0 is not compatible with the latest extra OpenCV modules so I have to build it with the latest OpenCV (which is 4.0.0)



The problem is, I'm in a Catch 22 situation.



1. If I use mingw 32bit 5.1.0 to build OpenCV (which is a compiler bundled with Qt), I have a following error




CMakeFilesopencv_core.dir/objects.a: member
CMakeFilesopencv_core.dir/objects.a(vs_version.rc.obj) in archive is
not an object




2. If I use mingw 64bit 8.1.0 to build OpenCV, it works fine. However there are two situations that give me an error.



2.1. If I use mingw 32bit 5.1.0 to build a Qt Project with those OpenCV libs, it gives a following error.




D:opencv-buildbinlibopencv_core400.dll:-1: error: file not
recognized: File format not recognized




I suspect that this has something to do with 32-64bit problem. The compiler may expect 32bit libs, but the libs are 64bit format because the compiler used to build OpenCV was 64bit mingw.



file format pei-i386
file format pei-x86-64


The first one is the file format of the OpenCV 3.2.0 libs which I used in the past and worked fine with Qt.
The second one is the file format of the OpenCV 4.0.0 libs newly built.



2.2 If I use mingw 64bit 8.1.0 to build a Qt Project with those OpenCV libs, it gives a following error.




collect2.exe: error: ld returned 5 exit status




I suspect that this occurred because basically Qt is for 32-bit, not 64-bit.



What I want to do is that building OpenCV 4.0.0 so that somehow the file format of those OpenCV libs is pei-i386, not pei-x86-64.
How can I achieve this?







qt opencv mingw-w64 mingw32






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 at 1:01

























asked Nov 12 at 13:27









James

587




587












  • collect2.exe: error: ld returned 5 exit status is not a diagnostic. It is GCC saying "Your linkage failed :( Bye.". The linker's diagnostics precede this farewell in the buildlog, and they are what you need to post to get help with the linkage failure. Just post the complete buildlog, verbatim.
    – Mike Kinghan
    Nov 12 at 16:02










  • also you know you can download the opencv_contrib for version 3.2.0? better to use the latest version, though
    – Miki
    Nov 12 at 17:17






  • 1




    Your assumption regarding the Qt libs is correct. I would recommend you to build Qt yourself with the mingw 64 8.1.0
    – Felix
    Nov 12 at 18:14










  • @Mike Kinghan It was the only error message. Is there a way for me to get the verbose buildlog in that case?
    – James
    Nov 13 at 1:08










  • @James Probably, but I don't know what your build-system is or how you are running it.
    – Mike Kinghan
    Nov 13 at 7:35


















  • collect2.exe: error: ld returned 5 exit status is not a diagnostic. It is GCC saying "Your linkage failed :( Bye.". The linker's diagnostics precede this farewell in the buildlog, and they are what you need to post to get help with the linkage failure. Just post the complete buildlog, verbatim.
    – Mike Kinghan
    Nov 12 at 16:02










  • also you know you can download the opencv_contrib for version 3.2.0? better to use the latest version, though
    – Miki
    Nov 12 at 17:17






  • 1




    Your assumption regarding the Qt libs is correct. I would recommend you to build Qt yourself with the mingw 64 8.1.0
    – Felix
    Nov 12 at 18:14










  • @Mike Kinghan It was the only error message. Is there a way for me to get the verbose buildlog in that case?
    – James
    Nov 13 at 1:08










  • @James Probably, but I don't know what your build-system is or how you are running it.
    – Mike Kinghan
    Nov 13 at 7:35
















collect2.exe: error: ld returned 5 exit status is not a diagnostic. It is GCC saying "Your linkage failed :( Bye.". The linker's diagnostics precede this farewell in the buildlog, and they are what you need to post to get help with the linkage failure. Just post the complete buildlog, verbatim.
– Mike Kinghan
Nov 12 at 16:02




collect2.exe: error: ld returned 5 exit status is not a diagnostic. It is GCC saying "Your linkage failed :( Bye.". The linker's diagnostics precede this farewell in the buildlog, and they are what you need to post to get help with the linkage failure. Just post the complete buildlog, verbatim.
– Mike Kinghan
Nov 12 at 16:02












also you know you can download the opencv_contrib for version 3.2.0? better to use the latest version, though
– Miki
Nov 12 at 17:17




also you know you can download the opencv_contrib for version 3.2.0? better to use the latest version, though
– Miki
Nov 12 at 17:17




1




1




Your assumption regarding the Qt libs is correct. I would recommend you to build Qt yourself with the mingw 64 8.1.0
– Felix
Nov 12 at 18:14




Your assumption regarding the Qt libs is correct. I would recommend you to build Qt yourself with the mingw 64 8.1.0
– Felix
Nov 12 at 18:14












@Mike Kinghan It was the only error message. Is there a way for me to get the verbose buildlog in that case?
– James
Nov 13 at 1:08




@Mike Kinghan It was the only error message. Is there a way for me to get the verbose buildlog in that case?
– James
Nov 13 at 1:08












@James Probably, but I don't know what your build-system is or how you are running it.
– Mike Kinghan
Nov 13 at 7:35




@James Probably, but I don't know what your build-system is or how you are running it.
– Mike Kinghan
Nov 13 at 7:35

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53263199%2fhave-a-32-64bit-problem-with-opencv-and-qt%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53263199%2fhave-a-32-64bit-problem-with-opencv-and-qt%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Xamarin.iOS Cant Deploy on Iphone

Glorious Revolution

Dulmage-Mendelsohn matrix decomposition in Python