glog似乎没有在带有MinGW的Windows上编译。Cmake的配置和生成是可以的,但当我启动mingw32-make.exe-j10命令时,我会收到很多与模糊性声明有关的错误。
这是完整的cmake配置和生成命令输出:
D:INSTALLDevelopmentlibceres-mingwglogbuild>"D:Program FilesCMakebincmake.exe" -G "MinGW Makefiles" -Dgflags_DIR="D:INSTALLDevelopmentlibceres-mingwgflagsbuild" ..
-- The C compiler identification is GNU 9.2.0
-- The CXX compiler identification is GNU 9.2.0
-- Check for working C compiler: D:/MinGW/bin/gcc.exe
-- Check for working C compiler: D:/MinGW/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: D:/MinGW/bin/g++.exe
-- Check for working CXX compiler: D:/MinGW/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for gflags namespace
-- Looking for gflags namespace - gflags
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Could NOT find Unwind (missing: Unwind_INCLUDE_DIR Unwind_LIBRARY Unwind_PLATFORM_LIBRARY)
-- Looking for dlfcn.h
-- Looking for dlfcn.h - found
-- Looking for execinfo.h
-- Looking for execinfo.h - not found
-- Looking for glob.h
-- Looking for glob.h - found
-- Looking for inttypes.h
-- Looking for inttypes.h - found
-- Looking for memory.h
-- Looking for memory.h - found
-- Looking for pwd.h
-- Looking for pwd.h - not found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stdlib.h
-- Looking for stdlib.h - found
-- Looking for string.h
-- Looking for string.h - found
-- Looking for strings.h
-- Looking for strings.h - found
-- Looking for sys/stat.h
-- Looking for sys/stat.h - found
-- Looking for sys/syscall.h
-- Looking for sys/syscall.h - not found
-- Looking for sys/time.h
-- Looking for sys/time.h - found
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for sys/utsname.h
-- Looking for sys/utsname.h - not found
-- Looking for sys/wait.h
-- Looking for sys/wait.h - not found
-- Looking for syscall.h
-- Looking for syscall.h - not found
-- Looking for syslog.h
-- Looking for syslog.h - not found
-- Looking for ucontext.h
-- Looking for ucontext.h - not found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Looking for C++ include ext/hash_map
-- Looking for C++ include ext/hash_map - found
-- Looking for C++ include ext/hash_set
-- Looking for C++ include ext/hash_set - found
-- Looking for C++ include ext/slist
-- Looking for C++ include ext/slist - found
-- Looking for C++ include tr1/unordered_map
-- Looking for C++ include tr1/unordered_map - found
-- Looking for C++ include tr1/unordered_set
-- Looking for C++ include tr1/unordered_set - found
-- Looking for C++ include unordered_map
-- Looking for C++ include unordered_map - found
-- Looking for C++ include unordered_set
-- Looking for C++ include unordered_set - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of unsigned __int16
-- Check size of unsigned __int16 - done
-- Check size of u_int16_t
-- Check size of u_int16_t - failed
-- Check size of uint16_t
-- Check size of uint16_t - done
-- Looking for dladdr
-- Looking for dladdr - not found
-- Looking for fcntl
-- Looking for fcntl - not found
-- Looking for pread
-- Looking for pread - not found
-- Looking for pwrite
-- Looking for pwrite - not found
-- Looking for sigaction
-- Looking for sigaction - not found
-- Looking for sigaltstack
-- Looking for sigaltstack - not found
-- Performing Test HAVE_NO_DEPRECATED
-- Performing Test HAVE_NO_DEPRECATED - Success
-- Performing Test HAVE_NO_UNNAMED_TYPE_TEMPLATE_ARGS
-- Performing Test HAVE_NO_UNNAMED_TYPE_TEMPLATE_ARGS - Failed
-- Looking for snprintf
-- Looking for snprintf - found
-- Looking for UnDecorateSymbolName in dbghelp
-- Looking for UnDecorateSymbolName in dbghelp - not found
-- Performing Test HAVE___ATTRIBUTE__
-- Performing Test HAVE___ATTRIBUTE__ - Success
-- Performing Test HAVE___ATTRIBUTE__VISIBILITY_DEFAULT
-- Performing Test HAVE___ATTRIBUTE__VISIBILITY_DEFAULT - Success
-- Performing Test HAVE___ATTRIBUTE__VISIBILITY_HIDDEN
-- Performing Test HAVE___ATTRIBUTE__VISIBILITY_HIDDEN - Success
-- Performing Test HAVE___BUILTIN_EXPECT
-- Performing Test HAVE___BUILTIN_EXPECT - Success
-- Performing Test HAVE___SYNC_VAL_COMPARE_AND_SWAP
-- Performing Test HAVE___SYNC_VAL_COMPARE_AND_SWAP - Success
-- Performing Test HAVE_RWLOCK
-- Performing Test HAVE_RWLOCK - Failed
-- Performing Test HAVE___DECLSPEC
-- Performing Test HAVE___DECLSPEC - Success
-- Performing Test STL_NO_NAMESPACE
-- Performing Test STL_NO_NAMESPACE - Failed
-- Performing Test STL_STD_NAMESPACE
-- Performing Test STL_STD_NAMESPACE - Success
-- Performing Test HAVE_USING_OPERATOR
-- Performing Test HAVE_USING_OPERATOR - Success
-- Performing Test HAVE_NAMESPACES
-- Performing Test HAVE_NAMESPACES - Success
-- Performing Test HAVE_GCC_TLS
-- Performing Test HAVE_GCC_TLS - Success
-- Performing Test HAVE_MSVC_TLS
-- Performing Test HAVE_MSVC_TLS - Success
-- Performing Test HAVE_CXX11_TLS
-- Performing Test HAVE_CXX11_TLS - Success
-- Performing Test HAVE_ALIGNED_STORAGE
-- Performing Test HAVE_ALIGNED_STORAGE - Success
-- Performing Test HAVE_SYMBOLIZE
-- Performing Test HAVE_SYMBOLIZE - Failed
-- Performing Test HAVE_LOCALTIME_R
-- Performing Test HAVE_LOCALTIME_R - Failed
-- Configuring done
-- Generating done
-- Build files have been written to: D:/INSTALL/Development/lib/ceres-mingw/glog/build
这是mingw32编译命令的错误输出:
D:INSTALLDevelopmentlibceres-mingwglogsrcdemangle.cc:42:10: fatal error: dbghelp.h: No such file or directory
42 | #include <dbghelp.h>
| ^~~~~~~~~~~
compilation terminated.
CMakeFilesglog.dirbuild.make:62: recipe for target 'CMakeFiles/glog.dir/src/demangle.cc.obj' failed
mingw32-make[2]: *** [CMakeFiles/glog.dir/src/demangle.cc.obj] Error 1
mingw32-make[2]: *** Waiting for unfinished jobs....
In file included from D:INSTALLDevelopmentlibceres-mingwglogsrclogging.cc:63:
D:INSTALLDevelopmentlibceres-mingwglogsrcwindows/dirent.h:383:28: error: missing binary operator before token "("
383 | #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
| ^
D:INSTALLDevelopmentlibceres-mingwglogsrcwindows/dirent.h:405:28: error: missing binary operator before token "("
405 | #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
| ^
D:INSTALLDevelopmentlibceres-mingwglogsrcsymbolize.cc:877:10: fatal error: dbghelp.h: No such file or directory
877 | #include <dbghelp.h>
| ^~~~~~~~~~~
compilation terminated.
In file included from D:INSTALLDevelopmentlibceres-mingwglogsrcwindowsport.cc:41:
D:INSTALLDevelopmentlibceres-mingwglogsrcwindowsport.h:166:14: error: ambiguating new declaration of 'char* strerror_r(int, char*, size_t)'
166 | inline char* strerror_r(int errnum, char* buf, size_t buflen) {
| ^~~~~~~~~~
In file included from d:mingwincludewinnt.h:49,
from d:mingwincludewindef.h:269,
from d:mingwincludewindows.h:42,
from D:INSTALLDevelopmentlibceres-mingwglogsrcwindowsport.h:52,
from D:INSTALLDevelopmentlibceres-mingwglogsrcwindowsport.cc:41:
d:mingwincludestring.h:223:12: note: old declaration 'int strerror_r(int, char*, size_t)'
223 | extern int strerror_r (int, char *, size_t);
| ^~~~~~~~~~C akeFilesglog.dirbuild.make:104: recipe for target 'CMakeFiles/glog.dir/src/symbolize.cc.obj' failed
mingw32-make[2]: *** [CMakeFiles/glog.dir/src/sy D:INSTALLDevelopmentlibceres-mingwglogsrcwindowsport.cc:bo In function 'litm* localtime_r(const time_t*, tm*)ze':
.cD:INSTALLDevelopmentlibceres-mingwglogsrcwindowsport.cc:53:3:c. oberror: j]' Elocaltime_srr' was not declared in this scope; did you mean 'orlocaltime_r 1'?
53 |
localtime_s(result, timep);
| ^~~~~~~~~~~
| localtime_r
D:INSTALLDevelopmentlibceres-mingwglogsrcwindowsport.cc: In function 'tm* gmtime_r(const time_t*, tm*)':
D:INSTALLDevelopmentlibceres-mingwglogsrcwindowsport.cc:59:5: error: 'gmtime_s' was not declared in this scope; did you mean 'gmtime_r'?
59 | gmtime_s(result, timep);
| ^~~~~~~~
| gmtime_r
In file included from D:INSTALLDevelopmentlibceres-mingwglogsrcutilities.h:80,
from D:INSTALLDevelopmentlibceres-mingwglogsrcraw_logging.cc:34:
D:/INSTALL/Development/lib/ceres-mingw/glog/src/windows/port.h:166:14: error: ambiguating new declaration of 'char* strerror_r(int, char*, size_t)'
166 | inline char* strerror_r(int errnum, char* buf, size_t buflen) {
| ^~~~~~~~~~
In file included from d:mingwincludewinnt.h:49,
from d:mingwincludewindef.h:269,
from d:mingwincludewindows.h:42,
from D:INSTALLDevelopmentlibceres-mingwglogsrcbase/mutex.h:129,
from D:INSTALLDevelopmentlibceres-mingwglogsrcutilities.h:75,
from D:INSTALLDevelopmentlibceres-mingwglogsrcraw_logging.cc:34:
d:mingwincludestring.h:223:12: note: old declaration 'int strerror_r(int, char*, size_t)'
223 | extern int MakeFilesglog.dirbuild.make:160: recipe for target 'CMakeFiles/glog.dirstrerror_r/ rc/windows/port.cc.obj' failed
(int, char *, size_t);
| mi^~~~~~~~~~ng
w32-make[2]: *** [CMakeFiles/glog.dir/src/windows/port.cc.obj] Error 1
In file included from D:INSTALLDevelopmentlibceres-mingwglogsrcutilities.h:80,
from D:INSTALLDevelopmentlibceres-mingwglogsrclogging.cc:32:
D:/INSTALL/Development/lib/ceres-mingw/glog/src/windows/port.h:166:14: error: ambiguating new declaration of 'char* strerror_r(int, char*, size_t)'
166 | inline char* strerror_r(int errnum, char* buf, size_t buflen) {
| ^~~~~~~~~~
In file included from d:mingwincludewinnt.h:49,
from d:mingwincludewindef.h:269,
from d:mingwincludewindows.h:42,
from In file included from from ,
from from :
ambiguating new declaration of ' '
166 | inline char* 223 | extern int (int errnum, char* buf, size_t buflen) {
| |
^~~~~~~~~~
In file included from d:mingwincludewinnt.h:49,
from d:mingwincludewindef.h:269,
from d:mingwincludewindows.h:42,
from D:INSTALLDevelopmentlibceres-mingwglogsrcbase/mutex.h:129,
from D:INSTALLDevelopmentlibceres-mingwglogsrcutilities.h:75,
from D:INSTALLDevelopmentlibceres-mingwglogsrcutilities.cc:32:
d:mingwincludestring.h:223:12: note: old declaration 'int strerror_r(int, char*, size_t)'
223 | extern int strerror_r (int, char *, size_t);
| ^~~~~~~~~~
In file included from D:INSTALLDevelopmentlibceres-mingwglogsrcutilities.h:80,
from D:INSTALLDevelopmentlibceres-mingwglogsrcsignalhandler.cc:34:
D:/INSTALL/Development/lib/ceres-mingw/glog/src/windows/port.h:166:14: error: ambiguating new declaration of 'char* strerror_r(int, char*, size_t)'
166 | inline char* strerror_r(int errnum, char* buf, size_t buflen) {
| ^~~~~~~~~~
In file included from d:mingwincludewinnt.h:49,
from d:mingwincludewindef.h:269,
from d:mingwincludewindows.h:42,
from D:INSTALLDevelopmentlibceres-mingwglogsrcbase/mutex.h:129,
from D:INSTALLDevelopmentlibceres-mingwglogsrcutilities.h:75,
from D:INSTALLDevelopmentlibceres-mingwglogsrcsignalhandler.cc:34:
d:mingwincludestring.h:223:12: note: old declaration 'int strerror_r(int, char*, size_t)'
223 | extern int strerror_r (int, char *, size_t);
| ^~~~~~~~~~
CMakeFilesglog.dirbuild.make:90: recipe for target 'CMakeFiles/glog.dir/src/raw_logging.cc.obj' failed
mingw32-make[2]: *** [CMakeFiles/glog.dir/src/raw_logging.cc.obj] Error 1
CMakeFilesglog.dirbuild.make:118: recipe for target 'CMakeFiles/glog.dir/src/utilities.cc.obj' failed
mingw32-make[2]: *** [CMakeFiles/glog.dir/src/utilities.cc.obj] Error 1
In file included from In file included from D:INSTALLDevelopmentlibceres-mingwglogsrclogging.cc:63 ,
from :
D:INSTALLDevelopmentlibceres-mingwglogsrcvlog_is_on.cc:35D:INSTALLDevelopmentlibceres-mingwglogsrcwindows/dirent.h::
In function 'D:/INSTALL/Development/lib/ceres-mingw/glog/src/windows/port.h:166:14:_WDIR* _wopendir(const wchar_t*) ':
error: D:INSTALLDevelopmentlibceres-mingwglogsrcwindows/dirent.h:413:5:ambiguating new declaration of ' char* strerror_r(int, char*, size_t)error: '
166 | inline char* 'strerror_rwcsncpy_s(int errnum, char* buf, size_t buflen) {
| ' was not declared in this scope; did you mean '^~~~~~~~~~wcsncpy
'?
413 | In file included from | ,
from | ,
from ,
from D:INSTALLDevelopmentlibceres-mingwglogsrcbase/mutex.h:129,
from D:INSTALLDevelopmentlibceres-mingwglogsrcutilities.h:75,
from D:INSTALLDevelopmentlibceres-mingwglogsrcvlog_is_on.cc:35:
d:mingwincludestring.h:223:12: note: old declaration 'int strerror_r(int, char*, size_t)'
223 | extern int strerror_r (int, char *, size_t);
| ^~~~~~~~~~
CMakeFilesglog.dirbuild.make:146: recipe for target 'CMakeFiles/glog.dir/src/signalhandler.cc.obj' failed
mingw32-make[2]: *** [CMakeFiles/glog.dir/src/signalhandler.cc.obj] Error 1
D:INSTALLDevelopmentlibceres-mingwglogsrclogging.cc: In function 'void google::TruncateLogFile(const char*, google::int64, google::int64)':
D:INSTALLDevelopmentlibceres-mingwglogsrclogging.cc:2266:11: error: 'truncate' was not declared in this scope; did you mean 'ftruncate'?
2266 | if (truncate(path, 0) == -1) {
| ^~~~~~~~
| ftruncate
CMakeFilesglog.dirbuild.make:132: recipe for target 'CMakeFiles/glog.dir/src/vlog_is_on.cc.obj' failed
mingw32-make[2]: *** [CMakeFiles/glog.dir/src/vlog_is_on.cc.obj] Error 1
CMakeFilesglog.dirbuild.make:76: recipe for target 'CMakeFiles/glog.dir/src/logging.cc.obj' failed
mingw32-make[2]: *** [CMakeFiles/glog.dir/src/logging.cc.obj] Error 1
CMakeFilesMakefile2:926: recipe for target 'CMakeFiles/glog.dir/all' failed
mingw32-make[1]: *** [CMakeFiles/glog.dir/all] Error 2
Makefile:161: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
D:INSTALLDevelopmentlibceres-mingwglogbuild>
我使用cmake 3.15.4版本和官方的mingw32,如下所示:
C:Usersplamen>"D:Program FilesCMakebincmake.exe" --version
cmake version 3.15.4
CMake suite maintained and supported by Kitware (kitware.com/cmake).
C:Usersplamen>mingw32-make,exe --version
GNU Make 3.82.90
Built for i686-pc-mingw32
Copyright (C) 1988-2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
有人能帮我解决这个问题吗?
我使用以下步骤在Windows和MinGW上编译了glog:
在我的ceres文件夹中(在我的情况下是"D:\SINSTALL\Development\lib\ceres-mingw"(,我键入:
> git clone https://github.com/google/glog.git
之后,我将";glog/BUILD";文件到"_BUILD";并创建了名为"build"的文件夹。之后,我进入新创建的"构建"文件夹,并发出以下命令:
> "D:Program FilesCMakebincmake.exe" -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=14 -DCMAKE_CXX_STANDARD_REQUIRED=ON -Dgflags_DIR="D:INSTALLDevelopmentlibceres-mingwgflagsbuild" ..
> "D:MinGW64mingw64binmingw32-make.exe" -j10
重要提示:我将"log_severity.h"从'src\glog'文件夹(在我的情况下为'D:\INSTALL\Development\lib\ceres mingw\glog\src\glog'build\glog'文件夹中(在我情况下为'D:\INSTALL\Dvelopment\lb\ceres ming w\glog \build\glog'
因此,我有:
所有包括位于
'D:\SINSTALL\Development\lib\ceres mingw\glog\build\glog'中的文件libglog.一个静态库,位于
'D:\SINSTALL\Development\lib\ceres mingw\glog\build'中glog-config.cmake文件位于我的构建文件夹中(在我的情况下
'D:\INSTALL\Development\lib\ceres mingw\glog\build'(
可以选择安装(我没有(:
> "D:MinGW64mingw64binmingw32-make.exe" install
希望这些信息对其他用户也有用!
附言:我很可能需要重新编译glog(可能还有gflags和ceres(,将'-fPIC'添加到CMAKE_CXX_FLAGS,否则在Windows上使用MinGW为Android编译OpenCV时,我会错误地将libopencv_java4.so链接到libglog.a。或者,在为Android编译OpenCV时,我必须使用共享库。我很快就会检查这个。