Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to link libstdc++ statically with clang++

I'm trying to learn C++ deeper by reading source of STL as well as debugging it, so I want to link libstdc++ statically to my program, and it works fine using g++. However, how can I achieve the same thing with clang++ in llvm?

In another way, the question is, what is the clang++ equivalent of -static-libgcc?

Makefile I'm using

CXX=g++
CC=g++
LDFLAGS=-g -O0 -static-libgcc
CFLAGS=-O0 -Wall
CXXFLAGS=$(CFLAGS)
like image 434
Haocheng Avatar asked Dec 03 '12 08:12

Haocheng


1 Answers

The flag you're looking for, in both GCC and Clang, is: -static-libstdc++

like image 187
Chandler Carruth Avatar answered Sep 20 '22 07:09

Chandler Carruth