I now have to porting C++ code to iOS, trying to build static library by original C++ code and load the library on iOS. Because the original code is heavy, I start a small test to verify my steps could work or not.
First I need to build library (.a), which prints some string. I compile the following code and generate a library(.a) file
//talk.h
...
#include <iostream>
class Talk {
Talk();
void printHello();
void printWord(char*);
};
//talk.cpp
#include "talk.h"
using namespace std;
void Talk::printHello() {
cout << "Hello World";
}
void Talk::printWord(char* word) {
cout << "Hello" << word;
}
The second step I try to do is open a new project for iOS app and then set link to the library file, also include corresponding "talk.h" header file. However, some errors happen on the header file even though I build library successfully.
The errors indicate that
- "iostream" file not found
- "Unknown type name 'class'; did you mean 'Class'?
- any other errors...
I have try to rename controller.m to controller.mm, but it not fixes the problem
How to import the header file written in C++ for using library on iOS? Thanks