简体   繁体   English

cmake项目生成错误,共享库与另一个依赖

[英]cmake project build error, shared library with a dependency on another

I'm building a project that uses cmake. 我正在建立一个使用cmake的项目。

The project uses three shared libraries .so files. 该项目使用三个共享库.so文件。

In the CMakeLists.txt file I've added the these lines which link the shared libraries to the executable. 在CMakeLists.txt文件中,我添加了以下行,这些行将共享库链接到可执行文件。

project (lwm2mclient)

LINK_DIRECTORIES(/home/mraa-master-built/build/src)
LINK_DIRECTORIES(/home/libi2capi)
LINK_DIRECTORIES(/home/libtca6424a)
target_link_libraries (lwm2mclient libmraa.so m libi2capi.so libtca6424a.so) 

However, one of the shared libraries libtca6424a.so depends on libi2capi.so ie it uses methods that are defined in it. 但是,共享库libtca6424a.so取决于libi2capi.so即它使用其中定义的方法。

So when I'm building the cmake project I get an error like this saying that the .so file cannot find the method which is defined in the other .so file libtca6424a.so . 因此,当我构建cmake项目时,出现这样的错误,即.so文件找不到其他.so文件libtca6424a.so定义的方法。

Could somebody suggest a solution? 有人可以提出解决方案吗?

/../../lib/libtca6424a.so: undefined reference to `i2c_write_byte_data' 

Please try 请试试

target_link_libraries (-Wl,--start-group lwm2mclient libmraa.so m libi2capi.so libtca6424a.so -Wl,--end-group)

or change the order of the libraries 或更改库的顺序

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM