Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » How to force Eclipse CDT to use only libc++?(I want to use libc++ instead of stdc++, but Eclipse keeps re-inserting the latter even after deletion)
How to force Eclipse CDT to use only libc++? [message #1800410] Thu, 27 December 2018 03:22 Go to next message
Eclipse UserFriend
I've been trying to use clang with libc++ in an Eclipse CDT project, but every time I add "c++" and delete "stdc++" in

Project->Properties->C/C++ Build->Settings->Tool Settings->LLVM Clang C++ Linker->Libraries


"stdc++" gets re-inserted, and both libraries get linked.

Using the flag "-stdlib=libc++" still ends up with Eclipse linking to "stdc++".

How do I get Eclipse to use only libc++?

[Updated on: Thu, 27 December 2018 10:44] by Moderator

Re: How to force Eclipse CDT to use only libc++? [message #1800584 is a reply to message #1800410] Wed, 02 January 2019 18:15 Go to previous messageGo to next message
Eclipse UserFriend
I've been trying to do this with an HelloWorld project.
When both the static and dynamic libraries are available, you need to explicitly name them.
libstdc++ will still appear on the link command but won't cause problems.
https://jonwillia.ms/2018/02/02/static-linking

I added the following to "Other bytecode files"
/usr/lib64/libc++.a
/usr/lib64/libc++abi.a

I am still getting errors because I am trying to link libraries built by GCC.
They are incompatible with those built with LLVM and I don't feel like fixing them.

make all 
Building target: Hello - LLVM
Invoking: LLVM Clang C++ linker
clang++ -L/usr/lib64 -L/usr/lib/gcc/x86_64-redhat-linux/8/32/ -stdlib=libc++ -o "Hello - LLVM"  ./src/Duplicate.bc ./src/Florp.bc ./src/Hello.bc ./src/ParmTest.bc  /usr/lib64/libc++.a /usr/lib64/libc++abi.a -lstdc++
/home/dvavra/perl5/perlbrew/perls/system/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/8/32//libgcc_s.so when searching for -lgcc_s
/home/dvavra/perl5/perlbrew/perls/system/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/8/32//libgcc.a when searching for -lgcc
/home/dvavra/perl5/perlbrew/perls/system/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/8/32//libgcc_s.so when searching for -lgcc_s
/home/dvavra/perl5/perlbrew/perls/system/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/8/32//libgcc.a when searching for -lgcc
/home/dvavra/perl5/perlbrew/perls/system/bin/ld: /usr/lib64/libc++.a(mutex.cpp.o): undefined reference to symbol 'pthread_mutexattr_settype@@GLIBC_2.2.5'
//usr/lib64/libpthread.so.0: error adding symbols: DSO missing from command line
clang-6.0: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [makefile:53: Hello - LLVM] Error 1

18:05:59 Build Failed. 6 errors, 0 warnings. (took 1s.255ms)



HTH

[Updated on: Wed, 02 January 2019 18:29] by Moderator

Re: How to force Eclipse CDT to use only libc++? [message #1800638 is a reply to message #1800584] Fri, 04 January 2019 04:08 Go to previous messageGo to next message
Eclipse UserFriend
That sounds like a PITA. There's a libc++.a, but I cannot find libc++abi.a, only the *.so variants. I'm using Eclipse CDT on Manjaro within VirtualBox.

Perhaps it'll be "safe" enough, to put libc++ before libstdc++ in the load order.
Re: How to force Eclipse CDT to use only libc++? [message #1802431 is a reply to message #1800638] Fri, 08 February 2019 12:45 Go to previous message
Eclipse UserFriend
I've found a solution, which in retrospect seems so very, very obvious.

When creating a project and choosing LLVM/clang as the toolchain, I went to the compiler settings
Project -> Properties -> C/C++ Build -> Settings -> LLVM Clang++

and appended
-stdlib=libc++

to the "Command" field.

I also added "c++" to be included by the linker:

Project -> Properties -> C/C++ Build -> Settings -> LLVM Clang C++ Linker -> Libraries (-l)


The presence of the "stdc++" library can be safely ignored.

To test if "libc++" is really used, I've written the following piece of code:
#include <iostream>

int main() {
	std::cout << _LIBCPP_VERSION << std::endl;
	return 0;
}


In my case, the output was
7000

which corresponds to clang 7.0 on my system.

Edit:
Update: I mistakenly typed "-std" instead of "-stdlib".

[Updated on: Wed, 13 February 2019 11:26] by Moderator

Previous Topic:Help needed for multithreading debugging of Stockfish10 in Eclipse C++
Next Topic:Add clang with libc++ (LLVM)
Goto Forum:
  


Current Time: Wed Aug 20 13:30:36 EDT 2025

Powered by FUDForum. Page generated in 0.02717 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top