anyks/alm

Make error

Closed this issue · 9 comments

When I compiling the project I get the following error:

[ 95%] Building CXX object CMakeFiles/alm.dir/app/alm.cpp.o
[100%] Linking CXX executable alm
/usr/bin/ld: cannot find -ltcmalloc
collect2: error: ld returned 1 exit status
CMakeFiles/alm.dir/build.make:87: recipe for target 'alm' failed
make[2]: *** [alm] Error 1
CMakeFiles/Makefile2:104: recipe for target 'CMakeFiles/alm.dir/all' failed
make[1]: *** [CMakeFiles/alm.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
anyks commented

I tried, but it wasn't working

anyks commented

Ваше решение к сожалению не помогло, возможно проблема в том что cmake не совсем работал, не видел python-3.7, поэтому я сделал так:
https://stackoverflow.com/a/38121972

(python-3.7.7)ml ➜  build git:(master) cmake .. \
-DPYTHON_INCLUDE_DIR=$(python -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())")  \
-DPYTHON_LIBRARY=$(python -c "import distutils.sysconfig as sysconfig; print(sysconfig.get_config_var('LIBDIR'))")
-- The CXX compiler identification is GNU 5.5.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.8")
Zlib include dir: /usr/include
Zlib libraries: /usr/lib/x86_64-linux-gnu/libz.so
-- Found PythonLibs: /home/omorykon/.pyenv/versions/3.7.7/lib (found suitable version "3.7.7", minimum required is "3.7")
Python include dir: /home/omorykon/.pyenv/versions/3.7.7/include/python3.7m
Python libraries: /home/omorykon/.pyenv/versions/3.7.7/lib
-- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found version "1.0.2g")
OpenSSL libraries: /usr/lib/x86_64-linux-gnu/libssl.so;/usr/lib/x86_64-linux-gnu/libcrypto.so
OpenSSL include dir: /usr/include
-- Creating "Smart Language Model" application
-- Build Type:
-- Using C++ compiler: GNU 5.5.0
-- Using C compiler:  5.5.0
-- C++ Flags:  -std=c++17 -Wall -fPIC -pthread   -O2 -DNDEBUG
-- C Flags:  -Wall -fPIC
Select Linux
-- Configuring done
WARNING: Target "alm" requests linking to directory "/home/omorykon/.pyenv/versions/3.7.7/lib".  Targets may link only to libraries.  CMake is dropping the item.
-- Generating done
-- Build files have been written to: /home/omorykon/lm_dataset/alm/build

а когда я поправил CmakeList.txt то получил следующее

