0

I am trying build Apache log4cxx 0.13.0 for mingw in windows platform

  1. I builder and installed apr and apr-util using MSYS2
  2. I downloaded log4cxx source from apache repository

but when configuring with CMake it shows this error:

CMake Error at src/cmake/FindAPR.cmake:17 (message):
apr-1-config --includedir failed with result %1 is not a valid Win32
application
Call Stack (most recent call first):
src/cmake/FindAPR.cmake:35 (_apr_invoke)
CMakeLists.txt:44 (find_package)

CMakeOutput.log

enter image description here

  • Do you have apr installed and `apr-1-config` in your `PATH`? – Brecht Sanders Aug 10 '22 at 06:28
  • Yes I have it. Also I tried building my self apr and apr-util applying the mingw patchs and when I buil log4cxx I get the same error. https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-apr – Orlay Garcia Duconge Aug 10 '22 at 16:06
  • I actually have the same issue as you since log4cxx version 0.12.0. I am able to build version 0.11.0, see my recipe at: https://github.com/brechtsanders/winlibs_recipes/blob/main/recipes/log4cxx.winlib – Brecht Sanders Aug 10 '22 at 17:21
  • Scratch that, I got version 0.13.0 to build on Windows with a few tweaks. – Brecht Sanders Aug 10 '22 at 17:46

1 Answers1

1

apu-1-config of the apr-util package is actually a *nix shell script.

CMake is trying to run apr-1-config directly but of course Windows has no clue how to execute it.

The solution is execute sh.exe with apr-1-config (and its arguments) as argument(s).

The following patch fixes this issue for me:

patch -ulbf src/cmake/FindAPR.cmake << EOF
@@ -10,3 +10,3 @@
     execute_process(
-        COMMAND \${APR_CONFIG_EXECUTABLE} \${ARGN}
+        COMMAND sh \${APR_CONFIG_EXECUTABLE} \${ARGN}
         OUTPUT_VARIABLE _apr_output
EOF
patch -ulbf src/cmake/FindAPR-Util.cmake << EOF
@@ -11,3 +11,3 @@
     execute_process(
-        COMMAND \${APR_UTIL_CONFIG_EXECUTABLE} \${ARGN}
+        COMMAND sh \${APR_UTIL_CONFIG_EXECUTABLE} \${ARGN}
         OUTPUT_VARIABLE _apr_output
EOF

I have updated my winlibs build script (which is mostly MSYS2 shell commands) so it now builds the most recent Apache Log4cxx 0.13.0. Besides this issue I had to add a few more workarounds though...

Brecht Sanders
  • 6,215
  • 1
  • 16
  • 40
  • this is the correct answer to my question. I patched all the files as .wimlib and I was able to configure and generate the source using CMake. But make command dont find apr include path https://drive.google.com/file/d/1uGNsUOxnIGuav6bmr5_KPku6XnnYVwWO/view?usp=sharing – Orlay Garcia Duconge Aug 10 '22 at 21:43
  • 1
    I actually modifed `apr-1-config` in https://github.com/brechtsanders/winlibs_recipes/blob/main/recipes/apr.winlib because otherwise there were relocation issues. – Brecht Sanders Aug 11 '22 at 08:27