0

I installed a fresh version of Ubuntu 16.04.4 LTS and was able to compile my project with cmake . and make and this g++-5 command

 g++-5 src/*.cpp -pthread -I extern/sleepy-discord/include -I
 extern/poco-1.9.0/Foundation/include -I extern/poco-1.9.0/JSON/include
 -I extern/poco-1.9.0/Net/include -I extern/poco-1.9.0/Util/include -L extern/sleepy-discord/lib/linux -L extern/poco-1.9.0/lib/linux
 -std=c++11 -o bin/tipbot -lPocoJSON -lPocoUtil -lPocoNet -lPocoFoundation -lsleepy_discord -lcurl -lssl -lcrypto

Everything built successfully without error but on Travis CI it gives hundreds of linker errors Travis.yml:

dist: trusty
sudo: false
language: cpp

addons:
  apt:
    sources:
      - ubuntu-toolchain-r-test
    packages:
      - g++-5
      - libcurl4-openssl-dev
      - openssl

script:
  - ls extern/sleepy-discord/lib/linux
  - ls extern/poco-1.9.0/lib/linux
  - g++-5 src/*.cpp -pthread -I extern/sleepy-discord/include -I extern/poco-1.9.0/Foundation/include -I extern/poco-1.9.0/JSON/include -I extern/poco-1.9.0/Net/include -I extern/poco-1.9.0/Util/include -L extern/sleepy-discord/lib/linux -L extern/poco-1.9.0/lib/linux -std=c++11 -o bin/tipbot -lPocoJSON -lPocoUtil -lPocoNet -lPocoFoundation -lsleepy_discord -lcurl -lssl -lcrypto

This is the error, it obviously found the libPocoJSON.a file but I don't understand why it says "undefined reference to" if it found the .a file and it found the C++11 template libraries.

extern/poco-1.9.0/lib/linux/libPocoJSON.a(ParserImpl.o): In function Poco::JSON::ParserImpl::stripComments(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&) [clone .part.23]': ParserImpl.cpp:(.text+0x91): undefined reference to std::__cxx11::basic_string, std::allocator >::_M_erase(unsigned long, unsigned long)' extern/poco-1.9.0/lib/linux/libPocoJSON.a(ParserImpl.o): In function void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*>(char*, char*, std::forward_iterator_tag) [clone .isra.68]': ParserImpl.cpp:(.text+0x1f9): undefined reference to std::__cxx11::basic_string, std::allocator >::_M_create(unsigned long&, unsigned long)' extern/poco-1.9.0/lib/linux/libPocoJSON.a(ParserImpl.o): In function `Poco::JSON::ParserImpl::handle()':

Full Travis report: https://travis-ci.org/Brandantl/IntenseCoin-TipBot/builds/363978290?utm_source=github_status&utm_medium=notification

Repo: https://github.com/Brandantl/IntenseCoin-TipBot

Can also compile with cmake .;make

1 Answers1

0

The problem is that you mixed use the c++11 string with the c++03 string, which have different implementation.

Maybe, the poco library or other library on your Travis CI server is not compiled with c++11 flag. Recompile it with -std=c++11 or replace it with the one on your local machine.

Wei Guo
  • 544
  • 3
  • 15