xcode c++11 and libc++, wxWidgets 3.1.1

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
joe31093
Earned a small fee
Earned a small fee
Posts: 12
Joined: Thu Mar 15, 2018 3:06 pm

xcode c++11 and libc++, wxWidgets 3.1.1

Post by joe31093 »

I am running minimal project in the samples folder for OS X.

I am trying to add spdlog https://github.com/gabime/spdlog into the project. The error that I got was 'initializer_list' file not found. Then I tried to switch the project and wxcocoa.xcodeproj settings to c++11 and libc++ to resolve the issue.

Apple LLVM9.0 - Language - C++
C++ Language Dialect -> C++11 [-std=c++11]
C++ Standard Library -> libc++ (LLVM C++ standard library with C++ support)


The initializer_list error is still there and I have some additional cmath errors.

No member named 'signbit' in the global namespace
No member named 'fpclassify' in the global namespace; did you mean '__fpclassify'?
No member named 'isfinite' in the global namespace; did you mean 'finite'?
(and many more...)


Are there additional settings I need to make to work with c++11 and libc++ / resolve the issues?
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: xcode c++11 and libc++, wxWidgets 3.1.1

Post by ONEEYEMAN »

Hi,
What is the exact error message you received without C++11?
Is the file present on your system?
Did you link with all required framework?
After you switch to C++11, did you rebuild wx and then rebuild your application?

Thank you.
joe31093
Earned a small fee
Earned a small fee
Posts: 12
Joined: Thu Mar 15, 2018 3:06 pm

Re: xcode c++11 and libc++, wxWidgets 3.1.1

Post by joe31093 »

If I included just spdlog.h the error that I got was
'initializer_list' file not found
.

Then I switched to c++11 and libc++. wx rebuilt and the minimal project rebuilt. Then the following errors occurred:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:313:9: No member named 'signbit' in the global namespace
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:314:9: No member named 'fpclassify' in the global namespace; did you mean '__fpclassify'?
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:315:9: No member named 'isfinite' in the global namespace; did you mean 'finite'?
And 10 more other errors coming from cmath.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: xcode c++11 and libc++, wxWidgets 3.1.1

Post by ONEEYEMAN »

Hi,
You need to re-configure and re-compile wx with c++11 mode.
Also, just curious - how exactly did you configure wx to be c++11 compatible? Please post an exact configure line.

Thank you.,
joe31093
Earned a small fee
Earned a small fee
Posts: 12
Joined: Thu Mar 15, 2018 3:06 pm

Re: xcode c++11 and libc++, wxWidgets 3.1.1

Post by joe31093 »

Ok, I will reconfigure and rebuild wx and then reinstall it.

To change the xCode project to c++11/libc++, I went to Build Settings (by highlighting wxcocoa.xcodeproj), scroll down to Apple LLVM 9.0 - Language - C++, selected C++11 [-std=c++11] under C++ Language Dialect. Then selected libc++ under C++ Standard Library.

I will report back after the rebuild. Thanks for the help.
joe31093
Earned a small fee
Earned a small fee
Posts: 12
Joined: Thu Mar 15, 2018 3:06 pm

Re: xcode c++11 and libc++, wxWidgets 3.1.1

Post by joe31093 »

I rebuilt everything and recompiled the project and same cmath errors listed above.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7477
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: xcode c++11 and libc++, wxWidgets 3.1.1

Post by ONEEYEMAN »

Hi,
What is the exact configure line you used to build the library?
You can take it from the config.log file that can be found inside the build directory.

Thank you.
joe31093
Earned a small fee
Earned a small fee
Posts: 12
Joined: Thu Mar 15, 2018 3:06 pm

Re: xcode c++11 and libc++, wxWidgets 3.1.1

Post by joe31093 »

$ ../configure CFLAGS= CXXFLAGS=-std=c++11 -stdlib=libc++ CPPFLAGS=-stdlib=libc++ OBJCFLAGS= OBJCXXFLAGS=-std=c++11 -stdlib=libc++ LDFLAGS=-stdlib=libc++ --disable-shared

This seemed to have worked. I did not see any errors. I think what I am really after is how do I build the "minimal" project with c++11/libc++ in Xcode.
joe31093
Earned a small fee
Earned a small fee
Posts: 12
Joined: Thu Mar 15, 2018 3:06 pm

Re: xcode c++11 and libc++, wxWidgets 3.1.1

Post by joe31093 »

I made the following changes to the project settings and it built the static library without issues. But building the executable I ran in to the math errors.

In wxcocoa.xcoconfig:
MACOSX_DEPLOYMENT_TARGET = 10.9 // changed from 10.7 to 10.9
OTHER_LDFLAGS = -framework WebKit -framework IOKit -framework Carbon -framework Cocoa -framework AudioToolbox -framework OpenGL -framework AVFoundation -framework CoreMedia -framework Security -weak_framework AVKit -std=c++11 -stdlib=libc++

In the project Build Settings:
C++ Language Dialect->C++11
C++ Standard Library->libc++

Math errors in cmath.h:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:313:9: No member named 'signbit' in the global namespace
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:314:9: No member named 'fpclassify' in the global namespace
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:315:9: No member named 'isfinite' in the global namespace; did you mean 'finite'?
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:316:9: No member named 'isinf' in the global namespace
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:317:9: No member named 'isnan' in the global namespace
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:318:9: No member named 'isnormal' in the global namespace
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:319:7: No member named 'isgreater' in the global namespace; did you mean '::std::greater'?
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:320:7: No member named 'isgreaterequal' in the global namespace; did you mean '::std::greater_equal'?
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:321:9: No member named 'isless' in the global namespace
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:322:9: No member named 'islessequal' in the global namespace
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:323:9: No member named 'islessgreater' in the global namespace
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:324:9: No member named 'isunordered' in the global namespace
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath:325:9: No member named 'isunordered' in the global namespace

Dependency order issue?
joe31093
Earned a small fee
Earned a small fee
Posts: 12
Joined: Thu Mar 15, 2018 3:06 pm

Re: xcode c++11 and libc++, wxWidgets 3.1.1

Post by joe31093 »

Issue resolved:

Had "/usr/local/include" in "System Header Search Paths" by mistake. Moved the path to "User Header Search Paths" fixed the issue.

Thanks for all the help.
Post Reply