Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

oF 64 bit, c++11 support (only merge once os x apothecary build binaries are in master) #3627

Merged
merged 22 commits into from
May 14, 2015

Conversation

tgfrerer
Copy link
Member

@tgfrerer tgfrerer commented Feb 6, 2015

I guess an image says it better than 1.000 words =):

screenshot 2015-02-06 16 18 30

This sets up the OS X openFrameworksLib project files and the openFrameworks project template so that you can select via drop-down whether you want to compile your openFrameworks app as 64 bit c++11, or, legacy 32 bit cpp98. Addresses #2016, #1864


Use

  1. Use the project generator to create or update an openFrameworks project.
  2. Open your project. You'll see this in the XCode top bar:
    screenshot 2015-02-06 16 15 20
  3. Select the build target (in my case emptyExample Debug) to either compile the Debug or the Release configuration.
    screenshot 2015-02-06 16 37 59
  4. Then select the target architecture (32 or 64 bit).
    screenshot 2015-02-06 16 18 30

You can click the architecture dropdown to switch between architectures. Don't worry about selecting the target architecture for openFrameworks itself, that one is automatically detected from your current build target.

Also, the correct stdlib is automatically used to link everything together. In 32 bit mode, you can use cpp98 like you always did. =)
screenshot 2015-02-06 16 42 39
screenshot 2015-02-06 16 19 33

But, once you switch over to 64 bit mode, you get full c++11 support:
screenshot 2015-02-06 16 16 44


How this works

In XCode, you can set per architecture build flags. These build flags make sure that the 64 bit and the 32 bit version are compiled with the correct toolchains. The Project is set to Universal (which gives you the architecture selection dropdown), but the projects themselves are set up to only build the active architecture. This gives you either a 32 bit binary or a 64 bit binary.

I put the necessary project build settings into the CoreOF.xcconfig file. This file is included in both the App project compile settings and the openFrameworksLib project compile settings.

For the app settings, it is included at Target level, meaning the settings in CoreOF.xcconfig it will take precedent over the settings selected in the project build settings panel. (If you need to, you can still override the settings using the target build settings panel).

To update "old" project files to 64 bit, using the projectGenerator with "update project" in devApps should do.


Pre-Requisites

This works once apothecary has been used to compile out all necessary fat libs:

./apothecary update glfw
./apothecary update FreeImage
./apothecary update cairo
./apothecary update openssl
./apothecary update poco
./apothecary update tess2
./apothecary update fmodex

Preview

If you don't want to compile everything, i have a branch in my repo currently that has all that applied, and the libraries compiled, so if you pull from this, you should be able to test 64 bit / 32 bit openFrameworks quickly: https://github.com/tgfrerer/openFrameworks/tree/of_64_bit_c%2B%2B11-precompiled

+ allows core to be compiled as c++11 and linked against libc++
+ puts compilation flags into xcconfig instead of project files.

+ compilation flags are laid out so that core can be compiled 32 bit or 64 bit, and will take the current user selected arch as a hint which architecture should be compiled. Also, the correct c++ settings and stdlinb settings are used, based on user selected arch. This works through architecture specific build flags.
includes Project.xcconfig at target level, thus making sure proper 64/32 bit settings are set up, unless someone wants to set their own target settings in their project files.
CLANG_CXX_LIBRARY[arch=x86_64] = libc++
CLANG_CXX_LANGUAGE_STANDARD[arch=x86_64] = c++11

MACOSX_DEPLOYMENT_TARGET = 10.7 // libstdc++ is only available in 10.7+
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, so we cannot support Mac OS X 10.6? That is perfectly fine with me as I was advocating we drop 10.6 and 10.7, see #3507 and #3543 😉

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, cpp11 apparently requires 10.7+

@kylemcdonald
Copy link
Contributor

thanks! looking forward to merging this once the apothecary libs are built :)

@kylemcdonald kylemcdonald added this to the 0.9.0 milestone Feb 6, 2015
@armadillu
Copy link
Contributor

Thx so much for making this happen guys!

@pizthewiz
Copy link
Member

Technically we could merge this and i386 would continue to work. I think for x86_64, we'd need to merge #3624 and sort out the GLFW fork and upstream changes #3621 and we should be good, no? 😁

@ofTheo
Copy link
Member

ofTheo commented Feb 6, 2015

I think its okay if we want to merge this now as long as it works fine and defaults to i386.
Probably easier to merge this now than risk merge conflicts as it waits for libs.

@tgfrerer
Copy link
Member Author

tgfrerer commented Feb 6, 2015

I'd wait just for a little bit more if possible-

the PR is quite slim and since it only touches the project files shouldn't code rot that fast, but if merged, you might end up with a not-yet-functional 64 bit target (the i386 target should be fine) which might confuse folks using master as their development branch...

That said, if there's consensus to merge earlier, I can try to figure out to make sure it defaults to i386 =)

@admsyn
Copy link
Member

admsyn commented Feb 8, 2015

Amazing, thanks for the great writeup as well @tgfrerer :)

@bilderbuchi
Copy link
Member

I'll just ping @openframeworks/documentation so that they're aware of this write-up which could probably be easily cannibalized for a guide on this.

