Compiling Nana with Clang 8.0 - cnjinhao/nana GitHub Wiki
This article describes how to compile Nana with clang and libc++. The clang version is 8, which currently is a development branch.
The llvm.org provides prebuilt clang for Debian and Ubuntu. My Linux distro is LinuxMint, so I chose the Trusty
packages. Refer to http://apt.llvm.org for other packages.
Add the repo to the apt sources.list:
sudo vi /etc/apt/sources.list
Add the following line:
deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty main
My Linux distro is LinuxMint(Ubuntu), so don't forget to add following line:
deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu trusty main
This is a development branch for clang 8.0. Save the modification.
Update the lists:
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
#Add this PPA to your system if it is Ubuntu
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
Then install clang 8 and libc++:
sudo apt-get install clang-8 lldb-8 lld-8
sudo apt-get install libc++-8-dev libc++abi-8-dev
Finally, please wait for minutes...After that, you can verify clang in terminal with following command.
clang++-8
Download the Nana from the latest development branch(develop-1.7). This is important, because it includes some fixes for clang 8.
Extract the zip file, open the makefile:
vi <nana-path>/build/makefile/makefile
Modify the following lines for clang 8.0
#GCC= g++
GCC = clang++-8
#Modify CXXFLAGS
CXXFLAGS= -g -fexceptions -std=c++17 -stdlib=libc++ -Wall -Wextra -Wunused-variable -Wfatal-errors
Save the modifications, then make
, libnana.a will be generated.
Create a use-nana.cpp
file
vi use-nana.cpp
Then edit the file
#include <nana/gui.hpp>
int main()
{
using namespace nana;
form fm;
drawing{fm}.draw([](paint::graphics& graph){
graph.string({10, 10}, "Hello, Nana C++ Library", colors::white);
});
fm.show();
exec();
}
Compile the program:
clang++-8 use-nana.cpp -o use-nana -std=c++17 -stdlib=libc++ -I<nana-path>/include -L<nana-path>/build/bin -lnana -lX11 -lXcursor -lpthread -lrt -lXft -lfontconfig -lc++ -lc++fs
Run the program.
./use-nana