Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installing doctest using cmake and make fails on Ubuntu 16.04 (C++11 is not used) #189

Closed
Dobiasd opened this issue Feb 27, 2019 · 2 comments

Comments

@Dobiasd
Copy link

Dobiasd commented Feb 27, 2019

When trying to install doctest naively like this:

git clone https://github.com/onqtam/doctest
cd doctest
mkdir -p build
cd build
cmake ..
make install

I get compiler errors from the fact, that it tried to compile without setting the -std=c++11 flag.

In file included from /home/tobias/doctest/examples/all_features/main.cpp:2:0:
/home/tobias/doctest/examples/all_features/../../doctest/doctest.h:392:1: error: identifier ‘decltype’ is a keyword in C++11 [-Werror=c++0x-compat]
 typedef decltype(nullptr) nullptr_t;

Full output here: https://gist.github.com/Dobiasd/6146ff7ea3ebe0261cbe45b27db0bebd

When I git checkout tags/1.2.9 instead, it works, but I'd like to upgrade my two libraries (FunctionalPlus, and frugally-deep) to the latest version.

My test machine is basically an Ubuntu 16.04:

$ cat /etc/linuxmint/info
RELEASE=18.2
CODENAME=sonya
EDITION="Cinnamon 64-bit"
DESCRIPTION="Linux Mint 18.2 Sonya"
DESKTOP=Gnome
TOOLKIT=GTK
NEW_FEATURES_URL=http://www.linuxmint.com/rel_sonya_cinnamon_whatsnew.php
RELEASE_NOTES_URL=http://www.linuxmint.com/rel_sonya_cinnamon.php
USER_GUIDE_URL=help:linuxmint
GRUB_TITLE=Linux Mint 18.2 Cinnamon 64-bit

The compilers are new enough to support C++11:

$ g++ --version
g++ (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ clang++ --version
clang version 3.8.0-2ubuntu4 (tags/RELEASE_380/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

What is the recommended way to install doctest using cmake? I was unable to find it in the docs.

@onqtam
Copy link
Member

onqtam commented Feb 27, 2019

Sooo it seems that it is not the installing, but the building of the examples that fails.

doctest 2.0 uses C++11. Also it uses -Weverything for clang for building the examples and later disables a few flags which aren't compatible - like c++98-compat:
https://github.com/onqtam/doctest/blob/master/scripts/cmake/common.cmake#L154

I now see that on Travis CI I explicitly tell CMake to use C++11 like this:
https://github.com/onqtam/doctest/blob/master/.travis.yml#L332

and later like this:

https://github.com/onqtam/doctest/blob/master/.travis.yml#L340

Both of the compilers you are using support some (or even most) of C++11, but for them the default std is still 98 - I think that changed for GCC 6 and perhaps a newer clang as well.

So try explicitly setting the standard to C++11 and let me know if it works - I might think of a solution inside of the repository if this is indeed the problem.

@Dobiasd
Copy link
Author

Dobiasd commented Feb 27, 2019

Thanks for the quick help. I'm now using the following, and it works perfectly:

git clone https://github.com/onqtam/doctest
cd doctest
mkdir -p build
cd build
cmake .. -DCMAKE_CXX_FLAGS=-std=c++11
make install

@Dobiasd Dobiasd closed this as completed Feb 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants