在CLion中使用libbitcoin [英] Use libbitcoin in CLion

查看:169
本文介绍了在CLion中使用libbitcoin的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不是C ++程序员,只是前一阵子.使用自制软件,我安装了libbitcoin并希望可以像引用增强库一样引用该库.我还意识到/usr/local/bin中没有到地窖的链接. 我想我可以通过使用绝对路径来使它正常工作,但我正在寻找正确处理刚刚提到的星座的方法.

I am not a C++ programmer, only have made a course a while ago. Using homebrew I installed libbitcoin and was hoping that I can reference the library like I was able to reference the boost libraries. I also realized that there are no links in /usr/local/bin to the Cellar. I think I could get it working by using the absolute paths but I am looking for the proper way of handling this constellation that I just mentioned.

当前CMake:

cmake_minimum_required(VERSION 2.8.4)

project(cplusplus)

message(STATUS "start running cmake...")

find_package(boost 1.65.1 COMPONENTS system filesystem REQUIRED)
find_package(libbitcoin 3.3.0 COMPONENTS system filesystem REQUIRED)

message("system: ${CMAKE_SYSTEM_PREFIX_PATH}")
find_library(LIB_BITCOIN libbitcoin)
message("bitcoin: ${LIB_BITCOIN}")

if(Boost_FOUND)
    message(STATUS "Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}")
    message(STATUS "Boost_LIBRARIES: ${Boost_LIBRARIES}")
    message(STATUS "Boost_VERSION: ${Boost_VERSION}")
    include_directories(${Boost_INCLUDE_DIRS})
 endif()

 add_executable(cplusplus main.cpp)

 if(Boost_FOUND)
     target_link_libraries(cplusplus ${Boost_LIBRARIES})
 endif()

目前,我收到以下错误消息:

Currently I get these errors:

/Applications/CLion.app/Contents/bin/cmake/bin/cmake -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - Unix Makefiles" /Users/johndow/Documents/Workspace/bitcoin-code/cplusplus
-- start running cmake...
-- Boost version: 1.65.1
CMake Error at CMakeLists.txt:8 (find_package):
  By not providing "Findlibbitcoin.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "libbitcoin", but CMake did not find one.

  Could not find a package configuration file provided by "libbitcoin"
  (requested version 3.3.0) with any of the following names:

  libbitcoinConfig.cmake
  libbitcoin-config.cmake

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


-- Configuring incomplete, errors occurred!
See also "/Users/johndoe/Documents/Workspace/bitcoin-code/cplusplus/cmake-build-debug/CMakeFiles/CMakeOutput.log".

[Finished]

推荐答案

据我所知,当前libbitcoin 不会导出任何<libbitcoin>Config.cmake程序包.

As far as I know, currently libbitcoin does not export any <libbitcoin>Config.cmake package.

但是它会导出libbitcoin.pc文件供pkg-config通用使用.

But it does export a libbitcoin.pc file for generic use with pkg-config.

即:/usr/local/lib/pkgconfig/libbitcoin.pc

如果您通过调用pkg-config --cflags libbitcoin获得结果,那么它就在那里.

If you get results from invoking pkg-config --cflags libbitcoin then it's there.

然后您可以在CMakeLists.txt中放入这样的内容:

And then you can put something like this in your CMakeLists.txt:

#use this if libbitcoin is installed to some custom location
set(ENV{PKG_CONFIG_PATH} "/path/to/libbitcoin/pkgconfig/:$ENV{PKG_CONFIG_PATH}")

#then later..
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIB_BITCOIN REQUIRED libbitcoin) 

#then later..
target_link_libraries(${PROJECT_NAME} PRIVATE ${LIB_BITCOIN_LIBRARIES})
target_include_directories(${PROJECT_NAME} PRIVATE ${LIB_BITCOIN_INCLUDE_DIRS})

应该插入boost,使libbitcoin includes可见并解决编译器和链接器问题的所有方式.

That should pull in boost, make the libbitcoin includes visible and solve all manner of compiler and linker woes.

(或者,如果您感到生气,可以随时使用此要点)

(Or if you are feeling mad, you could always make use of this gist).

这篇关于在CLion中使用libbitcoin的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