Using clang on OSX

133 views
Skip to first unread message

Igor Korot

unread,
Sep 3, 2018, 2:43:14 PM9/3/18
to wx-u...@googlegroups.com
Hi,
I just bought myself a new Apple laptop.
I installed Xcode on it (command line tools are installed by default -
thank you Apple).
Next I downloaded wxWidgets latest stable release unpacked it and did:

[code]
cd wxWidgets
mkdir buildMac
cd buildMac
../configure --with-cocoa --enable-debug
[/code]

Judging from the configure output the compiler will be g++.

Is there a way to change for clang?

I think this should be default for the Xcode.

Thank you.

Igor Korot

unread,
Sep 3, 2018, 2:47:40 PM9/3/18
to wx-u...@googlegroups.com
In addition I will need to compile in C++11 mode.

Is it a default for a clang on Xcode 9.4.1? Or I will have to issue
CXXFLAGS="-std=c++11"?

TIA!

Stefan Csomor

unread,
Sep 3, 2018, 2:54:22 PM9/3/18
to wx-u...@googlegroups.com
Hi



Is it a default for a clang on Xcode 9.4.1? Or I will have to issue

CXXFLAGS="-std=c++11"?



I do a --with-cxx=11 for configure



And a gcc --version will show you that you are probably are using clang anyway



FWIW I also have apart from your flags a min OS directive --with-macosx-version-min=10.8

And in order to avoid some linkage problems where SDK symbols didn't exist on previous versions --without-liblzma --with-zlib=builtin



HTH,



Stefan


Igor Korot

unread,
Sep 3, 2018, 10:45:01 PM9/3/18
to wx-u...@googlegroups.com
Hi, Stefan,
I did configured as follows.
CXXFLAGS="-std=c++11" ../configure --with-cocoa --enable-debug
--with-macosx-version-min=10.8 --without-liblzma --with-zlib=builtin

And that's what I received (it is on the 3.1 release):

