Symbol'' has different size in shared object,consider re-linking

Symbol'' has different size in shared object,consider re-linking

我是在EclipseCDT链接mongo数据库时出现这个问题,详细介绍如下

这个提示基本上是是因为链接库出了问题,于是打开lib库发现libmongoclient.so文件已经消失,只有libmongoclient.so.bak备份文件,可能就是因为找不到.so链接库才会有以上提示,于是复制libmongoclient.so.bak然后重命名去掉.bak继续操作发现还是这个提示,估计是生成的.bak文件是加密的无法通过直接修改后缀改编,需要原来的.so文件,但是.so文件已经消失了,找不到了,所以只能找到以前装libmongoclient.so的父文件夹或者压缩包,然后重新复制一个libmongoclient.so进lib库,之后ldconfig一下,问题解决了。

To link a C++ shared library, you need to follow these steps: 1. Compile your C++ code into an object file using the `-c` flag. For example, if your C++ code is in a file called `mylibrary.cpp`, you would run the following command: `g++ -c -fPIC mylibrary.cpp` The `-fPIC` flag is necessary to generate Position Independent Code, which is needed for shared libraries. 2. Link the object file into a shared library using the `-shared` flag. For example, if your object file is called `mylibrary.o`, you would run the following command: `g++ -shared -o libmylibrary.so mylibrary.o` The `-o` flag specifies the output file name, and the `.so` extension is used for shared libraries on Linux. 3. Include the shared library in your project by specifying the library name and location in your build system. For example, if you are using CMake, you would add the following lines to your `CMakeLists.txt` file: ``` add_library(mylibrary SHARED IMPORTED) set_target_properties(mylibrary PROPERTIES IMPORTED_LOCATION /path/to/libmylibrary.so) ``` This tells CMake to import the `mylibrary` shared library and set its location to `/path/to/libmylibrary.so`. 4. Use the functions and classes defined in the shared library in your code by including the appropriate header files and linking against the library. For example, if your library defines a function called `myfunction`, you would include its header file and link against the library like this: ``` #include "mylibrary.h" ... myfunction(); ``` And in your build system, you would specify the library as a dependency: ``` target_link_libraries(myprogram mylibrary) ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值