On Mon, Jul 25, 2022 at 2:29 PM Ilya Maximets <[email protected]> wrote: > > Current version of debian/rules simply passes the libopenvswitch.a > as a command line argument via LDFLAGS, but that doesn't actually > lead to this library being statically linked into python extension, > which is a shared library. Instead, the build "succeeds", but the > resulted extension is not usable, because most of the symbols are > missing: > > from ovs import _json > > ImportError: > /usr/lib/python3/dist-packages/ovs/_json.cpython-310-x86_64-linux-gnu.so: > undefined symbol: json_parser_finish > > '-lopenvswitch' with a path to a static library should be passed > instead to make it actually statically linked. But even that is not > enough as all the libraries that libopenvswitch.a was built with also > has to be passed. Otherwise, we'll have unresolved symbols like ssl, > cap-ng, etc. > > The most convenient way to get all the required libraries and cflags > seems to be by using pkg-config. > > Setting several environment variables for pkg-config, so it can find > the libopenvswitch.pc in non-standard directory, not skip default > locations and also report them with the right base directory. > > Extra '-Wl,-Bstatic -lopenvswitch -Wl,-Bdynamic' is added before all > the libs to ensure static linking of libopenvswitch even if the > dynamic library is available in a system.
Did you consider the simple :filename form to tell ld to link an archive? Here that would translate to a simple -l:libopenvswitch.a This is only a suggestion to avoid adding too many -Wl options as they stack up if you are not careful. > > One more problem here is that it is not possible to link static > library into dynamic library if the static one is not position > independent. So, we have to build everything with -fPIC, otherwise > it's not possible to build C extensions. > > Also added a simple CI script to check that we're able to use python > C extension after installing a package. -- David Marchand _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
