Deploying C app that uses the PCRE library

前端 未结 3 820
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-21 09:32

I wrote a C app that uses the PCRE library. Everything works on my own computer. However, when I copy the binary over to another computer and run it, it gives the following erro

3条回答
  •  一向
    一向 (楼主)
    2021-01-21 10:07

    As @hacker said, you either have to ensure that you install PCRE on the target machine or you have to use a static library (libpcre.a instead of libpcre.so) on the development machine. That might also mean you need to build PCRE with a static library, and you'd have to use the correct compile time options to pull in the static library. One relatively easy way to do it is to specify /usr/lib/libpcre.a on the compiler command line. Ideally, you'd avoid including -lpcre on the command line too - certainly, you'd want the static library to appear ahead of the shared library.

    Your copy may have failed because of issues with symlinks. You usually link to a file such as:

    /usr/lib/libpcre.so
    

    but that is a symlink to a versioned library such as:

    /usr/lib/libpcre.so.0
    

    Or it could work the other way around. If you were using tar to copy things, you may have copied a symlink.

    Ideally, you install PCRE in a system directory - but doing that requires root privileges. You also have to be careful to ensure that you don't overwrite a more recent version of PCRE with your older version. You also want to avoid forcing users into setting the LD_LIBRARY_PATH environment variable (or its equivalents), or forcing them to use the configuration program (ld.so.conf?).

提交回复
热议问题