gpt4 book ai didi

c++ - 我尝试使用 cmake 来制作项目,但它调用了一个错误 ld: library not found for -levmc::loader

转载 作者:行者123 更新时间:2023-12-05 06:47:33 27 4
gpt4 key购买 nike

我 git 克隆了一个名为 evmc 的项目在 github 上。

我尝试通过 cmake 在这个项目中构建 example 文件夹。但是这里有一些错误叫做:

使用 cmake .

-- Configuring done
CMake Error at CMakeLists.txt:23 (add_executable):
Target "evmc-example" links to target "evmc::evmc_cpp" but the target was
not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?


CMake Error at CMakeLists.txt:23 (add_executable):
Target "evmc-example" links to target "evmc::loader" but the target was not
found. Perhaps a find_package() call is missing for an IMPORTED target, or
an ALIAS target is missing?


CMake Error at CMakeLists.txt:19 (add_executable):
Target "evmc-example-static" links to target "evmc::evmc_cpp" but the
target was not found. Perhaps a find_package() call is missing for an
IMPORTED target, or an ALIAS target is missing?


CMake Error at CMakeLists.txt:19 (add_executable):
Target "evmc-example-static" links to target "evmc::evmc" but the target
was not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?


CMake Error at CMakeLists.txt:19 (add_executable):
Target "evmc-example-static" links to target "evmc::evmc" but the target
was not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?


CMake Error at CMakeLists.txt:16 (add_library):
Target "evmc-example-host" links to target "evmc::evmc_cpp" but the target
was not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?


CMake Error at example_vm/CMakeLists.txt:10 (add_library):
Target "example-vm-static" links to target "evmc::evmc" but the target was
not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?


CMake Error at example_vm/CMakeLists.txt:5 (add_library):
Target "example-vm" links to target "evmc::evmc" but the target was not
found. Perhaps a find_package() call is missing for an IMPORTED target, or
an ALIAS target is missing?


CMake Error at example_precompiles_vm/CMakeLists.txt:10 (add_library):
Target "example-precompiles-vm-static" links to target "evmc::evmc" but the
target was not found. Perhaps a find_package() call is missing for an
IMPORTED target, or an ALIAS target is missing?


CMake Error at example_precompiles_vm/CMakeLists.txt:5 (add_library):
Target "example-precompiles-vm" links to target "evmc::evmc" but the target
was not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?


-- Generating done
CMake Generate step failed. Build files cannot be regenerated correctly.
make: *** [cmake_check_build_system] Error 1

使用make

Consolidate compiler generated dependencies of target evmc-example-host
[ 14%] Built target evmc-example-host
Consolidate compiler generated dependencies of target evmc-example
[ 21%] Linking CXX executable evmc-example
ld: library not found for -levmc::loader
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [evmc-example] Error 1
make[1]: *** [CMakeFiles/evmc-example.dir/all] Error 2
make: *** [all] Error 2

这是我的 CMakeLists:

# EVMC: Ethereum Client-VM Connector API.
# Copyright 2016-2019 The EVMC Authors.
# Licensed under the Apache License, Version 2.0.

cmake_minimum_required(VERSION 3.13)

set (CMAKE_C_COMPILER /usr/bin/clang)
set (CMAKE_CXX_COMPILER /usr/bin/clang++)
set (CMAKE_CXX_STANDARD 17)

include(GNUInstallDirs)

add_subdirectory(example_vm)
add_subdirectory(example_precompiles_vm)

add_library(evmc-example-host STATIC example_host.cpp)
target_link_libraries(evmc-example-host PRIVATE evmc::evmc_cpp)

add_executable(evmc-example-static example.c)
target_link_libraries(evmc-example-static PRIVATE evmc-example-host evmc::example-vm-static evmc::evmc)
target_compile_definitions(evmc-example-static PRIVATE STATICALLY_LINKED_EXAMPLE)

add_executable(evmc-example example.c)
target_link_libraries(evmc-example PRIVATE evmc-example-host evmc::loader)

include_directories(../include)

这是我的项目结构:

evmc
├── AUTHORS.md
├── CHANGELOG.md
├── CMakeCache.txt
├── CMakeLists.txt
├── CNAME
├── CPackConfig.cmake
├── CPackSourceConfig.cmake
├── Cargo.lock
├── Cargo.toml
├── Doxyfile
├── LICENSE
├── Makefile
├── README.md
├── appveyor.yml
├── bindings
│ ├── go
│ ├── java
│ └── rust
├── build
│ ├── CMakeCache.txt
│ ├── CMakeFiles
│ ├── CPackConfig.cmake
│ ├── CPackSourceConfig.cmake
│ ├── Makefile
│ ├── cmake_install.cmake
│ ├── evmcConfig.cmake
│ ├── evmcConfigVersion.cmake
│ └── lib
├── circle.yml
├── cmake
│ ├── Config.cmake.in
│ ├── EVMC.cmake
│ ├── Hunter
│ └── cable
├── cmake_install.cmake
├── codecov.yml
├── docs
│ ├── EVMC.md
│ ├── Host_Guide.md
│ ├── VM_Guide.md
│ ├── VM_Tester.md
│ └── custom.dox
├── evmcConfig.cmake
├── evmcConfigVersion.cmake
├── examples
│ ├── CMakeCache.txt
│ ├── CMakeFiles
│ ├── CMakeLists.txt
│ ├── Makefile
│ ├── build
│ ├── cmake_install.cmake
│ ├── example-rust-vm
│ ├── example.c
│ ├── example_host.cpp
│ ├── example_host.h
│ ├── example_precompiles_vm
│ ├── example_vm
│ ├── libevmc-example-host.a
│ ├── use_evmc_in_cmake
│ └── use_instructions_in_cmake
├── go.mod
├── include
│ └── evmc
├── lib
│ ├── CMakeFiles
│ ├── CMakeLists.txt
│ ├── Makefile
│ ├── cmake_install.cmake
│ ├── hex
│ ├── instructions
│ ├── loader
│ └── mocked_host
├── target
│ ├── CACHEDIR.TAG
│ └── debug
├── test
│ ├── CMakeLists.txt
│ ├── cmake_package
│ ├── compilation
│ ├── examples
│ ├── gomod
│ ├── tools
│ ├── unittests
│ └── vmtester
└── tools
├── CMakeLists.txt
├── commands
├── evmc
├── utils
└── vmtester

我已经升级了我在这个项目中使用的所有工具:clang、cmake...

但是还是不能正常运行,怎么办?

最佳答案

这发生在我身上是因为我用于库的路径不正确,它没有指向包含 CMakeLists.txt 的目录。

我在我的顶级 CMakeLists.txt 中使用 FetchContent 包含 cpr,并意外地将 FETCHCONTENT_SOURCEDIR_CPR 设置为上面的级别。我在 cpr/cpr-master 中有 cpr 的源代码,但只是将它设置为 cpr。

更笼统地回答,这意味着 evmc 的路径可能不正确。

关于c++ - 我尝试使用 cmake 来制作项目,但它调用了一个错误 ld: library not found for -levmc::loader,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67074331/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com