How can I create .o and .a files in ELF format for Windows for the use with C++Builder 10.3.3?

1.2k Views Asked by At

I'm working with Embarcadero C++Builder 10.3.3, and would like to use OpenCV with it. However, the precompiled OpenCV pack is precompiled with Visual Studio, which uses the COFF format. However, the C++Builder 64-bit compiler uses the ELF format under Windows, per Upgrading Existing C++ Projects to 64-bit Windows:

Object and Library File Format

  • BCC32 and its associated tools use OMF in .obj and .lib files.
  • BCC64 uses ELF in .o and .a files.

Of course, I tried to compile the OpenCV source code with C++Builder, but I failed miserably. A Google search didn't find anything really helpful either, except that others also didn't succeed.

Does anyone know a CMake-compatible compiler that can generate object files (.o) and static libraries (.a) for Windows to compile OpenCV (for Windows, not for Linux, because BCC64.EXE is a Windows compiler)?

1

There are 1 best solutions below

6
Rolf Fankhauser On

I'm also trying to use OpenCV with C++Builder (I couldn't write a comment because this is my first contribution!).

I could create the lib file with mkexp from the precompiled dll (opencv_world452.dll in \opencv\build\x64\vc15\bin) as Remy suggested.

But I have problems with the header files: How to set include path that the statement #include "opencv2/core.hpp" is accepted by the compiler? "core.hpp" also has such include statements. So, do we need to change all these #includes (\ instead of /)?

As a workaround you could try to use the Delphi-OpenCV library (https://github.com/Laex/Delphi-OpenCV) or install Python4Delphi in C++Builder and use OpenCV via Python.