google / glog

C++ implementation of the Google logging module
http://google.github.io/glog/
BSD 3-Clause "New" or "Revised" License
6.99k stars 2.05k forks source link

windows mingw64 compile fail #1027

Closed aiaimimi0920 closed 8 months ago

aiaimimi0920 commented 8 months ago

My step:

git clone https://github.com/google/glog.git
cd glog

cmake -S . -B build -G "Unix Makefiles"
cmake --build build

An error occurred:

[  3%] Building CXX object CMakeFiles/glog_internal.dir/src/demangle.cc.obj
In file included from C:/Users/xxx/Documents/glog/src/demangle.cc:44:
C:/Users/xxx/Documents/glog/src/utilities.h:61:12: fatal error: port.h: No such file or directory
   61 | #  include "port.h"
      |            ^~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/glog_internal.dir/build.make:76: CMakeFiles/glog_internal.dir/src/demangle.cc.obj] Error 1
make[1]: *** [CMakeFiles/Makefile2:861: CMakeFiles/glog_internal.dir/all] Error 2
make: *** [Makefile:166: all] Error 2

Everything is normal when compiling on Ubuntu. Is there any special operation required for compiling on the Windows platform?

I use MSYS2 MINGW64、windows 11 、 Latest code 54b2c17172dc39892de41ed2b3e72902e19ce0c0

Hope to receive some guidance, thank you in advance

sergiud commented 8 months ago

Could you please provide the full output of cmake --build build --verbose?

aiaimimi0920 commented 8 months ago

This is the complete output

$ cmake --build build --verbose
Change Dir: '/c/Users/xxx/Documents/glog/build'

Run Build Command(s): /usr/bin/cmake.exe -E env VERBOSE=1 /usr/bin/make.exe -f Makefile
/usr/bin/cmake.exe -S/c/Users/xxx/Documents/glog -B/c/Users/xxx/Documents/glog/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake.exe -E cmake_progress_start /c/Users/xxx/Documents/glog/build/CMakeFiles /c/Users/xxx/Documents/glog/build//CMakeFiles/progress.marks
/usr/bin/make  -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/c/Users/xxx/Documents/glog/build'
/usr/bin/make  -f CMakeFiles/glog_internal.dir/build.make CMakeFiles/glog_internal.dir/depend
make[2]: Entering directory '/c/Users/xxx/Documents/glog/build'
cd /c/Users/xxx/Documents/glog/build && /usr/bin/cmake.exe -E cmake_depends "Unix Makefiles" /c/Users/xxx/Documents/glog /c/Users/xxx/Documents/glog /c/Users/xxx/Documents/glog/build /c/Users/xxx/Documents/glog/build /c/Users/xxx/Documents/glog/build/CMakeFiles/glog_internal.dir/DependInfo.cmake "--color="
make[2]: Leaving directory '/c/Users/xxx/Documents/glog/build'
/usr/bin/make  -f CMakeFiles/glog_internal.dir/build.make CMakeFiles/glog_internal.dir/build
make[2]: Entering directory '/c/Users/xxx/Documents/glog/build'
[  3%] Building CXX object CMakeFiles/glog_internal.dir/src/demangle.cc.obj
/mingw64/bin/CC.exe -DGFLAGS_IS_A_DLL=0 -DGLOG_NO_SYMBOLIZE_DETECTION -DGLOG_USE_GFLAGS -DGLOG_USE_GLOG_EXPORT -DGOOGLE_GLOG_IS_A_DLL -I/c/Users/xxx/Documents/glog/src -I/c/Users/xxx/Documents/glog/build -I/usr/local/include -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -MD -MT CMakeFiles/glog_internal.dir/src/demangle.cc.obj -MF CMakeFiles/glog_internal.dir/src/demangle.cc.obj.d -o CMakeFiles/glog_internal.dir/src/demangle.cc.obj -c /c/Users/xxx/Documents/glog/src/demangle.cc
In file included from C:/Users/xxx/Documents/glog/src/demangle.cc:44:
C:/Users/xxx/Documents/glog/src/utilities.h:61:12: fatal error: port.h: No such file or directory
   61 | #  include "port.h"
      |            ^~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/glog_internal.dir/build.make:76: CMakeFiles/glog_internal.dir/src/demangle.cc.obj] Error 1
make[2]: Leaving directory '/c/Users/xxx/Documents/glog/build'
make[1]: *** [CMakeFiles/Makefile2:861: CMakeFiles/glog_internal.dir/all] Error 2
make[1]: Leaving directory '/c/Users/xxx/Documents/glog/build'
make: *** [Makefile:166: all] Error 2
sergiud commented 8 months ago

You need to run CMake in the MINGW64 / MSYS2 shell not MSYS / MSYS2. You may need to install the mingw-w64-x86_64-cmake package. See our MinGW github action for reference:

https://github.com/google/glog/blob/cafba580ec4faeeb8e61a97f91819fd0db3205a0/.github/workflows/windows.yml#L179-L186

aiaimimi0920 commented 8 months ago

Thanks for your guidance, it helps a lot.

I am indeed using MINGW64/MSYS2. It should be caused by not installing the software package mingw-w64-x86_64-cmake. Because I did not encounter this problem when compiling other projects normally, I did not take it into consideration.

All in all, thank you very much