Alexander
Alexander

Reputation: 63264

C++ - Switching from G++ to Xcode (and clang)

I'm trying to use a sample program for the gloox library (a XMPP client library for C++) that I'll eventually integrate into (among others) an iOS app. An obvious (yet frustrating difficult) step in achieving this is to use the C++ code in Xcode (typically with the clang compiler).

How I compiled using G++:

g++ -o bot bot.cpp -lgloox -lpthread

What I've tried in Xcode:

Under my targets build settings:

However, when I go to compile this abomination, I get these errors:

enter image description here

Can somebody help me make sense of these?

Edit: I've searched the internet extensively for this, to no avail.

Upvotes: 1

Views: 400

Answers (1)

user149341
user149341

Reputation:

You will need to remove /usr/include from your library search paths. It's already included by default, and trying to add it a second time can make it end up overriding some headers provided by the compiler, with unfortunate results.


The link errors you got when you did this look like the gloox library isn't being used at link time, so that's failing now. This is progress! — if you're getting to the link phase, compilation is now going just fine.

Go to your project settings (click the project name at the top of the left-hand column), go to the "Build Phases" tab, open up the "Link Binary With Libraries" phase, and click the + button. Then find libgloox.dylib (probably in /usr/local/lib) and add it.

Upvotes: 1

Related Questions