2

I'm developing an ios app that's very basic and uses objective almost all of the time. However my app needs to deal with big integer numbers (eg: 2^200) and add and multiply them. To achieve that I need to include a c++ library called bigint that allows these operations on huge integers. The problem I have is that when I include the bigint project I get many errors and I thought that this could be because it's c++ and can't mix with objective c. I'm new to this idea and was wondering if there are any steps i need to take to correctly add a c++ library to an objective c project. By the way I'm not using opengl or anything complicated just simple ui and some quartz stuff.

Update: I did everything you guys said, I changed all the extensions to .mm and added the bigint library. My project ran perfectly without errors before doing these things. I get an error when i do this and I get an error even if I don't even add the library. just changing the file extensions to .mm gives me the following error. enter image description here

This just doesnt make sense since everything ran fine before and I don't have any duplicates in my program. I have no idea why just changing the extensions to .mm could cause this error. Any ideas guys?

Jonas
  • 121,568
  • 97
  • 310
  • 388
Milad
  • 115
  • 1
  • 10
  • 1
    You have to include more information than just 'I get many errors', because it is hard to prophesy what may be going wrong in your program. But for reference, I am able to include the bigint libraries in Xcode project by dragging its folder into the project as a reference. This after renaming all the implementation and header files as brainjam described in his answer. – Perception Sep 27 '11 at 05:41

1 Answers1

3

You can mix in C++ files, but use a .cpp suffix for them (and .hpp for their corresponding header files). If you want to mix C++ and Obj-C in the same file, you can do that, but give it a .mm suffix.

brainjam
  • 18,863
  • 8
  • 57
  • 82
  • I've done those things but i still get the errors, I think I need to do something more complex than that.maybe something to do with the project or target setting. – Milad Sep 27 '11 at 04:18
  • @Milad. Using C++ with Obj-C is pretty common, and there are lots of more detailed questions/answers on this subject here - e.g. http://stackoverflow.com/questions/525609/use-c-with-cocoa-instead-of-objective-c. You should be more specific about the error messages you're getting, and what you've done (provide the details by editing your original question, not by stuffing them into comments.) – brainjam Sep 27 '11 at 04:50