Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spdlog android 编译报错 #3493

Open
guijiyang opened this issue Mar 13, 2024 · 12 comments
Open

spdlog android 编译报错 #3493

guijiyang opened this issue Mar 13, 2024 · 12 comments
Labels

Comments

@guijiyang
Copy link
Contributor

Xmake 版本

2.8.6

操作系统版本和架构

windows10

描述问题

spdlog 编译的时候使用fmt库,add_requires("spdlog v1.13.0", { configs = { header_only = false, fmt_external = true } })
但是自带的cmake config 的时候会出现找不到fmt config 信息:

编译windows版本的时候就不会有这个问题,fmt 安装包路径的配置信息是不是要传递给spdlog

期待的结果

spdlog使用fmt的情况下编译通过

工程配置

add_requires("spdlog v1.13.0", { configs = { header_only = false, fmt_external = true } })

附加信息和错误日志

checking for cmake ... D:\Program Files\CMake\bin\cmake
D:\Program Files\CMake\bin\cmake -DSPDLOG_BUILD_TESTS=OFF -DSPDLOG_BUILD_EXAMPLE=OFF -DSPDLOG_BUILD_SHARED=OFF -DSPDLOG_USE_STD_FORMAT=OFF -DSPDLOG_FMT_EXTERNAL=ON -DSPDLOG_FMT_EXTERNAL_HO=OFF -DSPDLOG_NO_EXCEPTIONS=OFF -DSPDLOG_WCHAR_SUPPORT=OFF -DCMAKE_INSTALL_PREFIX=F:\packages\s\spdlog\v1.13.0\8ed1ed185b0143e89804de2862dc3c49 -DCMAKE_INSTALL_LIBDIR:PATH=lib -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=D:\android-ndk-r26b\build\cmake\android.toolchain.cmake -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=android-26 -DANDROID_NATIVE_API_LEVEL=26 -DCMAKE_MAKE_PROGRAM=D:\android-ndk-r26b\prebuilt\windows-x86_64\bin\make.exe -DCMAKE_POSITION_INDEPENDENT_CODE=ON F:\xmake_global\.xmake\cache\packages\2403\s\spdlog\v1.13.0\source
-- The CXX compiler identification is Clang 17.0.2
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: D:/android-ndk-r26b/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Build spdlog: 1.13.0
-- 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 - not found
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE  
-- Build type: Release
CMake Error at CMakeLists.txt:211 (find_package):
  Could not find a package configuration file provided by "fmt" with any of
  the following names:

    fmtConfig.cmake
    fmt-config.cmake

  Add the installation prefix of "fmt" to CMAKE_PREFIX_PATH or set "fmt_DIR"
  to a directory containing one of the above files.  If "fmt" provides a
  separate development package or SDK, be sure it has been installed.


-- Configuring incomplete, errors occurred!
@guijiyang guijiyang added the bug label Mar 13, 2024
@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Title: spdlog android compilation error

@star-hengxing
Copy link
Contributor

cmake 的 find_package 不稳定,这里估计要 patch 一下 cmake,然后用 packagedeps 的方式传入构建

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


cmake's find_package is unstable. It is estimated that you need to patch cmake and then use packagedeps to pass it into the build.

@guijiyang
Copy link
Contributor Author

cmake 的 find_package 不稳定,这里估计要 patch 一下 cmake,然后用 packagedeps 的方式传入构建
fmt包是用xmake安装的,安装的路径下fmtConfig.cmake相关信息,在Windows下cmake默认的查找路径应该是不包含xmake的路径的,但是spdlog包安装的时候也能使用cmake find_package找到fmtConfig.cmake,这个是不是xmake在哪里传入了fmt包的路径信息给cmake了?

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


cmake's find_package is unstable. It is estimated that you need to patch cmake and then use packagedeps to pass it into the build.
The fmt package is installed with xmake. The information about fmtConfig.cmake is under the installation path. The default search path of cmake under Windows should not include the path of xmake. However, when the spdlog package is installed, you can also use cmake find_package to find fmtConfig.cmake. , is this where xmake passes the path information of the fmt package to cmake?

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


It will be passed here. . https://github.com/xmake-io/xmake/blob/80af97d2fb131d6c8a4eaff114035ecc578499e5/xmake/modules/package/tools/cmake.lua#L811

@guijiyang
Copy link
Contributor Author

这里会传。。https://github.com/xmake-io/xmake/blob/80af97d2fb131d6c8a4eaff114035ecc578499e5/xmake/modules/package/tools/cmake.lua#L811

嗯,我在xmake添加了依赖库路径打印,可以看到Windows和Android都设置了下去。
然后在spdlog 的安装包的cmakelists.txt文件里面添加了打印message(STATUS "CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}"),msvc打印的值为空,Android打印了ndk工具链路径,但是windows可以编译过去,Android却不行。

msvc:

