Copy link to clipboard
Copied
I have a working project in CS6 that uses the boost::regex framework that I'm having problems porting into CC2014.
I ported this project by using Dolly to create a new project, then coping the old source files across, finally updating the various out dated InDesign API calls that appeared when I compiled. For the use of regular expressions I added the debug and release builds of the boost_regex.framework to the respective targets.
Now, for the debug build the new CC2014 projects builds happily. But when I switch to the release build I get a few linker errors. They are all something like:
Undefined symbols for architecture x86_64:
"boost::re_detail::get_mem_block()", referenced from:
boost::re_details::perl_matcher<__gnu_cxx::__normal_iterator<char const *, std::string>, std::allocator<boost::sub_match<__gnu_cxx::__normal_iterator<char const *, std::string> > >, boost::regex::regex_traits<char, boost::cpp_regex_traits<char> > >::find_imp() in SbRegex.o
etc.
I did a bit of reading through the boost header files. The odd thing is that the "get_mem_block()" appears to be defined for the pre-processor option BOOST_REGEX_NON_RECURSIVE, while in the project settings for BOOST_PREPROCESSOR_DEFINITIONS contains BOOST_REGEX_RECURSIVE. These two settings are mutually exclusive and there's pre-processor logic that blocks having both cases defined at once.
This recursive option is used to control how memory is used while processing a regular expression, so seeing a get_mem_block() call (other link errors involve a call to put_mem_block) sort of makes sense being calls that look like something to do with memory.
I'm trying to figure out why debug builds, but release build fails. Does this problem look familiar to anyone? Anyone have any suggestions to try to fix it?
1 Correct answer
Figured out how to build the project when adding the boost regular expression framework.
The key is the optimisation level. When Dolly creates a project it sets the optimization level for the release build to "-O3". When using boost::regex you can only link correctly if you use optimization levels O0 or O1. Any higher and those link errors that I saw appear.
So for release build, I set in the Release_Cocoa64 build settings "Optimization Level" to "Fast [-O, O1]" and it compiles.
Copy link to clipboard
Copied
Have you read this thread?
Getting Linker errors while porting InDesign CC plugin code to InDesign CC 2014
Copy link to clipboard
Copied
Thanks for the reply, Bartok, but those didn't seem to work for me. Maybe I applied them incorrectly as that thread was for the Win platform and not Xcode and I might have translated the solution poorly.
Basically I went to the "Release_Cocoa64" target, and scrolled down the "Build Settings" page. I then edited the BOOST_PREPROCESSOR_DEFINITIONS field.
First I tried just appending BOOST_SYSTEM_NO_DEPRECATED.
Second I thought that this might be a macro of some sort so I tried $(BOOST_SYSTEM_NO_DEPRECATED).
Finally, I deleted all the previous values and added "BOOST_ALL_DYN_LINK BOOST_REGEX_USE_CPP_LOCALE BOOST_REGEX_RECURSIVE BOOST_HAS_ICU=1 BOOST_ FILESYSTEM_VERSION=3 BOOST_CHRONO_HEADER_ONLY BOOST_SIGNALS_NO_DEPRECATION_WARNING".
As you might guess from the experimentation I got none of these to work. The error that I was getting has remained exactly the same.
One difference that I assumed between the Win and Xcode version is that Win separates the values with a semi-colon whereas Xcode separates with a space.
My only other thought is maybe I edited the wrong field. Is BOOST_PREPROCESSOR_DEFINITIONS the one?
--
As a final comment, the thread you gave me and my issue really comparable? I have other projects that don't use the boost::regex libraries and they build and run without issue. It's only when I try to use boost's regular expressions in a release build that I get problems when linking (debug build is still fine).
Also the link error looks different. The thread that you gave me points at "boost::system::error_category" as not being resolved, while I have problems resolving "boost::re_detail::get_mem_block".
I don't seem to have problems with basic boost - just the regular expression stuff.
Copy link to clipboard
Copied
Figured out how to build the project when adding the boost regular expression framework.
The key is the optimisation level. When Dolly creates a project it sets the optimization level for the release build to "-O3". When using boost::regex you can only link correctly if you use optimization levels O0 or O1. Any higher and those link errors that I saw appear.
So for release build, I set in the Release_Cocoa64 build settings "Optimization Level" to "Fast [-O, O1]" and it compiles.
Copy link to clipboard
Copied
Thanks a lot Andrew !
I was porting a plugin with boost::regex functions from CS6 to CC 2015 using XCode and encountered the same issue.
I added the boost_regex.framework (and the ICUUnicode.framework because I use the u32regex functions), and set the Optimization Level to "Fast" as you said, it works perfectly !
I'm curious to know how did you find about the optimization level limit
Regards,
Guillaume
Copy link to clipboard
Copied
I know this post is old, but just in case someone else than me has an "ethical" problem with using the -O0 level, there is an alternate possibility :
You can just add 'BOOST_REGEX_RECURSIVE' to 'Build Settings -> Preprocessor Macro' in your target.
I know this preprocessor macro is already set in 'BOOST_PREPROCESSOR_DEFINITION', but it seems to be somehow overriden when using strong optimisation flags. Forcing it in the global target preprocessor macros seems to do the trick.
Note that this should not be used with IndesignCC2015, which has BOOST_REGEX_NON_RECURSIVE by default (so the boost binaries shipped with it do have the "get_mem_block()" function defined)
Thanks anyway for the previous answer, which works too!

