#40515 closed defect (fixed)
codeblocks: fails to compile with libc++
Reported by: | mojca (Mojca Miklavec) | Owned by: | mojca (Mojca Miklavec) |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | ports | Version: | |
Keywords: | Cc: | jeremyhu (Jeremy Huddleston Sequoia) | |
Port: | codeblocks |
Description
(Reported by Jeremy.)
If you set "cxx_stdlib libc++
" in macports.conf
as discussed on macports-dev
, you get the following error:
/usr/bin/clang++ -DHAVE_CONFIG_H -I/opt/local/Library/Frameworks/wxWidgets.framework/Versions/wxGTK/2.8/lib/wx/include/gtk2-unicode-release-2.8 -I/opt/local/Library/Frameworks/wxWidgets.framework/Versions/wxGTK/2.8/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -I../../src/include -I../../src/include -I../../src/sdk/wxscintilla/include -I../../src/include/tinyxml -I../../src/include/scripting/include -I../../src/include/scripting/sqplus -I../../src/include/mozilla_chardet -I/opt/local/include -Ulinux -Uunix -O2 -ffast-math -DCB_AUTOCONF -pipe -Os -arch x86_64 -stdlib=libc++ -DCB_PRECOMP -Winvalid-pch -fPIC -DPIC -fexceptions -o sdk_precomp.h.gch -xc++-header ./sdk_precomp.h In file included from ./sdk_precomp.h:13: In file included from ../../src/include/sdk_common.h:43: ../../src/include/prep.h:409:10: fatal error: 'tr1/memory' file not found #include <tr1/memory> ^ 1 error generated.
Change History (11)
comment:1 Changed 11 years ago by mojca (Mojca Miklavec)
comment:4 Changed 11 years ago by cooljeanius (Eric Gallager)
Darn it my finger slipped and I accidentally double-clicked the "Cc Me!" button...
comment:5 Changed 11 years ago by jeremyhu (Jeremy Huddleston Sequoia)
It's not related to precompiled headers. You just need to update the source to not use tr1.
comment:6 Changed 11 years ago by mojca (Mojca Miklavec)
Do you want to say that the solution is to use
#include <memory>
instead of
#include <tr1/memory>
?
comment:7 Changed 11 years ago by jeremyhu (Jeremy Huddleston Sequoia)
That is likely part of the fix, yes. You'll also need to cleanup the namespacing. See this article for a bit more reference:
Depending on how much of tr1 is used, you can probably just get away with something like:
reinplace "s:tr1/::" ${file} reinplace "s/tr1:://" ${file}
comment:8 Changed 11 years ago by mojca (Mojca Miklavec)
Thank you for the explanation. I submitted a bug report upstream:
The tr1
seems to appear just here:
./src/include/prep.h:#include <tr1/memory> ./src/include/prep.h: using std::tr1::shared_ptr; ./src/include/prep.h: using std::tr1::static_pointer_cast; ./src/include/prep.h: using std::tr1::weak_ptr;
so it doesn't seem like much work.
It also appears here, but for a different purpose:
./src/plugins/codecompletion/cctest/cctest.cpp: Tokenizer::SetReplacementString(_T("_GLIBCXX_BEGIN_NAMESPACE_TR1"), _T("namespace tr1 {")); ./src/plugins/codecompletion/codecompletion.cpp: repl[_T("_GLIBCXX_BEGIN_NAMESPACE_TR1")] = _T("namespace tr1 {");
I believe I need to use
#if __cplusplus >= 201103L ... #else ... #endif
right?
Just a note to myself: play with -std=c++11
and use these options to inspect the value of __cplusplus
, for example:
clang++ -std=c++11 -dM -E -x c++ /dev/null
comment:9 Changed 11 years ago by mojca (Mojca Miklavec)
I'm unable to attach the patch (there seem to be problems with trac at the moment), but I committed a blind patch in r111426. Please confirm that it works now.
comment:10 Changed 11 years ago by jeremyhu (Jeremy Huddleston Sequoia)
Resolution: | → fixed |
---|---|
Status: | new → closed |
That doesn't fix the issue when using clang++ -stdlib=libc++ (without -std=c++11) ...
Fixed in r111440
comment:11 Changed 11 years ago by mojca (Mojca Miklavec)
Thank you very much for fixing this. Do you want to say that compilation also works for 10.9 now?
Dear Jeremy, I'm afraid that this is more in your field of the expertise. I have
here as well as a bunch of files like
but I don't have a clue yet about how
libc++
affects the search paths of headers and what this particulartr1
means (other than what can be found on http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt01ch03s02.html or https://en.wikipedia.org/wiki/C%2B%2B_Technical_Report_1).There is a tiny chance that this is related to precompiled headers (#40513).