Nightmare1
@Nightmare1
Программист

Линковщик не находит необходимую функцию в библиотеке, почему?

Библиотека, содержащая функцию exec.

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


Фрагмент release make-файла.
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 "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
endef
define PRELINKCMDS
endef
define POSTBUILDCMDS
endef


Процесс построения.
ubuntu@ubuntu:~/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


ubuntu@ubuntu:~/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
ubuntu@ubuntu:~/workspace/cpp.machinarium$ dpkg -s libboost-all-dev | grep 'Version'
Version: 1.58.0.1ubuntu1
  • Вопрос задан
  • 120 просмотров
Решения вопроса 1
jcmvbkbc
@jcmvbkbc
"I'm here to consult you" © Dogbert
undefined reference to `boost::python::exec(char const*, boost::python::api::object, boost::python::api::object)'


Сигнатура метода не сходится:
$ c++filt 
_ZN5boost6python4execENS0_3strENS0_3api6objectES3_
boost::python::exec(boost::python::str, boost::python::api::object, boost::python::api::object)

Не сконструировался boost::python::str из с-строчки.
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы