Xcode compile error in juce_File.cpp

Hi - I upgraded to Xcode 13 and started seeing this error. I then downgraded to Xcode 12.5 and I am still seeing this error. It seems to be an include path problem. Can anyone help advise on how to fix this? Thanks!!

In file included from /Users/brent/Documents/SoftwareDev/SoftwareDev/DialogRecorder/JuceLibraryCode/include_juce_core.mm:8:
In file included from /Users/brent/JUCE/modules/juce_core/juce_core.mm:23:
In file included from /Users/brent/JUCE/modules/juce_core/juce_core.cpp:138:
/Users/brent/JUCE/modules/juce_core/files/juce_File.cpp:977:9: error: use of undeclared identifier ‘symlink’
if (symlink (nativePathOfTarget.toRawUTF8(), linkFileToCreate.getFullPathName().toRawUTF8()) == -1)
^
In file included from /Users/brent/Documents/SoftwareDev/SoftwareDev/DialogRecorder/JuceLibraryCode/include_juce_core.mm:8:
In file included from /Users/brent/JUCE/modules/juce_core/juce_core.mm:23:
In file included from /Users/brent/JUCE/modules/juce_core/juce_core.cpp:156:
/Users/brent/JUCE/modules/juce_core/network/juce_Socket.cpp:137:19: error: no type named ‘close’ in the global namespace
::close (h);
~~^
/Users/brent/JUCE/modules/juce_core/network/juce_Socket.cpp:412:23: error: no type named ‘close’ in the global namespace
::close (newHandle);
~~^
In file included from /Users/brent/Documents/SoftwareDev/SoftwareDev/DialogRecorder/JuceLibraryCode/include_juce_core.mm:8:
In file included from /Users/brent/JUCE/modules/juce_core/juce_core.mm:23:
In file included from /Users/brent/JUCE/modules/juce_core/juce_core.cpp:164:
/Users/brent/JUCE/modules/juce_core/system/juce_SystemStats.cpp:204:13: error: use of undeclared identifier ‘getpid’
::kill (getpid(), SIGKILL);
^
In file included from /Users/brent/Documents/SoftwareDev/SoftwareDev/DialogRecorder/JuceLibraryCode/include_juce_core.mm:8:
In file included from /Users/brent/JUCE/modules/juce_core/juce_core.mm:23:
In file included from /Users/brent/JUCE/modules/juce_core/juce_core.cpp:197:
/Users/brent/JUCE/modules/juce_core/native/juce_posix_SharedCode.h:115:16: error: use of undeclared identifier ‘getcwd’
auto cwd = getcwd (localBuffer, sizeof (localBuffer) - 1);
^
/Users/brent/JUCE/modules/juce_core/native/juce_posix_SharedCode.h:121:15: error: use of undeclared identifier ‘getcwd’
cwd = getcwd (heapBuffer, bufferSize - 1);

It looks like it’s complaining about functions declared in the unistd.h header. I think this header is normally included in Xcode (or the commandline tools), rather than being included with the OS. You could try updating your development paths by running the following in a terminal:

sudo xcode-select --switch /Applications/Xcode.app # or whatever the actual path is
sudo xcode-select --install

Then, try rebuilding your project.

Hmm, unfortantly that did not fix the problem for me. (I thought it did at first because I got a new error in my code, I did not get before)… I will try a complete Xcode uninstall and reinstall…

Are you using c++14 or c++20?

I was sent a project which was set to use the latest C++ Language Standard and I got some weird errors

Rail

I am set to c++ 14…

I tried completely uninstalling Xcode from my system by following these steps: Uninstall Xcode From MacOS. How to Uninstall Xcode Developer Tools… | by Onexlab | Medium

reinstalled Xcode 12.5

I am getting the same error… :frowning:

I also tried adding #include <unistd.h> to the top of juce_File.cpp, no difference…

I found it. libsamplerate was including a dummy unistd.h file. Thanks for the help!!

2 Likes