Problems building with the API using Qt Creator on OS X 10.11.3

Hello,

I am trying to build a .skp file reader for my application. The reader will be a plugin for my application in the form of a dynamic library which uses the SketchUpAPI to read the data.
My application is built using Qt and I use the Qt Creator IDE for development. The platform is OS X 10.11.3, currently using Qt 5.4.1 and clang with Xcode 7.2.

I am new to the SDK and need some advice about building for it with Qt Creator and qmake. Firstly, I would like to know the best way to deal with the include path used in the API headers. For example…
#include <SketchUpAPI/common.h> is used in many include files.
The “SketchUpAPI” bit refers to the path to the the header files but how do tell qmake where this is, use an alias perhaps? or is there a better way?

Secondly, I get a linker error when I try to link to the SketchUpAPI.framework. The linker says it cannot find the framework. I use the following settings in the Qt .pro file…

QMAKE_LFLAGS += …/…/SDK_Mac_16-0-19913
LIBS += -framework SketchUpAPI

Which is the recommended way to do it but it does not find the framework. The linker error is…
ld: framework not found SketchUpAPI
If the path was wrong I would a “error: no such file or directory:…” type error so I don’t think it is a problem with the path.
Is this a problem with the structure of the framework, or am I doing something wrong?

I will be very grateful for any advice on this.
Thank you.

Hello again,

I found the solution to my problems. Just in case anyone is the same situation I thought I would share it with the forum. So if anyone is interested here it is…

I handled the include path thing by using a symbolic link to the include directory. I don’t particularly like it but it works for now.

The problem with linking it was with the how to indicate the path to the framework to the linker. In the case of a framework it appears to be a little more complex than with a simple library. The lines to add to your .pro file are…

QMAKE_LFLAGS += -F/<path to your SketchUp SDK>/SketchUpAPI.framework
LIBS += -F/<path to your SketchUp SDK>/ -framework SketchUpAPI

The point of interest here being the -F flag and the path being in the LFLAGS and the LIBS sections. Something I was not familiar with up until now.

Finally the good folks at SketchUp have chosen to use the @rpath syntax instead of the more familiar @executable_path one when building the framework. This means one must add another LFLAGS line to the .pro file per…

QMAKE_LFLAGS += -rpath @executable_path/../Frameworks

To indicate to the client that uses the framework where it can be found in its app bundle. There you can see the good old @executable_path syntax being used.

So there you have it. I hope it will be of some use to anyone who uses the Qt Creator and qmake to develop cross platform applications and needs to use the SketchUp SDK.

I am sure I will need more advice as I write my converter so thanks in advance and I look forward to following the forum.

Cheers.

1 Like

Hi Kenchan-

I’m glad you got it figured out, thanks for following up with such a comprehensive solution post!

Marc

Continuing the discussion from Problems building with the API using Qt Creator on OS X 10.11.3:

Hi,

I am facing similar issue while linking SkectUpAPI framework in qt, I followed steps specified in your suggestion but it did not work for me.

QT version : 5.9.2
MAC Osx : 10.13.6
I am getting this crash error
dyld: Library not loaded: @rpath/SketchUpAPI.framework/Versions/A/SketchUpAPI
Referenced from: /path to my application
Reason: image not found
The program has unexpectedly finished.

Can anyone provide information on adding framework to

Hi sowmya.m,

Could you show the contents of your pro file, describe how you create the app bundle and possibly the contents of your app bundle?

Also, if you post this question on the Qt forum you might get the attention of more people with Qt knowledge.