Travis-ci-未定义引用C ++

时间:2018-08-02 09:54:47

标签: c++ cmake travis-ci

我的Travis-ci构建因未定义的引用而不断失败,这是构建日志

我该如何解决ncurses的“未定义引用”? 我从源头构建了ncurses,并将'CMAKE_CXX_FLAGS'设置为“ -inccurses”,但我认为它似乎没有执行'CMAKE_CXX_FLAGS'。

用于非链接

cmake-

cmake_minimum_required(VERSION 3.9)
project(hoshiMenu)
include(FindPkgConfig)
pkg_check_modules(CURLPP REQUIRED curlpp)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

set(CMAKE_CXX_FLAGS "-lncurses")

add_executable(hoshiMenu main.cpp)
target_link_libraries(hoshiMenu ${CURLPP_LDFLAGS})

travis构建错误部分-

$ make
Scanning dependencies of target hoshiMenu
[ 50%] Building CXX object CMakeFiles/hoshiMenu.dir/main.cpp.o
[100%] Linking CXX executable hoshiMenu
CMakeFiles/hoshiMenu.dir/main.cpp.o: In function `main':
main.cpp:(.text+0x2d): undefined reference to `initscr'
main.cpp:(.text+0x32): undefined reference to `cbreak'
main.cpp:(.text+0x4d): undefined reference to `stdscr'
main.cpp:(.text+0x59): undefined reference to `stdscr'
main.cpp:(.text+0x75): undefined reference to `stdscr'
main.cpp:(.text+0x81): undefined reference to `stdscr'
main.cpp:(.text+0xb9): undefined reference to `newwin'
main.cpp:(.text+0xd9): undefined reference to `box'
main.cpp:(.text+0xf2): undefined reference to `newwin'
main.cpp:(.text+0x112): undefined reference to `box'
main.cpp:(.text+0x12b): undefined reference to `newwin'
main.cpp:(.text+0x14b): undefined reference to `box'
main.cpp:(.text+0x150): undefined reference to `refresh'
main.cpp:(.text+0x15f): undefined reference to `wrefresh'
main.cpp:(.text+0x16e): undefined reference to `wrefresh'
main.cpp:(.text+0x17d): undefined reference to `wrefresh'
main.cpp:(.text+0x191): undefined reference to `keypad'
main.cpp:(.text+0x2ca): undefined reference to `wattr_on'
main.cpp:(.text+0x311): undefined reference to `mvwprintw'
main.cpp:(.text+0x32a): undefined reference to `wattr_off'
main.cpp:(.text+0x34d): undefined reference to `wgetch'
main.cpp:(.text+0x3af): undefined reference to `refresh'
main.cpp:(.text+0x3bb): undefined reference to `refresh'
main.cpp:(.text+0x3cf): undefined reference to `keypad'
main.cpp:(.text+0x62c): undefined reference to `wattr_on'
main.cpp:(.text+0x673): undefined reference to `mvwprintw'
main.cpp:(.text+0x68c): undefined reference to `wattr_off'
main.cpp:(.text+0x6af): undefined reference to `wgetch'
main.cpp:(.text+0x752): undefined reference to `wattr_on'
main.cpp:(.text+0x799): undefined reference to `mvwprintw'
main.cpp:(.text+0x7b2): undefined reference to `wattr_off'
main.cpp:(.text+0x7d5): undefined reference to `wgetch'
main.cpp:(.text+0x891): undefined reference to `refresh'
main.cpp:(.text+0x898): undefined reference to `stdscr'
main.cpp:(.text+0x8a4): undefined reference to `stdscr'
main.cpp:(.text+0x8c0): undefined reference to `stdscr'
main.cpp:(.text+0x8cc): undefined reference to `stdscr'
main.cpp:(.text+0x8f0): undefined reference to `wrefresh'
main.cpp:(.text+0x91a): undefined reference to `mvwprintw'
main.cpp:(.text+0x929): undefined reference to `wrefresh'
main.cpp:(.text+0x93f): undefined reference to `stdscr'
main.cpp:(.text+0x947): undefined reference to `wgetch'
main.cpp:(.text+0x94c): undefined reference to `endwin'
collect2: error: ld returned 1 exit status
make[2]: *** [hoshiMenu] Error 1
make[1]: *** [CMakeFiles/hoshiMenu.dir/all] Error 2
make: *** [all] Error 2
The command "make" exited with 2.
Done. Your build exited with 1.

Travis yaml-

language: cpp
sudo: required
dist: trusty
os: linux
compiler: gcc
addons:
    apt:
        sources: ['ubuntu-toolchain-r-test']
        packages: ['g++', 'gcc', 'cmake', 'make']
        env:
            - CXX_COMPILER=g++
            - C_COMPILER=gcc

before_install:
    - pushd ~
    - wget -O curlpp-0.8.1.tar.gz https://github.com/jpbarrette/curlpp/archive/v0.8.1.tar.gz
    - tar -xf curlpp-0.8.1.tar.gz
    - cd curlpp-0.8.1
    - mkdir cmake_build
    - cd cmake_build
    - cmake -D CMAKE_CXX_COMPILER=`which ${CXX_COMPILER}` -DCMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS" -DCMAKE_EXE_LINKER_FLAGS="$CMAKE_EXE_LINKER_FLAGS" ..
    - sudo make install
    - wget -O ncurses-6.1.tar.gz https://invisible-mirror.net/archives/ncurses/ncurses-6.1.tar.gz
    - tar -xf ncurses-6.1.tar.gz
    - cd ncurses-6.1
    - ./configure
    - make
    - sudo make install
    - popd

script:
    - mkdir build
    - cd build
    - cmake ..
    - make

谢谢您的帮助<3

0 个答案:

没有答案