liblm.a(python.cpp.o): In function `anyks::Python::add(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned short)':
python.cpp:(.text+0x7b0): undefined reference to `PySys_GetObject'
python.cpp:(.text+0x7ce): undefined reference to `PyUnicode_FromString'
python.cpp:(.text+0x7ee): undefined reference to `PyList_Append'
python.cpp:(.text+0x84c): undefined reference to `PyUnicode_DecodeFSDefault'
python.cpp:(.text+0x862): undefined reference to `PyImport_Import'
python.cpp:(.text+0x8d6): undefined reference to `PyObject_GetAttrString'
python.cpp:(.text+0x8f3): undefined reference to `PyObject_GetAttrString'
python.cpp:(.text+0x919): undefined reference to `PyCallable_Check'
python.cpp:(.text+0x930): undefined reference to `PyTuple_New'
python.cpp:(.text+0x950): undefined reference to `PyObject_CallObject'
python.cpp:(.text+0xa1c): undefined reference to `PyCallable_Check'
python.cpp:(.text+0xb83): undefined reference to `PyErr_Occurred'
python.cpp:(.text+0xb92): undefined reference to `PyErr_Print'
python.cpp:(.text+0xbd9): undefined reference to `PyErr_Occurred'
python.cpp:(.text+0xbe8): undefined reference to `PyErr_Print'
python.cpp:(.text+0xc2c): undefined reference to `PyErr_Print'
liblm.a(python.cpp.o): In function `anyks::Python::run(unsigned long, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&) const':
python.cpp:(.text+0xe4e): undefined reference to `PyTuple_New'
python.cpp:(.text+0xec4): undefined reference to `PyUnicode_FromString'
python.cpp:(.text+0xeec): undefined reference to `PyTuple_SetItem'
python.cpp:(.text+0xf68): undefined reference to `PyList_New'
python.cpp:(.text+0xfb4): undefined reference to `PyUnicode_FromString'
python.cpp:(.text+0xfca): undefined reference to `PyList_SetItem'
python.cpp:(.text+0x1000): undefined reference to `PyTuple_SetItem'
python.cpp:(.text+0x1093): undefined reference to `PyTuple_New'
python.cpp:(.text+0x10a6): undefined reference to `PyCallable_Check'
python.cpp:(.text+0x10c9): undefined reference to `PyObject_CallObject'
python.cpp:(.text+0x114b): undefined reference to `PyUnicode_AsWideCharString'
python.cpp:(.text+0x1252): undefined reference to `PyErr_Print'
liblm.a(python.cpp.o): In function `anyks::Python::Python()':
python.cpp:(.text+0x12b4): undefined reference to `Py_IsInitialized'
python.cpp:(.text+0x12c2): undefined reference to `Py_Initialize'
liblm.a(python.cpp.o): In function `anyks::Python::Python(anyks::Tokenizer const*)':
python.cpp:(.text+0x12fe): undefined reference to `Py_IsInitialized'
python.cpp:(.text+0x130c): undefined reference to `Py_Initialize'
liblm.a(python.cpp.o): In function `anyks::Python::~Python()':
python.cpp:(.text+0x133f): undefined reference to `Py_IsInitialized'
python.cpp:(.text+0x134d): undefined reference to `Py_Finalize'
collect2: error: ld returned 1 exit status
CMakeFiles/alm.dir/build.make:87: recipe for target 'alm' failed
make[2]: *** [alm] Error 1
CMakeFiles/Makefile2:104: recipe for target 'CMakeFiles/alm.dir/all' failed
make[1]: *** [CMakeFiles/alm.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
anyks commented

Спасибо поставил 3.8.1, но получил ошибку:

[ 95%] Building CXX object CMakeFiles/alm.dir/app/alm.cpp.o
[100%] Linking CXX executable alm
/usr/bin/ld: /usr/local/lib/libpython3.8.a(dynload_shlib.o): undefined reference to symbol 'dlsym@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libdl.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
CMakeFiles/alm.dir/build.make:88: recipe for target 'alm' failed
make[2]: *** [alm] Error 1
CMakeFiles/Makefile2:104: recipe for target 'CMakeFiles/alm.dir/all' failed
make[1]: *** [CMakeFiles/alm.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

может все же 3,7 будет лучше?

anyks commented

Попробовал еще на одной машине где установлен системный python 3.7

 build git:(master) ls -ls /usr/bin/python*
   0 lrwxrwxrwx 1 root root       9 кві 16  2018 /usr/bin/python -> python2.7
   0 lrwxrwxrwx 1 root root       9 кві 16  2018 /usr/bin/python2 -> python2.7
3580 -rwxr-xr-x 1 root root 3665768 лип 20 18:37 /usr/bin/python2.7
   0 lrwxrwxrwx 1 root root      33 лип 20 18:37 /usr/bin/python2.7-config -> x86_64-linux-gnu-python2.7-config
   0 lrwxrwxrwx 1 root root      16 кві 16  2018 /usr/bin/python2-config -> python2.7-config
   0 lrwxrwxrwx 1 root root       9 жов 25  2018 /usr/bin/python3 -> python3.6
4424 -rwxr-xr-x 2 root root 4526456 лип 17 15:50 /usr/bin/python3.6
   0 lrwxrwxrwx 1 root root      33 лип 17 15:50 /usr/bin/python3.6-config -> x86_64-linux-gnu-python3.6-config
4424 -rwxr-xr-x 2 root root 4526456 лип 17 15:50 /usr/bin/python3.6m
   0 lrwxrwxrwx 1 root root      34 лип 17 15:50 /usr/bin/python3.6m-config -> x86_64-linux-gnu-python3.6m-config
5184 -rwxr-xr-x 2 root root 5308240 чер 29 08:44 /usr/bin/python3.7
5184 -rwxr-xr-x 2 root root 5308240 чер 29 08:44 /usr/bin/python3.7m
   0 lrwxrwxrwx 1 root root      16 жов 25  2018 /usr/bin/python3-config -> python3.6-config
   0 lrwxrwxrwx 1 root root      10 жов 25  2018 /usr/bin/python3m -> python3.6m
   0 lrwxrwxrwx 1 root root      17 жов 25  2018 /usr/bin/python3m-config -> python3.6m-config
   0 lrwxrwxrwx 1 root root      16 кві 16  2018 /usr/bin/python-config -> python2.7-config

та же ошибка при проверке cmake на наличие python 3.7

CMake Error at /usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS)
  (Required is at least version "3.7")
Call Stack (most recent call first):
  /usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.10/Modules/FindPythonLibs.cmake:262 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:45 (find_package)

потом взял на гугл клауде чистый инстанс и установил google-perftools но все равно получал ошибку

/usr/bin/ld: cannot find -ltcmalloc

и только после #1 (comment)
все заработало. Спасибо!!!

anyks commented