如何在 C++ 的 .so 文件中包含库
How do I include a library in an .so file in C++
我正在尝试编译一个依赖于FTDI库的.so
文件。我不确定如何包含库以使其正确编译。(以下是我最好的猜测(。这是可能的还是有其他方法可以做到的?
shared: pldevice pldeviceenttecpro pluniverse
$(CC) -shared -Wl,-soname,libplanklight.so -o libplanklight.so
-L/usr/local/lib -lftd2xx
pldevice.o pldeviceenttecpro.o pluniverse.o
编辑:这是输出:
g++ -fPIC -c pldevice.cpp
g++ -fPIC -c pldeviceenttecpro.cpp
g++ -fPIC -c pluniverse.cpp
g++ -shared -Wl,-soname,libplanklight.so -o libplanklight.so
-L/usr/local/lib -lftd2xx
pldevice.o pldeviceenttecpro.o pluniverse.o
/usr/bin/x86_64-linux-gnu-ld: cannot open output file libplanklight.so-L/usr/local/lib: No such file or directory
collect2: error: ld returned 1 exit status
Makefile:5: recipe for target 'shared' failed
make: *** [shared] Error 1
你缺少一个空格。
$(CC) -shared -Wl,-soname,libplanklight.so -o libplanklight.so
^^
Add a space here
\ 只是使命令在下一行继续,所以当你有
-o libplanklight.so
-L/usr/local/lib
它将与-o libplanklight.so-L/usr/local/lib
相同
但你想要-o libplanklight.so -L/usr/local/lib
相关文章:
- 实验性文件系统库不完整C++?
- CMake:我们可以为一组不形成可执行文件或库的特定文件指定包含目录吗?
- 无法链接文件系统库C++
- 读取大文件(>2GB)(文本文件包含以太网数据)并通过不同参数随机访问数据的最佳方法是什么?
- 如何在 C++ 的 .so 文件中包含库
- CMake 如何强制third_party库将项目文件包含在当前项目源目录中?
- cmake 可以包含具有头文件和库文件但没有 .cmake 文件的库吗?
- 在 C++ 中包含库数据库.txt文件时出错
- 修改生成文件以包含库并使用 C++11
- 忽略来自 GDB(终端)中的包含/库文件的调试消息
- 在标题文件和CPP文件中都包含库
- Qt C++:将所有库文件包含在项目文件夹中
- 有没有一种简单的方法可以将库文件包含在MSVC中
- 在.cpp文件中包含库时
- 自定义头文件和包含库[C++]
- 如何重定向头文件(到库)以在实例化中包含一些代码
- 在c++中添加包含多个文件的库
- 包含库的c++运行文件失败而没有编译错误(CMake / CLion)
- 如何告诉Visual Studio包含库的.cpp文件?
- 如何处理和包含头文件和库,以便在不同的机器上构建Visual Studio 2010解决方案