Ask Your Question
0

Error compiling OpenCV in VS2010

asked 2014-02-06 12:22:51 -0600

Mainframe gravatar image

I recently downloaded OpenCV and I haven't been able to compile the demo program. I downloaded the latest version and when compiling in VS2010 I get the following error:

1>Debug\opencv.obj : fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'

It's a basic error but quite honestly I can't seem to find out what's causing it. I'm using the following software:

  • Windows7, 64 bit
  • VS2010
  • OpenCV 2.4.8

I followed all the steps from the installation tutorial, as follows:

Environment variable: OPENCV_DIR S:\OpenCV\build\x86\vc10 On Windows Path: S:\OpenCV\build\x86\vc10\bin

In VS2010:

  • At C/C++ "Additional include directories": S:\OpenCV\build\include
  • Linker->General->Additional Library Dependencies: $(OPENCV_DIR)\lib
  • Linker->Input->Additional Dependencies (for Debug):

opencv_core248d.lib opencv_imgproc248d.lib opencv_highgui248d.lib opencv_ml248d.lib opencv_video248d.lib opencv_features2d248d.lib opencv_calib3d248d.lib opencv_objdetect248d.lib opencv_contrib248d.lib opencv_legacy248d.lib opencv_flann248d.lib

  • Linker->Advanced->Target Machine: MachineX86

  • Linker->Command Line-> There is no /MACHINE:X64 there, only /MACHINE:X86

I did try to change these settings to run in 64 bits but I STILL get an error, only this time it's the opposite (instead of x86 conflicts with x64, i get x64 conflicts with x86). Tried to google for any way to solve this but haven't found a solution for my particular problem.

Any sort of help would be greatly appreciated.

Regards, Nuno

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2014-02-06 13:45:59 -0600

andrei.toader gravatar image

updated 2014-02-07 03:10:18 -0600

Hey, I will give you my configuration.
http://pastebin.com/ekt04Yag
Now, in C/C++ general (Additional Include Libraries):
\build\include\opencv
\build\include\opencv2
\build\include

//Looks better formatted like that.

edit flag offensive delete link more

Comments

Let me understand, I tried to help you and you gave me a low vote? If you don't understand the configuration or how I wrote you just say it - for me it works fine with all the versions and on all the platforms x64, x86.

andrei.toader gravatar imageandrei.toader ( 2014-02-07 03:02:52 -0600 )edit

Actually I will downvote it again because your solution is wrong to the problem stated. He has a wrong configuration in his visual studio. You can specify the target architecture in your project settings, and it still stand on 32bit systems while he is compiling for 64 bit systems or vice versa.

StevenPuttemans gravatar imageStevenPuttemans ( 2014-02-07 07:11:19 -0600 )edit

Huh, if I did a low vote on your comment Andrei, I assure you it wasn't intentional. Apologies. Regarding the comment itself, I already tried those settings but it didn't work.

Mainframe gravatar imageMainframe ( 2014-02-07 07:34:40 -0600 )edit

Not sure but maybe you have the same environment variable for opencv libs for both x86 and x64 somehow the same? e.g OPENCV_DIR from the environment variables is the same for x86 and x64. Not really sure about that.

andrei.toader gravatar imageandrei.toader ( 2014-02-07 07:45:41 -0600 )edit

Double checked it through the "Set" command on command line, only have one OpenCV environment variable:

OPENCV_DIR=S:\OpenCV\build\x86\vc10

Mainframe gravatar imageMainframe ( 2014-02-07 09:21:07 -0600 )edit
0

answered 2014-02-07 07:12:45 -0600

This is your problem. You need to change your target machine type.

edit flag offensive delete link more

Comments

Okay excuse me, read over the fact that you do not have the x64 machine type ... did you download a 32 bit VS for a 64 bit maybe?

StevenPuttemans gravatar imageStevenPuttemans ( 2014-02-07 07:14:43 -0600 )edit

It's VS2010 32 Bits (correct me if I'm wrong but there is no 64 bits version, at least there wasn't one few years back and even now it's not available at MS DreamSpark website), the Windows is the only 64b software here.

Mainframe gravatar imageMainframe ( 2014-02-07 07:42:51 -0600 )edit
1

If you read the part :

"In VS2010:

At C/C++ "Additional include directories": S:\OpenCV\build\include"

You should understand that initially I thought he is missing some configurations so yeah, I tried to give him a proper configuration to start from. I don't care about down-votes but I do care about people being fair (a lot).

andrei.toader gravatar imageandrei.toader ( 2014-02-07 07:49:34 -0600 )edit

Agreed to that. However my downvote is not for the fact your hunch was not well intended, but for the fact that that solution isn't proper for this question. For example, I would understand if mine got downvoted because i read the question wrong. I would remove it myself if there werent some interesting comments ...

StevenPuttemans gravatar imageStevenPuttemans ( 2014-02-07 08:42:37 -0600 )edit

@Mainframe, did you went to your project configuration and made sure every setting there is on x64?

StevenPuttemans gravatar imageStevenPuttemans ( 2014-02-07 08:55:37 -0600 )edit
1

It seems there was one x64 setting... I fixed it and different error (only when running in Debug mode):

1>LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt

Also, forgot to mention in the first post, not that it should make any difference but I don't have VS2010 SP1 installed and I also have VS2013 installed.

Mainframe gravatar imageMainframe ( 2014-02-07 09:56:34 -0600 )edit
1

That is simple. go to Linker/General and disable Incremental Linkining: "Enable Incremental Linking: No(/INCREMENTAL:NO)".

andrei.toader gravatar imageandrei.toader ( 2014-02-07 09:59:00 -0600 )edit

Okey, got some progress now :) That fixed it but now got a whole new array of errors:

'TestOpenCV.exe': Loaded 'W:\Dropbox\Tese\Visual Studio Projects\Kinect\MyProjs\TestOpenCV\Debug\TestOpenCV.exe', Symbols loaded.

'TestOpenCV.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file

'TestOpenCV.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file

'TestOpenCV.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file

'TestOpenCV.exe': Loaded 'S:\OpenCV\build\x86\vc10\bin\opencv_core248d.dll', Cannot find or open the PDB file

This error list goes on for other DLL files...

Mainframe gravatar imageMainframe ( 2014-02-07 10:04:53 -0600 )edit

I can't help you with that. I only used on 2010 and 2012. Both without problems - as I stated before. I hope you know that you have different libs for different vs versions. E.g vc10 for visual studio 10, vc11 for visual studio 12 or smth like that, sorry if I got the names wrong.

andrei.toader gravatar imageandrei.toader ( 2014-02-07 10:08:55 -0600 )edit

I think you need to add the bin opencv\build\x86\vc12 to the path so that it works on visual studio 2013 too. Exactly as you did for vs 2010

andrei.toader gravatar imageandrei.toader ( 2014-02-07 10:10:56 -0600 )edit

Question Tools

Stats

Asked: 2014-02-06 12:22:51 -0600

Seen: 2,780 times

Last updated: Feb 07 '14