Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/163.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ Python静态链接_C++_Boost_Makefile_Boost Python_Undefined Symbol - Fatal编程技术网

C++ Python静态链接

C++ Python静态链接,c++,boost,makefile,boost-python,undefined-symbol,C++,Boost,Makefile,Boost Python,Undefined Symbol,我需要在我的项目中静态链接-lboost_python。这是我的Makefile: CC=g++ override CFLAGS+=-c -std=c++11 -Wall -Wextra -Werror override LFLAGS+=-lboost_python -lpthread -lboost_filesystem -lboost_system -lboost_thread -lcrypto client: clientmain.o client.o ccommand.o $(

我需要在我的项目中静态链接-lboost_python。这是我的Makefile:

CC=g++
override CFLAGS+=-c -std=c++11 -Wall -Wextra -Werror
override LFLAGS+=-lboost_python -lpthread -lboost_filesystem -lboost_system -lboost_thread -lcrypto

client: clientmain.o client.o ccommand.o
    $(CC) $(LINK) ../build/datatype.o ../build/utility.o build/clientmain.o build/client.o build/ccommand.o -o \
        build/mylib.so $(LFLAGS)
clientmain.o: main.cpp
    $(CC) $(CFLAGS) -fPIC main.cpp -o build/clientmain.o
client.o: cclient.cpp
    $(CC) $(CFLAGS) -fPIC cclient.cpp -o build/client.o
ccommand.o: ccommand.cpp
    $(CC) $(CFLAGS) -fPIC ccommand.cpp -o build/ccommand.o  
当$(LINK)被“-shared”时,一切正常。然而,当$(LINK)是“-static”时,我会得到大量链接器错误“undefined symbol…”,所有这些错误都与boost::python有关。以下是其中的一些(完整的列表非常大,可以发布在这里):


我的Makefile怎么了?

丢失的符号肯定来自libpython
因此,您可能可以尝试添加-lpython2.7或您想要使用的任何python版本。

丢失的符号肯定来自libpython 因此,您可能可以尝试添加-lpython2.7或任何您想要使用的python版本

/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4/../../../../lib64/Scrt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4/../../../../lib64/libboost_python.a(list.o): In function `boost::python::detail::list_base::call(boost::python::api::object const&)':
(.text+0x20): undefined reference to `PyList_Type'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4/../../../../lib64/libboost_python.a(list.o): In function `boost::python::detail::list_base::call(boost::python::api::object const&)':
(.text+0x35): undefined reference to `PyObject_CallFunction'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4/../../../../lib64/libboost_python.a(list.o): In function `boost::python::detail::list_base::list_base()':
(.text+0x9a): undefined reference to `PyList_New'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4/../../../../lib64/libboost_python.a(list.o): In function `boost::python::detail::list_base::list_base(boost::python::api::object const&)':
(.text+0x114): undefined reference to `PyList_Type'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4/../../../../lib64/libboost_python.a(list.o): In function `boost::python::detail::list_base::list_base(boost::python::api::object const&)':
(.text+0x119): undefined reference to `PyObject_CallFunction'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4/../../../../lib64/libboost_python.a(list.o): In function `boost::python::detail::list_base::append(boost::python::api::object const&)':
(.text+0x18d): undefined reference to `PyList_Type'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4/../../../../lib64/libboost_python.a(list.o): In function `boost::python::detail::list_base::append(boost::python::api::object const&)':
(.text+0x1d1): undefined reference to `PyEval_CallFunction'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4/../../../../lib64/libboost_python.a(list.o): In function `boost::python::detail::list_base::append(boost::python::api::object const&)':
(.text+0x254): undefined reference to `PyList_Append'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4/../../../../lib64/libboost_python.a(list.o): In function `boost::python::detail::list_base::extend(boost::python::api::object const&)':
(.text+0x320): undefined reference to `PyEval_CallFunction'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4/../../../../lib64/libboost_python.a(list.o): In function `boost::python::detail::list_base::index(boost::python::api::object const&) const':
(.text+0x441): undefined reference to `PyEval_CallFunction'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4/../../../../lib64/libboost_python.a(list.o): In function `boost::python::detail::list_base::index(boost::python::api::object const&) const':
(.text+0x471): undefined reference to `PyLong_AsSsize_t'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4/../../../../lib64/libboost_python.a(list.o): In function `boost::python::detail::list_base::pop()':
(.text+0x5ae): undefined reference to `PyEval_CallFunction'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4/../../../../lib64/libboost_python.a(list.o): In function `boost::python::detail::list_base::pop(long)':
(.text+0x691): undefined reference to `PyLong_FromLong'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4/../../../../lib64/libboost_python.a(list.o): In function `boost::python::detail::list_base::pop(long)':
(.text+0x6eb): undefined reference to `PyEval_CallFunction'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4/../../../../lib64/libboost_python.a(list.o): In function `boost::python::detail::list_base::pop(boost::python::api::object const&)':
(.text+0x845): undefined reference to `PyEval_CallFunction'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4/../../../../lib64/libboost_python.a(list.o): In function `boost::python::detail::list_base::remove(boost::python::api::object const&)':
(.text+0x960): undefined reference to `PyEval_CallFunction'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4/../../../../lib64/libboost_python.a(list.o): In function `boost::python::detail::list_base::reverse()':
(.text+0xa4a): undefined reference to `PyList_Type'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4/../../../../lib64/libboost_python.a(list.o): In function `boost::python::detail::list_base::reverse()':
(.text+0xa8b): undefined reference to `PyEval_CallFunction'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4/../../../../lib64/libboost_python.a(list.o): In function `boost::python::detail::list_base::reverse()':
(.text+0xb11): undefined reference to `PyList_Reverse'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4/../../../../lib64/libboost_python.a(list.o): In function `boost::python::detail::list_base::sort()':
(.text+0xbaa): undefined reference to `PyList_Type'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4/../../../../lib64/libboost_python.a(list.o): In function `boost::python::detail::list_base::sort()':
(.text+0xbeb): undefined reference to `PyEval_CallFunction'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4/../../../../lib64/libboost_python.a(list.o): In function `boost::python::detail::list_base::sort()':
(.text+0xc71): undefined reference to `PyList_Sort'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4/../../../../lib64/libboost_python.a(list.o): In function `boost::python::detail::list_base::sort(boost::python::detail::args_proxy const&, boost::python::detail::kwds_proxy const&)':
(.text+0xd49): undefined reference to `PyObject_Call'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4/../../../../lib64/libboost_python.a(list.o): In function `boost::python::detail::list_base::count(boost::python::api::object const&) const':
(.text+0xef1): undefined reference to `PyEval_CallFunction'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4/../../../../lib64/libboost_python.a(list.o): In function `boost::python::detail::list_base::count(boost::python::api::object const&) const':
(.text+0xf21): undefined reference to `PyLong_AsSsize_t'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4/../../../../lib64/libboost_python.a(list.o): In function `boost::python::detail::list_base::insert(long, boost::python::api::object const&)':
(.text+0x1033): undefined reference to `PyList_Type'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4/../../../../lib64/libboost_python.a(list.o): In function `boost::python::detail::list_base::insert(long, boost::python::api::object const&)':
(.text+0x1072): undefined reference to `PyLong_FromLong'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4/../../../../lib64/libboost_python.a(list.o): In function `boost::python::detail::list_base::insert(long, boost::python::api::object const&)':
(.text+0x1095): undefined reference to `PyEval_CallFunction'
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4/../../../../lib64/libboost_python.a(list.o): In function `boost::python::detail::list_base::insert(long, boost::python::api::object const&)':
(.text+0x1134): undefined reference to `PyList_Insert'