Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question
2

Link OpenStudio to C++ Applications

asked 2016-02-16 19:42:36 -0600

pflaumingo's avatar

updated 2016-04-03 14:32:11 -0600

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?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
5

answered 2016-02-17 10:28:30 -0600

updated 2016-02-17 10:57:46 -0600

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.

edit flag offensive delete link more

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 -0600 )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 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Training Workshops

Careers

Question Tools

1 follower

Stats

Asked: 2016-02-16 19:42:36 -0600

Seen: 261 times

Last updated: Feb 17 '16