@tgfrerer
Copy link
Member Author

Awesome! seems we are one merge (#3624) away from being os x 32/64 bit potion-complete.
Update: the core is potion complete for OS X =) !

@pizthewiz
Copy link
Member

@tgfrerer now that the required apothecary changes have been merged into HEAD, can this be merged as well?

@tgfrerer
Copy link
Member Author

@pizthewiz it will only work (for 64bit) once the apothecary compiled binaries (and the corresponding headers) are in master. In the meantime, if run apothecary on your machine and recompile all core libraries using it, you should already be able to apply this PR and run 64bit/c++11 on OS X.

I believe a recent #define change for RPI has broken the auto-merge for this PR. It's probably just manually merging that line in ofTypes.h. I'll see to update the PR tomorrow morning to keep it fresh.

@carthach
Copy link

Howya!

Great work with this and kudos on the clear instructions.

I had some issues loading fonts with missing symbols for freetype like this:-

Undefined symbols for architecture x86_64:
"_hb_ft_font_create", referenced from:
_af_face_globals_new in freetype.a(autofit.o)

However it works fine linking to my universal homebrew version of freetype. I then managed to get it working with openFrameworks' version by adding "--without-harfbuzz" to freetype.sh.

Not sure if this affects others, hope it might be of some use...

@tgfrerer
Copy link
Member Author

hey @carthach, that's great to know!

As far as i could find out, the harfbuzz dependency has been added to Freetype 2.5.3 and is used to scan advanced OpenType layout features (see: freetype.org). It seems sensible to exclude it for now, as FreeType seems to work fine in most cases and provides the switch you found.

Also, Freetype are apparently exploring the possibility of merging some of harfbuzz's features into their codebase.

I guess if someone absolutely needs these advanced layout features, linking to a homebrew version of freetype like you did would make a lot of sense. I wonder, did you see any differences in text rendering between the homebrew and the apothecary version of freetype once you got the latter working?

Ping @openframeworks/typography

Do you mind sending a PR to the apothecary recipe for freetype adding the switch you found?

@carthach
Copy link

Sorry maybe I wasn't clear, the homebrew script has the no harfbuzz tag as well, that's where I got the idea for the fix.

I'll do a PR no problem.

* fixes merge conflict after android #defines added
* adds platform tests onto individual lines, to make this easier to read, and to enable more reliable version control.
@kylemcdonald
Copy link
Contributor

is it possible for you to add commits for the precompiled binaries as well? then we should be able to merge and work with it immediately, correct?

it would be good to merge this while we're filling all out apothecary / c++11 / 64-bit. the repo will get bigger again, but it's temporary :)

tgfrerer and others added 2 commits May 14, 2015 11:37
+ include <memory> for emscripten, osx, ios, linux if cpp11 is available, otherwise include <tr1/memory>

i'm making this a multiline #ifdef so that future additions should be easier to add / merge.
@ofTheo
Copy link
Member

ofTheo commented May 14, 2015

@tgfrerer the OS X 64bit libs are now in master and 10.8 is set as the default target. Do you want to update your PR so we can merge it in?

arturoc and others added 10 commits May 14, 2015 18:27
+ allows core to be compiled as c++11 and linked against libc++
+ puts compilation flags into xcconfig instead of project files.

+ compilation flags are laid out so that core can be compiled 32 bit or 64 bit, and will take the current user selected arch as a hint which architecture should be compiled. Also, the correct c++ settings and stdlinb settings are used, based on user selected arch. This works through architecture specific build flags.
includes Project.xcconfig at target level, thus making sure proper 64/32 bit settings are set up, unless someone wants to set their own target settings in their project files.
* fixes merge conflict after android #defines added
* adds platform tests onto individual lines, to make this easier to read, and to enable more reliable version control.
+ include <memory> for emscripten, osx, ios, linux if cpp11 is available, otherwise include <tr1/memory>

i'm making this a multiline #ifdef so that future additions should be easier to add / merge.
…into of_64_bit_c++11

# Conflicts:
#	libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig
@tgfrerer
Copy link
Member Author

@ofTheo i've just merged it manually on my mac, and tested OSX cpp11, and cpp98, which works =)
the only merge conflict i had was in ofTypes, the ifdef for the different platforms checking for c++11 availability, which i updated manually. The coreOF conflict was just a line-ending thing.

ofTheo added a commit that referenced this pull request May 14, 2015
oF 64 bit, c++11 support (only merge once os x apothecary build binaries are in master)
@ofTheo ofTheo merged commit 60f316a into openframeworks:master May 14, 2015
@ofTheo
Copy link
Member

ofTheo commented May 14, 2015

whohoo!
thanks @tgfrerer

@armadillu
Copy link
Contributor

woah is this what I think it is?

@ofTheo
Copy link
Member

ofTheo commented May 14, 2015

@armadillu yes. you might need to use the apps/devApps/projectGenerator to regenerate the Xcode files - but then you can build both 64bit or 32bit apps.

@tgfrerer tgfrerer deleted the of_64_bit_c++11 branch October 28, 2015 21:27
@kylemcdonald kylemcdonald mentioned this pull request Nov 1, 2015
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants