News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

Definition of libc++ library with Clang compiler in Code::Blocks on Ubuntu Linux

Started by ptolomey, April 08, 2013, 10:06:20 PM

Previous topic - Next topic

ptolomey

I installed Clang and libc++ in Linux Ubuntu 12.04 using instructions from the link: http://solarianprogrammer.com/2013/01/17/building-clang-libcpp-ubuntu-linux/.
Programs published in link above pass compilation and can be run, using terminal with following compilation options: clang++ -std=c++11 -stdlib=libc++.
The problem is appeared in C::B when I tried to use STL library libc++ with Clang compiler, option -stdlib=libc++ within Compiler settings -> Other options.
Everything is passing fluently in C::B when Clang compiler is used with STL library libstdc++.
How this problem can be solved?

The source code is published in link above and the compilation errors log file attached to post.

stahta01

May guess based on this link http://stackoverflow.com/questions/12939046/forcing-clang-to-link-with-c-runtime

Try adding the library "stdc++" to the link library list.

NOTE: This is only slightly related to CB; so, the topic might be locked.

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

ptolomey

Hi, stahta01
Thank you for reply.
The problem is does in C::B options.
I have no problems in compilation and runing the programm, when everything is done via terminal.

ptolomey

I think I found out where the problem is.

When I use the terminal the compilation command is:
clang++ -std=c++11 -stdlib=libc++ -g <filename>.cpp -o <filename>

This command make an executable file if compilation pass.

In case of C::B, first of all created objective file, and only after that executable is created.
There are two commands in C::B:

  • first for compilation and creation of objective file
  • second for linking

#1 clang++ -std=c++11 -stdlib=libc++ -g -c <filename>.cpp -o obj/Debug/<filename>.o
#2 clang++ -o /bin/debug/<filename> obj/Debug/<filename>.o


The command in 2-nd line created by C::B automaticly.
Based on attached Error Log file, it can be seen that errors start to appear after command in 2-nd line.
I belive that automaticly created command in 2-nd line, should look like following:

clang++ obj/Debug/<filename>.o -o /bin/debug/<filename>


Currently I have no accesses to PC with installed Clang.
Today at evening I will check this option using command line.

[attachment deleted by admin]

oBFusCATed

Quote from: ptolomey on April 09, 2013, 09:24:25 AM
I belive that some compiler flags are missing in automaticly created 2-nd line command.
Please use you console to play with it and tell us which flags.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

jarod42


ptolomey

Hi jarod42,
Thank you for advice.

The flag -stdlib=libc++ is compiler's and linker's option.
The code is get compiled and runs after addition of flag -stdlib=libc++ to Compiler settings -> Other options and Linker settings -> Other linker options in C::B.

The compilation and linking options in C::B are following:

Compilation: clang++ -stdlib=libc++ -std=c++11 -g -c <filename>.cpp -o obj/Debug/<filename>.o
Linking:     clang++ -stdlib=libc++ obj/Debug/<filename>.o -o /bin/debug/<filename>  


Via terminal is almost (except path) same command:

Compilation: clang++ -stdlib=libc++ -std=c++11 -g -c <filename>.cpp -o <filename>.o
Linking:     clang++ -stdlib=libc++ <filename>.o -o <filename>  


Thank you for ideas.