vcpkg使用记录


vcpkg工具使用记录

1、使用技巧

  • 在Windows 10中按住shift+右键,可以在当前目录打开power shell
  • 在命令行中设置代理,如此类似即可
$env:HTTP_PROXY="http://127.0.0.1:10809"
$env:HTTPS_PROXY="http://127.0.0.1:10809"
  • vcpkg工具使用时,下载缓慢,可以手动下载,然后放到downloads目录中。注意文件改名,可在temp目录中查看需要更改的名字
  • vcpkg可以只下载不编译,需添加 --only-downloads
  • vcpkg search >> supportLibs.txt,将当前支持安装的库信息放入文件 supportLibs.txt中,方便查看

2、导出相关库命令

vcpkg export xxlib:x64-windows --raw
vcpkg export xxlib:x64-windows --zip
vcpkg export xxlib:x64-windows --7zip

3、vcpkg生成库的使用

  • 在CMakeLists.txt中添加CMAKE_TOOLCHAIN_FILE变量,例如:
set(CMAKE_TOOLCHAIN_FILE  "xxx/scripts/buildsystems/vcpkg.cmake")

# 相关样板,可做参考
find_package(Ceres CONFIG REQUIRED)
target_link_libraries(main PRIVATE ceres)

find_package(CGAL CONFIG REQUIRED)
target_link_libraries(main PRIVATE CGAL::CGAL)

find_package(libusb CONFIG REQUIRED)
target_include_directories(main PRIVATE ${LIBUSB_INCLUDE_DIRS})
target_link_libraries(main PRIVATE ${LIBUSB_LIBRARIES})

find_package(OpenBLAS CONFIG REQUIRED)
target_link_libraries(main PRIVATE OpenBLAS::OpenBLAS)

find_path(NETHOST_INCLUDE_DIRS nethost.h)
find_library(NETHOST_LIBRARY NAMES libnethost nethost)
target_include_directories(main PRIVATE ${NETHOST_INCLUDE_DIRS})
target_link_libraries(main PRIVATE ${NETHOST_LIBRARY})

4、安装信息记录

  • 2020.11.21
opencv 4.3.0: .\vcpkg.exe install opencv4[contrib,cuda,dnn,eigen,ipp,jasper,jpeg,opengl,openmp,png,qt,tbb,vtk]:x64-windows
pcl 1.11.1: .\vcpkg.exe install pcl[cuda,qt,vtk]:x64-windows
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
vcpkg使用的无锁队列是一个基于 CAS (Compare and Swap) 操作的实现,它的实现位于 vcpkg 的 `include/vcpkg/fwdlock.h` 头文件中。 无锁队列的实现使用C++11 中的 `std::atomic` 类型,它支持原子操作,并且可以避免多线程访问时的竞争问题。在无锁队列中,每个节点包含一个数据项和一个指向下一个节点的指针,节点的插入和删除操作都是通过原子 CAS 操作来实现的。 无锁队列的代码示例: ```c++ template <typename T> class fwdlock { public: fwdlock() : head_(nullptr), tail_(nullptr) {} void push(T data) { node* n = new node(std::move(data)); node* t = tail_.load(std::memory_order_relaxed); do { n->next_ = t; } while (!tail_.compare_exchange_weak(t, n, std::memory_order_release, std::memory_order_relaxed)); } bool try_pop(T& data) { node* h = head_.load(std::memory_order_relaxed); node* t = tail_.load(std::memory_order_acquire); if (h == t) { return false; } node* next = h->next_; data = std::move(next->data_); head_.store(next, std::memory_order_release); delete h; return true; } private: struct node { T data_; node* next_; node(T data) : data_(std::move(data)), next_(nullptr) {} }; std::atomic<node*> head_; std::atomic<node*> tail_; }; ``` 在上述代码中,`fwdlock` 类实现了无锁队列的 push 和 try_pop 操作,其中 push 操作使用了 `compare_exchange_weak` 原子操作,try_pop 操作使用了 `load` 和 `store` 原子操作。使用无锁队列可以有效减少多线程并发访问时的竞争和锁等待,从而提高代码的性能和可伸缩性。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值