相关疑难解决方法(0)

如何在linux上为c ++创建动态库?

我想在linux上为c ++程序创建一个动态库.在c ++程序/系统中,我使用libconfig ++库,libpqxx库,一些boost和c ++ 11.

我的步骤:1)

g++ -Wall -I/usr/local/include/ -std=c++0x -lconfig++ -Wall -lpqxx -lpq -fPIC -c ../SourceFiles/DBHandler.cpp ../SourceFiles/ParamServer.cpp ../SourceFiles/Functions.cpp
Run Code Online (Sandbox Code Playgroud)

2)

g++ -shared -Wl,-soname,libctest.so.1 -o libctest.so.1.0   *.o
Run Code Online (Sandbox Code Playgroud)

3)

ln -sf libctest.so.1.0 libctest.so.1
Run Code Online (Sandbox Code Playgroud)

4)

ln -sf libctest.so.1.0 libctest.so
Run Code Online (Sandbox Code Playgroud)

5)编译

g++ -Wall -I/path/to/include-files -L/path/to/libraries program.cpp -I/usr/local/include/ -std=c++0x -lconfig++ -lpqxx -lpq -lctest -o prog
Run Code Online (Sandbox Code Playgroud)

执行上面的命令后:

/usr/bin/ld: cannot find -lctest
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

以下是参考: 在此处输入链接描述

c++ boost dynamic-linking dynamic-library c++11

0
推荐指数
1
解决办法
450
查看次数

标签 统计

boost ×1

c++ ×1

c++11 ×1

dynamic-library ×1

dynamic-linking ×1