Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ubuntu怎么链接带版本号的三方库? #895

Open
Tracker647 opened this issue Sep 7, 2024 · 1 comment
Open

ubuntu怎么链接带版本号的三方库? #895

Tracker647 opened this issue Sep 7, 2024 · 1 comment

Comments

@Tracker647
Copy link

在ubuntu20.04上编译项目,项目需要用到poco库。

步骤一:下载Poco库(我用版本为1.9.4),根据其README,./configure然后make, make install, 得到编译的二进制库:

./configure --prefix=/my/path/3rdparty/ubuntu/poco-1.9.4 \
      --shared --static --no-tests --no-samples --no-ipv6 \
      --include-path=/my/path/3rdparty/ubuntu/openssl-1.1.1w/include/ \
      --library-path=/my/path/3rdparty/ubuntu/openssl-1.1.1w/lib \
      --omit=Data/ODBC,Data/MySQL
make
make install

步骤二:
在项目根据按照如何引用第三方库的教程编写SConstruct,把用到的库的lib都改成了bin文件名,因为so库都是在lib下

DEPENDS_LIBS = CUSTOM_WIDGET_LIBS + [
  {
        'root' : '3rd/poco-1.9.4/',
        'shared_libs' : ['PocoFoundation', 'PocoUtil', 'PocoXML', 'PocoJSON', 'PocoCrypto', 'PocoNet', 'PocoNetSSL']
    }
]

ARGUMENTS['WITH_MVVM'] = 'true'
helper = app.Helper(ARGUMENTS)

APP_SRC = os.path.normpath(os.path.join(os.getcwd(), 'src'))
THIRD_PARTY_SRC = os.path.normpath(os.path.join(os.getcwd(), '3rd'))
APP_CPPPATH = [
  os.path.join(APP_SRC, 'common'),
  os.path.join(APP_SRC, 'view_models'),
  os.path.join(APP_SRC, 'pages'),
  os.path.join(THIRD_PARTY_SRC, 'poco-1.9.4/include')
]

CXXFLAGS = '-std=c++11'

helper.set_deps(DEPENDS_LIBS).add_cpppath(APP_CPPPATH).add_cxxflags(CXXFLAGS).call(DefaultEnvironment)

SConscriptFiles = ['src/SConscript', 'tests/SConscript']
helper.SConscript(SConscriptFiles)

步骤三,scons编译,编译成功,但是bin/demo显示error while loading shared libraries: libPocoFoundation.so.64: cannot open shared object file: No such file or directory, 看来是不接受软链接,但是Sconstruct脚本里好像固定写死了只能取libxxx.so的xxx了,只能手动把用到的库CV到bin, 不知道有后缀名的情况有没有更好的,自动化的处理办法?

@xianjimli
Copy link
Member

创建一个符号链接。libxxx.so --> libxxx.so.xx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants