-2

My professor created a C++ library in Visual Studio that we regularly use. He showed us how to add the library to a VS project, but I want to use Xcode as my IDE of choice. How can I add this library to my Xcode projects?

He has provided the .lib files for each library, as well as the .h and the .cpp files for the classes used.

Please be detailed in your response.

Mickster37
  • 155
  • 2
  • 10

1 Answers1

2

Create a new C++ project in Xcode and then drag all your .cpp and .h files into the project navigator. Make sure you tick Copy Items if needed.

If your teacher provides a Makefile, you could also try to configure Xcode to use that Makefile (more advanced than the above)

Community
  • 1
  • 1
tofi9
  • 5,775
  • 4
  • 29
  • 50
  • I don't want to just use the source code. I want to learn how to do this when all I have is the files necessary for a library. It's more of a general knowledge question, I won't always have .cpp files. – Mickster37 Feb 13 '15 at 01:22
  • "I want to learn how to do this" - to do what? You're being very unclear. Do you want to *compile source code given by your teacher*? Or do you want to write software that *uses your teacher's library*? For the latter you will need a library compiled for Mac. You can't use a `.dll` on a Mac. – tofi9 Feb 13 '15 at 01:40
  • Sorry, I haven't been very clear. I want to write software that uses my teacher's library. So how can I compile the library for Mac? – Mickster37 Feb 14 '15 at 06:18
  • By doing what's been described in my answer. Xcode can generate both libraries and executables (both for the MacOS and IOS). It seems like you're a beginner with Xcode. Generating libraries and reusing them is already an advanced topic in Xcode. I'd suggest you just include all the code that your teacher gives you, plus your own *homework* in a single *Xcode Console Application*. If your teacher wants your code to be compilable on his Windows/Linux machine, then read about using a `Makefile` with Xcode. – tofi9 Feb 14 '15 at 06:28