[SOLVED] Cant build JUCE 5.4.2 in Xcode 8.2.1


I just switched to the newest JUCE 5.4.2.
Unfortunately I am stuck on XCode 8.2.1, because my machine is very old.

And if I trye to compile the JUCE “imagesDemo” I am getting two compiler errors:

  1. /Users/MacUser/JUCE/modules/juce_core/files/juce_File.cpp:66:50: Default initialization of an object of const type ‘const juce::File’ without a user-provided default constructor
  2. /Users/MacUser/JUCE/modules/juce_core/files/juce_TemporaryFile.cpp:35:16: Constructor for ‘juce::TemporaryFile’ must explicitly initialize the const member ‘targetFile’

I get the same error, when compiling my own project.
The files did not change in quite a long time, as far as I can see on the JUCE GitHub. So not sure, whats causing this.

Has anyone else seen this and is there a workaround?

I can get rid of the problem by reverting back to JUCE 5.4.1. But my colleague is using JUCE 5.4.2. So I am kind of forced to use JUCE 5.4.2, too.

EDIT: My current workaround is commenting out the deprecated File::nonexistent definition and the problematic first constructor (which does not take the targetFile input) in the JUCE code.


Please apply the following patch on top of JUCE 5.4.2 and see whether you can build in Xcode 8.2.1:

diff --git a/modules/juce_core/files/juce_File.h b/modules/juce_core/files/juce_File.h
index e52b138a7..87ad8f74b 100644
--- a/modules/juce_core/files/juce_File.h
+++ b/modules/juce_core/files/juce_File.h
@@ -48,7 +48,7 @@ public:

         You can use its operator= method to point it at a proper file.
-    File() = default;
+    File() noexcept  {}

     /** Creates a file from an absolute path.

File() noexcept {} was replaced by File() = default; in a23472111. I don’t know whether Xcode 8.2.1 is rightfully complaining, or whether it’s a compiler bug.

You can also try to apply the following patch instead of the previous one:

diff --git a/modules/juce_core/files/juce_File.cpp b/modules/juce_core/files/juce_File.cpp
index 66a29256b..f226ba0e9 100644
--- a/modules/juce_core/files/juce_File.cpp
+++ b/modules/juce_core/files/juce_File.cpp
@@ -63,7 +63,7 @@ File& File::operator= (File&& other) noexcept
     return *this;

-JUCE_DECLARE_DEPRECATED_STATIC (const File File::nonexistent;)
+JUCE_DECLARE_DEPRECATED_STATIC (const File File::nonexistent{};)

 static String removeEllipsis (const String& path)
diff --git a/modules/juce_core/files/juce_TemporaryFile.cpp b/modules/juce_core/files/juce_TemporaryFile.cpp
index 794d6a1a2..964500da6 100644
--- a/modules/juce_core/files/juce_TemporaryFile.cpp
+++ b/modules/juce_core/files/juce_TemporaryFile.cpp
@@ -35,7 +35,8 @@ static File createTempFile (const File& parentDirectory, String name,
 TemporaryFile::TemporaryFile (const String& suffix, const int optionFlags)
     : temporaryFile (createTempFile (File::getSpecialLocation (File::tempDirectory),
                                      "temp_" + String::toHexString (Random::getSystemRandom().nextInt()),
-                                     suffix, optionFlags))
+                                     suffix, optionFlags)),
+    targetFile()

Declaring the constructor for File like File() = default; is a feature of C++11. Can you double check, if the Language Dialect in XCode is set to at least C++11. I also found hints via google, that you might have to increment the deployment target, since some features might not have been present in the APIs of OSX 10.7.

Solely in the juce_core module, there are 78 occurrences of = default. If the OP didn’t have at least C++11 enabled, they would get way more compiler errors.

Still worth double checking… The compiler stops usually after a few errors, so it might not have hit the other 77 occurrences. But you are probably right.

Thanks for all your help and feedback.

Your first patch worked. The one, where you changed back to "
File() noexcept {} "
Did not test the second patch.
With your first patch, I can build and run without error. Thanks :slight_smile:

I already had set the latest deployment target I can use on my system = 10.11. (I think that is the default JUCE target, too).
C++11 features are activated. At least most of them. For example std::unique_ptr is working fine.
Also the construct Object() = default; seems to work fine with my compiler in general. As McMartin says, it is used widely in the JUCE database. And my compiler chews that without problem. Only when it gets to File() = default; it chokes for some reason. Must be a combination of this keyword and how the File and TemporaryFile classes are programmed.

@Alatar I’m very glad that the first patch works! However, you should really consider giving a try to the second one, since I think this will roughly match what the JUCE team (@ed95 or @t0m) will do to fix the issue (at least it would match what they did in https://github.com/WeAreROLI/JUCE/commit/06f8accd9c303c29e8a7a0e1d079f9b04a5ec1d4 to fix a similar issue).

@McMartin is correct - I’ve gone for the latter. Please let us know if there are any other problems.

1 Like

Thanks Tom for the fixes.
Just tested with the latest JUCE-Develop. Can compile now without errors.

Thank you very much, it works. Have a nice day :slight_smile: