I have a new empty xcode project. It gives me "No such file or directory" compile error when I try to import some c++ libraries such as <iostream>
, <string>
, and <map>
What do I have to do to import c++ libraries into xcode for so I can call their functions in objective-c?
If you are just trying to write C++ code in Xcode instead of calling C++ libraries in your objectiveC project you can create a C++ project. I just created a new project using the "Command Line Tool" template and selected C++ as the language.
I could then add the following lines without the compiler complaining.
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
To use items from the std c++ libraries you prefix them with std::
int main (int argc, const char * argv[])
{
std::cout << "Hello World!";
return 0;
}
I was actually searching stack overflow for the reason std:: is necessary in Xcode...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.