checking for cmake ... D:\Program Files\CMake\bin\cmake
D:\Program Files\CMake\bin\cmake -DSPDLOG_BUILD_TESTS=OFF -DSPDLOG_BUILD_EXAMPLE=OFF -DSPDLOG_BUILD_SHARED=OFF -DSPDLOG_USE_STD_FORMAT=OFF -DSPDLOG_FMT_EXTERNAL=ON -DSPDLOG_FMT_EXTERNAL_HO=OFF -DSPDLOG_NO_EXCEPTIONS=OFF -DSPDLOG_WCHAR_SUPPORT=OFF -DCMAKE_INSTALL_PREFIX=F:\packages\s\spdlog\v1.13.0\32899dd3c7db488c935409d18777b562 -DCMAKE_INSTALL_LIBDIR:PATH=lib -G "Visual Studio 17 2022" -A x64 -DCMAKE_GENERATOR_TOOLSET=v143 -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebugDLL "-DCMAKE_CXX_FLAGS_DEBUG=/MDd /Zi /Ob0 /Od /RTC1" "-DCMAKE_CXX_FLAGS_RELEASE=/MDd /O2 /Ob2 /DNDEBUG" "-DCMAKE_C_FLAGS_DEBUG=/MDd /Zi /Ob0 /Od /RTC1" "-DCMAKE_C_FLAGS_RELEASE=/MDd /O2 /Ob2 /DNDEBUG" -DCMAKE_COMPILE_PDB_OUTPUT_DIRECTORY=pdb -DCMAKE_POSITION_INDEPENDENT_CODE=ON F:\xmake_global\.xmake\cache\packages\2403\s\spdlog\v1.13.0\source
CMAKE_PREFIX_PATH:      F:\packages\f\fmt\10.2.1\76261121e65a4f6fa74ec17b5e3dba9f  #msvc包路径
-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19045.
-- The CXX compiler identification is MSVC 19.35.32216.1
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.35.32215/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Build spdlog: 1.13.0
-- 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 - not found
-- Found Threads: TRUE  
-- Build type:
-- CMAKE_PREFIX_PATH: #cmake里面没有设置,但是怎么找的到fmtconfig.cmake?
-- Generating install
-- Configuring done (2.9s)
-- Generating done (0.0s)
CMake Warning:
  Manually-specified variables were not used by the project:

    CMAKE_C_FLAGS_DEBUG
    CMAKE_C_FLAGS_RELEASE


-- Build files have been written to: F:/xmake_global/.xmake/cache/packages/2403/s/spdlog/v1.13.0/source/build_32899dd3
checking for msbuild.exe ... C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\amd64\msbuild.exe

android:

checking for cmake ... D:\Program Files\CMake\bin\cmake
D:\Program Files\CMake\bin\cmake -DSPDLOG_BUILD_TESTS=OFF -DSPDLOG_BUILD_EXAMPLE=OFF -DSPDLOG_BUILD_SHARED=OFF -DSPDLOG_USE_STD_FORMAT=OFF -DSPDLOG_FMT_EXTERNAL=ON -DSPDLOG_FMT_EXTERNAL_HO=OFF -DSPDLOG_NO_EXCEPTIONS=OFF -DSPDLOG_WCHAR_SUPPORT=OFF -DCMAKE_INSTALL_PREFIX=F:\packages\s\spdlog\v1.13.0\23a656ef58d04e7f8e6f89ca2ba0cc91 -DCMAKE_INSTALL_LIBDIR:PATH=lib -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=D:\android-ndk-r26b\build\cmake\android.toolchain.cmake -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=android-21 -DANDROID_NATIVE_API_LEVEL=21 -DCMAKE_MAKE_PROGRAM=D:\android-ndk-r26b\prebuilt\windows-x86_64\bin\make.exe -DCMAKE_POSITION_INDEPENDENT_CODE=ON F:\xmake_global\.xmake\cache\packages\2403\s\spdlog\v1.13.0\source
CMAKE_PREFIX_PATH:      F:\packages\f\fmt\10.2.1\7def98216fe149a88a59c825d35870c7 #Android包路径
-- The CXX compiler identification is Clang 17.0.2
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: D:/android-ndk-r26b/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Build spdlog: 1.13.0
-- 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 - not found
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE  
-- Build type: Release
-- CMAKE_PREFIX_PATH: D:/android-ndk-r26b/toolchains/llvm/prebuilt/windows-x86_64 
#ndk工具链路径,这个值应该是cmake ndk 工具链设置的吧,也没有fmt安装包的路径
CMake Error at CMakeLists.txt:212 (find_package):
  Could not find a package configuration file provided by "fmt" with any of
  the following names:

    fmtConfig.cmake
    fmt-config.cmake

@star-hengxing
Copy link
Contributor

xmake 是环境变量传进去的,所以 cmake 没输出。
至于 cmake 为什么找不到,咱也不知道

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


xmake is passed in environment variables, so cmake has no output.
As for why cmake can’t be found, we don’t know either.

@guijiyang
Copy link
Contributor Author

xmake 是环境变量传进去的,所以 cmake 没输出。 至于 cmake 为什么找不到,咱也不知道

嗯,我去库作者那边问问,我本地用cmake编译也不行

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


xmake is passed in by environment variables, so cmake has no output. As for why cmake can’t be found, we don’t know either.

Well, I'll ask the library author. It doesn't work if I use cmake to compile locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants