First time here? Check our help page!
2

Link OpenStudio to C++ Applications

How do we link OpenStudio dlls (i.e bin\openstudio_utilities.dll) in a C++ application built in Visual Studio? is there an object library file we need to add to additional dependencies?

For example, if we wanted to access some of the objects and methods in the utilities\geometry folder, what project properties do we need to set?

pflaumingo's avatar
1.9k
pflaumingo
asked 2016-02-16 19:42:36 -0500
__AmirRoth__'s avatar
4.4k
__AmirRoth__
updated 2016-04-03 14:32:11 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

5

This is a pretty complex topic, but I can give you some general pointers. First, yes the openstudio_utilities.dll has other binary dependencies. That is to say it depends on other dll libraries to work. The Qt dlls for instance are one dependency. On windows these dlls need to be in the same directory as the utilities dll or they need to be installed to your system path. In order to see precisely what library dependencies are required for a particular openstudio dll, I suggest that you use Dependency Walker.

The other thing about accessing a C++ API like in OpenStudio, is that you need header files. These are the source code files ending in .hpp that define what functions are available. Your code needs to include these header files so you can use classes and functions defined in the dll libraries. Here's the catch. OpenStudio hasn't formalized the process for third parties to use the C++ API so we don't install the header files with our installer package. You need to get them from our source repository and that can be tricky because a given header file typically depends on other header files.

In my opinion the easiest way to build a third party app on OpenStudio C++ is to first checkout OS source and compile the project. Some time ago I created an example project derived from OpenStudio. It is CMake based just like OS is. It is a little out of date but you can take a look at the general idea, here.

The OS team recognizes the fact that dependencies (of which we have several big ones) are a significant burden to getting started with the C++ code. To address the issue we are actively trying to pair down these dependencies in our core libraries like OS Model and Utilities.

Finally I want to emphasize that most of the complexity is unique to accessing OpenStudio through C++. We distribute ruby bindings and C# bindings on windows out of the box. You get them automatically when you run the OS installer. Those languages don't require header files, so you load the libraries and start coding.

Kyle Benne's avatar
6k
Kyle Benne
answered 2016-02-17 10:28:30 -0500, updated 2016-02-17 10:57:46 -0500
edit flag offensive 0 remove flag delete link

Comments

Yeh, I've done a few things with both the C# and Ruby bindings, however, I was needing to use the boost libraries which I don't believe have been wrapped and made accessible through C# or Ruby bindings? I've checked out the OpenStudio source code and have built it successfully, but trying to understand all the dependencies and additional includes required is a little difficult. I'll have a look at dependency walker and your app to try and get my head around it.

pflaumingo's avatar pflaumingo (2016-02-17 13:26:50 -0500) edit

You are welcome to hit me up via email to expand on this. I can probably get you through trouble spots. I strongly recommend setting up your project in CMake. My example project was turnkey at one point in time, but like I said it is now a little out of date.

Kyle Benne's avatar Kyle Benne (2016-02-17 13:46:12 -0500) edit
add a comment see more comments