V
V
Vadim Ushakov2021-08-14 15:53:28
linux
Vadim Ushakov, 2021-08-14 15:53:28

The linker does not find the required function in the library, why?

The library containing the exec function.

[email protected]:~/workspace/cpp.machinarium$ readelf -Ws /usr/lib/i386-linux-gnu/libboost_python.so | grep exec
369: 543 00034820 FUNC GLOBAL DEFAULT 12 _ZN5boost6python14exec_statementENS0_3strENS0_3api6objectES3_
394: 543 00034600 FUNC GLOBAL DEFAULT 12 _ZN5boost6python4execENS0_3strENS0_3api6objectES3_
756: 00034a40 1241 FUNC GLOBAL DEFAULT 12 _ZN5boost6python9exec_fileENS0_3strENS0_3api6objectES3_


Fragment of the release makefile.
RESCOMP = windres
TARGETDIR = bin/Release
TARGET = $(TARGETDIR)/licenses
OBJDIR = obj/Release/licenses
DEFINES += -DNDEBUG
INCLUDES += -I/usr/include/python3.9 -Ideps -Ideps/cpython/PC - ideps/gmod-module-base/include
FORCE_INCLUDE +=
ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -O2 -Wall -Wextra -m32 -O3
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -O2 -Wall -Wextra -m32 -O3
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
LIBS += -lboost_system -lboost_filesystem -lpthread -lssl - lcpprest -lcrypto++ -lcrypto -ldl -lcryptopp -lpython3.5m -lboost_python -lboost_python-py27 -lpython2.7
LDDEPS +=
ALL_LDFLAGS += $(LDFLAGS) -Ldeps/cryptopp -Llibs -s -pthread
LINKCMD = $(CXX) -o "[email protected]" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
endef
define PRELINKCMDS
endef
define POSTBUILDCMDS
endef


Construction process.
[email protected]:~/workspace/cpp.machinarium$ premake5 gmake && make config=release
Building configurations...
Running action 'gmake'...
Done (655ms).
==== Building licenses (release) ====
Linking licenses
obj/Release/licenses/lib_globals.o: In function `shared_object_desctructor()':
lib_globals.cpp:(.text.exit+0x89): undefined reference to ` boost::python::exec(char const*, boost::python::api::object, boost::python::api::object)'
obj/Release/licenses/net.o: In function `Machinarium: :net_utils::GetCurrentIpAddressRemotelyGlobal[abi:cxx11](bool)':
net.cpp:(.text+0x11fe): undefined reference to `web::http::client::http_client::~http_client()'
obj/Release/licenses/net.o: In function `Machinarium::net_utils::GetCurrentIpAddressRemotelyGlobal[abi:cxx11](bool) [clone .cold]':
net.cpp:(.text.unlikely+0x28e): undefined reference to `web::http::client::http_client::~http_client()'
collect2: error: ld returned 1 exit status
licenses.make:94: recipe for target 'bin/Release/licenses' failed
make[1]: *** [bin/Release/licenses] Error 1
Makefile:30: recipe for target 'licenses' failed
make: *** [licenses] Error 2


[email protected]:~/workspace/cpp.machinarium$ cat /usr/include/boost/version.hpp //  Boost version.hpp configuration header file  ------------------------------//

//  (C) Copyright John maddock 1999. Distributed under the Boost
//  Software License, Version 1.0. (See accompanying file
//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

//  See http://www.boost.org/libs/config for documentation

#ifndef BOOST_VERSION_HPP
#define BOOST_VERSION_HPP

//
//  Caution: this is the only Boost header that is guaranteed
//  to change with every Boost release. Including this header
//  will cause a recompile every time a new Boost version is
//  used.
//
//  BOOST_VERSION % 100 is the patch level
//  BOOST_VERSION / 100 % 1000 is the minor version
//  BOOST_VERSION / 100000 is the major version

#define BOOST_VERSION 105800

//
//  BOOST_LIB_VERSION must be defined to be the same as BOOST_VERSION
//  but as a *string* in the form "x_y[_z]" where x is the major version
//  number, y is the minor version number, and z is the patch level if not 0.
//  This is used by <config/auto_link.hpp> to select which library version to link to.

#define BOOST_LIB_VERSION "1_58"

#endif
[email protected]:~/workspace/cpp.machinarium$ dpkg -s libboost-all-dev | grep 'Version'
Version: 1.58.0.1ubuntu1

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2021-08-15
@Nightmare1

undefined reference to `boost::python::exec(char const*, boost::python::api::object, boost::python::api::object)'

The method signature does not converge:
$ c++filt 
_ZN5boost6python4execENS0_3strENS0_3api6objectES3_
boost::python::exec(boost::python::str, boost::python::api::object, boost::python::api::object)

Not constructed boost::python::strfrom c-string.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question