openbmc / docs

OpenBMC Documentation
Creative Commons Attribution 4.0 International
279 stars 307 forks source link

Hello world example ERROR Dependency 'fmt' is required but not found. #78

Closed Evanfan007 closed 2 years ago

Evanfan007 commented 2 years ago

Hi, I'm NEW to openbmc, and I met a problem that confused me when I tried to build an openbmc application "Hello world" and I have spent a lot time on it. I thought I have found where the problem is but I can't solve it. It seemed that the fmt subproject didn't build successfully.Could you help me?

INFO

OS:Ubuntu 20.04.1 Cmake version: 3.24.3 Meson version: 0.63.3

PROBLEM

when I run meson build command, the output of the fmt Cmake seemed normal, but the process failed in the and and report that

WARNING: Subproject 'fmt' did not override 'fmt' dependency and no variable name specified
Dependency fmt from subproject subprojects/fmt found: NO

meson.build:86:0: ERROR: Dependency 'fmt' is required but not found.

but the previous log showed that the fmt had been build successfully. The log:

stdplus| Run-time dependency threads found: YES
stdplus| Run-time dependency fmt found: NO (tried pkgconfig and cmake)
stdplus| Using subprojects/sdeventplus/subprojects/fmt.wrap
stdplus| WARNING: Subproject fmt's revision may be out of date; its wrap file has changed since it was first configured

Executing subproject sdeventplus:stdplus:fmt method cmake

| Configuring the build directory with CMake version 3.24.3
| Running CMake with: -G Ninja -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DMASTER_PROJECT=OFF
|   - build directory:          /home/xxxxx/Desktop/OpenBMC/code/phosphor-state-manager/build/subprojects/fmt/__CMake_build
|   - source directory:         /home/xxxxx/Desktop/OpenBMC/code/phosphor-state-manager/subprojects/fmt
|   - toolchain file:           /home/xxxxx/Desktop/OpenBMC/code/phosphor-state-manager/build/subprojects/fmt/__CMake_build/CMakeMesonToolchainFile.cmake
|   - preload file:             /home/xxxxx/Desktop/OpenBMC/code/phosphor-state-manager/build/meson-private/data/preload.cmake
|   - trace args:               --trace-expand --trace-format=json-v1 --no-warn-unused-cli --trace-redirect=cmake_trace.txt
|   - disabled policy warnings: [CMP0025, CMP0047, CMP0056, CMP0060, CMP0065, CMP0066, CMP0067, CMP0082, CMP0089, CMP0102]

| Running with expanded trace output on.
| Not searching for unused variables given on the command line.
| Trace will be written to cmake_trace.txt
| -- CMake version: 3.24.3
| -- The CXX compiler identification is GNU 9.4.0
| -- Detecting CXX compiler ABI info
| -- Detecting CXX compiler ABI info - done
| -- Check for working CXX compiler: /usr/bin/c++ - skipped
| -- Detecting CXX compile features
| -- Detecting CXX compile features - done
| -- Module support is disabled.
| -- Version: 9.1.1
| -- Build type: Release
| -- CXX_STANDARD: 11
| -- Performing Test has_std_11_flag
| -- Performing Test has_std_11_flag - Success
| -- Performing Test has_std_0x_flag
| -- Performing Test has_std_0x_flag - Success
| -- Required features: cxx_variadic_templates
| -- Target 'doc' disabled (requires doxygen)
| -- 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
| -- Performing Test HAVE_FNO_DELETE_NULL_POINTER_CHECKS
| -- Performing Test HAVE_FNO_DELETE_NULL_POINTER_CHECKS - Success
| -- FMT_PEDANTIC: OFF
| -- Configuring done
| -- Generating done
| -- Build files have been written to: /home/xxxxx/Desktop/OpenBMC/code/phosphor-state-manager/build/subprojects/fmt/__CMake_build

fmt| CMake configuration: SUCCEEDED
fmt| CMake project FMT has 24 build targets.

cmake-ast| Processing generated meson AST
cmake-ast| Build file: /home/xxxxx/Desktop/OpenBMC/code/phosphor-state-manager/build/subprojects/fmt/meson.build

fmt| Project name: FMT
fmt| Project version: undefined
fmt| C compiler for the host machine: cc (gcc 9.4.0 "cc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0")
fmt| C linker for the host machine: cc ld.bfd 2.34
fmt| C++ compiler for the host machine: c++ (gcc 9.4.0 "c++ (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0")
fmt| C++ linker for the host machine: c++ ld.bfd 2.34
fmt| Build targets in project: 28
fmt| Subproject fmt finished.
eli-schwartz commented 2 years ago

This is coming from https://github.com/openbmc/stdplus/blob/f2ddf51fd19fde81e44607bac5cd0370adef351f/src/meson.build#L2-L14

I believe it is a bug in the stdplus project, because it should not use cmake to build the fmt library -- simply use https://wrapdb.mesonbuild.com/ to acquire the fmt wrap, which includes a native meson version that does proper dependency fallbacks. In your example "hello world" application, can you try to:

Evanfan007 commented 2 years ago

This is coming from https://github.com/openbmc/stdplus/blob/f2ddf51fd19fde81e44607bac5cd0370adef351f/src/meson.build#L2-L14

I believe it is a bug in the stdplus project, because it should not use cmake to build the fmt library -- simply use https://wrapdb.mesonbuild.com/ to acquire the fmt wrap, which includes a native meson version that does proper dependency fallbacks. In your example "hello world" application, can you try to:

  • clean old versions from subprojects/
  • run meson wrap install fmt
  • re-try the build

Thanks a lot! I solved the problem according to your answer. Besides, the cereal package has the same problem and was been solved by the same way. But I met another problem which is mentioned in https://github.com/openbmc/docs/issues/76. thank you!