c++ - 在新的 Cmake 项目中使用 OPCUA 库
问题描述
这一次,我想使用Freeopcua创建一个库以在其他项目中使用。
我已经在debian.soft
文件中安装了所有工具,并使用以下命令构建了sudo sh build.sh
, cmake .
, make
, sudo make install
. 虽然在目录/usr/local/include
和中分别/usr/local/lib
有opc
目录和libopc*.so
,但是当我创建一个新的 cmake 项目时,会出现错误。希望有人可以帮助我或提出一些建议。谢谢大家~~~
我参考了 /usr/local/lib not found中的库,但它对我不起作用
CMakeLists.txt
cmake_minimum_required(VERSION 2.8.12)
project(OPCUAIndependent)
include_directories(/usr/local/include/)
link_directories(/usr/local/lib/)
add_executable(sourceCode sourceCode.cpp)
target_link_libraries(sourceCode opc)
错误
[ 50%] Linking CXX executable sourceCode
/usr/bin/ld: cannot find -lopc
collect2: error: ld returned 1 exit status
CMakeFiles/sourceCode.dir/build.make:96: recipe for target 'sourceCode' failed
make[2]: *** [sourceCode] Error 1
CMakeFiles/Makefile2:82: recipe for target 'CMakeFiles/sourceCode.dir/all' failed
make[1]: *** [CMakeFiles/sourceCode.dir/all] Error 2
Makefile:90: recipe for target 'all' failed
make: *** [all] Error 2
解决方案
推荐阅读
- javascript - 我收到“document.getElementById(...) is null”消息错误,不知道为什么
- css - 响应地同时调整图像和背景图像的大小
- python - 使用 Python 获取 MPD 视频流
- c# - 在 MVC 应用程序中使用 OAuth
- azure - Azure Graph API 邀请返回 400 Bad Request
- javascript - JavaScript 类方法不反映字段值
- python - 应用字典查找功能来比较熊猫数据框列
- rust - Serde bincode 自定义反序列化方案
- vue.js - 设置 vuejs devserver.proxy 以避免 CORS 错误
- python - 如何在一页上使用 3 个单独的过滤器?