dougpuob / cppnamelint

CppNameLint is a naming convention linter of C/C++ source code (Based on LLVM's libtooling), which runs with command line on Windows/Linux/macOS.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] Build failed with undefined reference to `setupterm' on Ubuntu Linux

dougpuob opened this issue · comments

  • undefined reference to setupterm
  • undefined reference to tigetnum
  • undefined reference to set_curterm
  • undefined reference to del_curterm

LLVM libraries built with this command

$ cmake -DLLVM_ENABLE_PROJECTS=clang -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_RTTI=ON -G "Unix Makefiles" ../llvm

Full error message

[ 80%] Linking CXX executable Output/cppnamelint
/home/dougpuob/working-folder/llvm-project/8.0.0/build/lib/libLLVMSupport.a(Process.cpp.o): In function `llvm::sys::Process::FileDescriptorHasColors(int)':
Process.cpp:(.text._ZN4llvm3sys7Process23FileDescriptorHasColorsEi+0x5c): undefined reference to `setupterm'
Process.cpp:(.text._ZN4llvm3sys7Process23FileDescriptorHasColorsEi+0x6c): undefined reference to `tigetnum'
Process.cpp:(.text._ZN4llvm3sys7Process23FileDescriptorHasColorsEi+0x78): undefined reference to `set_curterm'
Process.cpp:(.text._ZN4llvm3sys7Process23FileDescriptorHasColorsEi+0x80): undefined reference to `del_curterm'
collect2: error: ld returned 1 exit status
CMakeFiles/cppnamelint.dir/build.make:306: recipe for target 'Output/cppnamelint' failed
make[2]: *** [Output/cppnamelint] Error 1
CMakeFiles/Makefile2:69: recipe for target 'CMakeFiles/cppnamelint.dir/all' failed
make[1]: *** [CMakeFiles/cppnamelint.dir/all] Error 2
Makefile:151: recipe for target 'all' failed
make: *** [all] Error 2

image

Build LLVM with -DLLVM_ENABLE_TERMINFO=OFF option, then build CppNameLint with -ltinfo option.

Buil LLVM with -DLLVM_ENABLE_TERMINFO=OFF option

$ cmake -DCMAKE_BUILD_TYPE=Release              \
               -DLLVM_ENABLE_PROJECTS=clang     \
               -DLLVM_ENABLE_RTTI=ON            \
               -DLLVM_ENABLE_TERMINFO=OFF       \
               -G "Unix Makefiles"              \
               ../llvm                          \
               > logfile-cmake.log 2>&1

Build CppNameLint project with -ltinfo option

set(CMAKE_CXX_FLAGS "-frtti -lz -ltinfo")