0

I am developing C++ code with OpenCV package for heterogeneous targets (windows/Mac/Linux - 32bit and 64 bit).

Libraries Required to build my c++:

  1. MingW
  2. OPenCV and Both are built for 64 bit.

I am able to generate 64 bit exe/dll/.so's on the 64 bit build environments.(Built opencv and mingw for 64 bit) and similarly for 32 bit.

Is it possible to create a 32 bit applications in 64 bit dev environment in windows with Mingw and OpenCV? A note here is that, my supporting sdk's or libraries are built with 64 bit.

2vision2
  • 4,933
  • 16
  • 83
  • 164
  • 1
    Dup http://stackoverflow.com/questions/1272357/how-to-compile-a-32-bit-binary-on-a-64-bit-linux-machine-with-gcc-cmake and here http://stackoverflow.com/questions/3501878/force-gcc-to-compile-32-bit-programs-on-64-bit-platform – Sergei Nikulov Feb 18 '15 at 07:40
  • why not just ask them on the forum? http://answers.opencv.org/questions/ – Kerry Kobashi Feb 18 '15 at 07:41
  • 1
    Yes you can build 32bit exes using MingW/OpenCV, but no, you won't be able to do that without having a 32bit mingw toolset/standard library/SDK and building both OpenCV and your app with it. I'm not sure this answers your question though :] – stijn Feb 18 '15 at 08:22
  • @stiji So you mean to say, all the supporting packages ( Mingw and Opencv) have to built for 32 bit – 2vision2 Feb 18 '15 at 08:24
  • 1
    Indeed. The code generated by compilers for 32bit/64bit targets is not compatible. Simplified example: a pointer in 32bit code is usually 4 bytes, but it is 8 bytes in 64bit code. You cannot expect that to be simply compatible. – stijn Feb 18 '15 at 08:28
  • 1.Is there any possibility to build the supporting packages (Mingw and OpenCV) to make it work with both 64 bit and 32 bit environment. 2. Can i just build the libraries with another 32 bit machine and point them in 64 bit dev or build environment ? – 2vision2 Feb 18 '15 at 09:30
  • You seem to have some misunderstanding about 32/64bit but I cannot pinpoint what exactly from your questions. *You cannot mix 32/64bit builds/static libraries/dlls/executables/...*. Just like you usually cannot mix debug and release builds. You have to build everything seperately. And you can do that on a 64bit machine, see linked question from Sergay. – stijn Feb 18 '15 at 12:12
  • Sorry for asking question in a confusable way. 1. Think that the supporting package (Mingw and Opencv) have been built for 32 bit. 2. And i copy /paste them in 64 bit machine 3. Now in, 64 bit build environment, will it work, if i just point the 32 bit libs instead of 64 bit libs? – 2vision2 Feb 19 '15 at 07:11
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/71231/discussion-between-2vision2-and-stijn). – 2vision2 Feb 19 '15 at 07:17

1 Answers1

0

In Win64 targetting Win32 you can do that by installing the correct mingw package from here.

Note the "Toolchains targetting Win32".

For example, for 4.9.2 you can take this. (I know as a fact that it works for OpenCV)

In the comments you got you can find also a solution for Linux64 targeting Linux32.

Antonio
  • 19,451
  • 13
  • 99
  • 197