[code]
/Users/igor/wxWidgets/buildMac/bk-deps g++ -mmacosx-version-min=10.8
-c -o basedll_appbase.o -D__WXOSX_COCOA__ -DWXBUILDING
-I/Users/igor/wxWidgets/buildMac/src/tiff/libtiff
-I../src/tiff/libtiff -I../src/jpeg -I../src/png -I../src/zlib
-I../src/regex -DwxUSE_GUI=0 -DWXMAKINGDLL_BASE -DwxUSE_BASE=1
-dynamic -fPIC -DPIC -Wall -Wundef -Wunused-parameter
-Wno-ctor-dtor-privacy -Woverloaded-virtual
-Wno-deprecated-declarations -D_FILE_OFFSET_BITS=64
-I/Users/igor/wxWidgets/buildMac/lib/wx/include/osx_cocoa-unicode-3.1
-I../include -g -O0 -std=c++11 -fno-common -fvisibility=hidden
-fvisibility-inlines-hidden ../src/common/appbase.cpp
In file included from ../src/common/appbase.cpp:31:
In file included from ../include/wx/app.h:19:
In file included from ../include/wx/event.h:32:
../include/wx/meta/convertible.h:50:17: error: no template named
'is_base_of' in namespace 'std'; did you mean
'std::tr1::is_base_of'?
value = std::is_base_of<B, D>::value &&
std::is_convertible<D*, B*>::value
^~~~~~~~~~~~~~~
std::tr1::is_base_of
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/c++/4.2.1/tr1/type_traits:465:12:
note:
'std::tr1::is_base_of' declared here
struct is_base_of
^
In file included from ../src/common/appbase.cpp:31:
In file included from ../include/wx/app.h:19:
In file included from ../include/wx/event.h:32:
../include/wx/meta/convertible.h:50:49: error: no template named
'is_convertible' in namespace 'std'; did you
mean 'std::tr1::is_convertible'?
value = std::is_base_of<B, D>::value &&
std::is_convertible<D*, B*>::value
^~~~~~~~~~~~~~~~~~~
std::tr1::is_convertible
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/c++/4.2.1/tr1/type_traits:514:12:
note:
'std::tr1::is_convertible' declared here
struct is_convertible
^
../src/common/appbase.cpp:716:13: error: no type named 'exception_ptr'
in namespace 'std'; did you mean
'exception'?
static std::exception_ptr gs_storedException;
~~~~~^~~~~~~~~~~~~
exception
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/c++/4.2.1/exception:56:9:
note:
'exception' declared here
class exception
^
../src/common/appbase.cpp:720:10: error: value of type
'std::exception' is not contextually convertible to
'bool'
if ( gs_storedException )
^~~~~~~~~~~~~~~~~~
../src/common/appbase.cpp:729:31: error: no member named
'current_exception' in namespace 'std'
gs_storedException = std::current_exception();
~~~~~^
../src/common/appbase.cpp:736:10: error: value of type
'std::exception' is not contextually convertible to
'bool'
if ( gs_storedException )
^~~~~~~~~~~~~~~~~~
../src/common/appbase.cpp:738:28: error: use of undeclared identifier
'storedException'; did you mean
'gs_storedException'?
std::exception_ptr storedException;
^~~~~~~~~~~~~~~
gs_storedException
../src/common/appbase.cpp:716:27: note: 'gs_storedException' declared here
static std::exception_ptr gs_storedException;
^
../src/common/appbase.cpp:738:27: error: expected ';' after expression
std::exception_ptr storedException;
^
;
../src/common/appbase.cpp:738:14: error: no member named
'exception_ptr' in namespace 'std'
std::exception_ptr storedException;
~~~~~^
../src/common/appbase.cpp:739:19: error: use of undeclared identifier
'storedException'; did you mean
'gs_storedException'?
std::swap(storedException, gs_storedException);
^~~~~~~~~~~~~~~
gs_storedException
../src/common/appbase.cpp:716:27: note: 'gs_storedException' declared here
static std::exception_ptr gs_storedException;
^
../src/common/appbase.cpp:741:14: error: no type named
'rethrow_exception' in namespace 'std'
std::rethrow_exception(storedException);
~~~~~^
../src/common/appbase.cpp:738:28: warning: expression result unused
[-Wunused-value]
std::exception_ptr storedException;
^~~~~~~~~~~~~~~
1 warning and 11 errors generated.
make: *** [basedll_appbase.o] Error 1
[/code]

Thank you.

>
>
>
> HTH,
>
>
>
> Stefan
>
>
> --
> Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
>
> To unsubscribe, send email to wx-users+u...@googlegroups.com
> or visit http://groups.google.com/group/wx-users

Igor Korot

unread,
Sep 4, 2018, 12:28:48 AM9/4/18
to wx-u...@googlegroups.com
Sorry, BM that.
Adding -stdlib=libc++ fixed it.

And yes, it did say "Apple LLVM", which I presumed is "clang".

[code]
Igors-MacBook-Air:~ igor$ gcc --version
Configured with:
--prefix=/Applications/Xcode.app/Contents/Developer/usr
--with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/c++/4.2.1
Apple LLVM version 9.1.0 (clang-902.0.39.2)
Target: x86_64-apple-darwin17.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Igors-MacBook-Air:~ igor$
[/code]

Thank you.

Stefan Csomor

unread,
Sep 4, 2018, 1:45:49 AM9/4/18
to wx-u...@googlegroups.com
Hi



 > CXXFLAGS="-std=c++11"

> Adding -stdlib=libc++ fixed it.



That's (both) what --with-cxx=11 does IMHO in a cleaner way and at least current master builds fine with that



And yes, it did say "Apple LLVM", which I presumed is "clang".



[code]

Igors-MacBook-Air:~ igor$ gcc --version

Configured with:

--prefix=/Applications/Xcode.app/Contents/Developer/usr

--with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/c++/4.2.1

Apple LLVM version 9.1.0 (clang-902.0.39.2)

Target: x86_64-apple-darwin17.5.0

Thread model: posix

InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Igors-MacBook-Air:~ igor$

[/code]



Exactly



Best,



Stefan




Reply all
Reply to author
Forward
0 new messages