Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

Command line compilation problem, standard includes not found

This example fails to compile on Sequoia 15.4 with Xcode 16.3 and the command line tools installed;

jacquesmenu@macstudio:C++Tests > cat pcount_test.cpp // clang++ -std=c++17 -o IntWrapperTest IntWrapperTest.cpp

#include <string> // std::string #include <iostream> // std::cout #include <sstream> // std::ostringstream

int main1 (int argc, char* argv[]) { std::string theString = "Prière d'éviter";

std::cout << theString << ", size(): " << theString.size () << std::endl;

std::stringstream oss;
oss << theString << std::endl;
std::cout << oss.str () << ", pcount(): " << oss.pcount () << std::endl;

}

//_______________________________________________________________________________ // position in output stream #include <fstream> // std::ofstream

int main () {

std::ofstream outfile; outfile.open ("test.txt");

outfile.write ("This is an apple",16); long pos = outfile.tellp(); outfile.seekp (pos-7); outfile.write (" sam",4);

outfile.close();

return 0; }

jacquesmenu@macstudio:C++Tests > clang++ pcount_test.cpp pcount_test.cpp:3:10: fatal error: 'string' file not found 3 | #include <string> // std::string | ^~~~~~~~ 1 error generated.

The same occurs with iostrem if it is the first include mentioned. Compiling in Xcode itself does not this problem, though.

This include is to be found here:

jacquesmenu@macstudio:C++Tests > xcode-select -p
/Applications/Xcode.app/Contents/Developer

jacquesmenu@macstudio:C++Tests > ls -sal /Applications/Xcode.app/Contents/Developer/**/string | grep MacOSX 72 -rw-r--r-- 10 root wheel 203802 Mar 8 06:17 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/string

Answered by DTS Engineer in 833151022
Maybe try to repost your code

Agreed.

Also, in Investigating Third-Party IDE Integration Problems you’ll find two things:

  • Some trivial test programs to verify your Apple tools setup. I recommend that you try compiling those.

  • Some general hints about debugging problems like this.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Maybe try to repost your code. It looks like you could be putting the #include behind a comment.

When I reformat what you've posted, and remove the pcount() function that was deprecated in the previous century, it works fine.

Maybe try to repost your code

Agreed.

Also, in Investigating Third-Party IDE Integration Problems you’ll find two things:

  • Some trivial test programs to verify your Apple tools setup. I recommend that you try compiling those.

  • Some general hints about debugging problems like this.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

The problem is not in the particular code: ni fact, I can't compile any C++ code on this machine!

I guess I'll have to reformat the volume and re-install everything...

Any better idea is welcome!

Command line compilation problem, standard includes not found
 
 
Q