Rhino C++ and Console App


Is there any possibility to use Rhino C++ geometry library on Console App for debugging reasons?

Most of the time I just need to print values without any interface, which would make my work faster, instead of loading each time Rhino that takes quite some time.

On C# it works with RhinoCommon. But I have no idea how to link Rhino C++ to console App.

Hi @Petras_Vestartas,

You can use openNURBS in a console application. Or are you thinking of something else?

– Dale

1 Like

I think this is what I am looking for, I hope the syntax is the same as Rhino C++ plugin (except ui)
I often just use data types such as polylines, curves, points, clouds, meshes.

How do you reference the OpenNurbs? Do you need to link only headers or also libraries?

The syntax is even pretty similar to RhinoCommon, except that everything is preceded by ON_ and C++ syntax conventions are mostly followed.

These are all available, but what you can’t do is manipulate Rhino in any way.

Check this out:

I don’t know whether this is legal, but I often times just copy the relevant cpp hpp file pairs to my project. I mostly always need only a couple of types, like the ones you name above, and not the entire “framework”. You need to make sure you also copy the relevant dependencies though. The people that programmed openNurbs did a wonderful job at keeping it quite modular and easy to understand. It’s a piece of art, if you ask me.

P.S.: It’s quite funny that you have two accounts here. Or is it a clone? :wink:

Screenshot 2021-07-26 at 19.07.05

Thank you for the help, I did not know that this is exactly the solution to the problem.

I see the linking using pragmas:

// Release x64 (64 bit) libs
#pragma message( " --- openNURBS Release x64 (64 bit) build." )
#pragma comment(lib, "../opennurbs/zlib/x64/Release/zlibx64.lib")
#pragma comment(lib, "../opennurbs/x64/Release/opennurbsx64.lib")

Would it be possible to show how this is done via linker and project properties?
I kind of understand the 2nd and the 3rd pragma that links to .lib file, but I do not understand what pragma message means.

I suspect the x64 dynamic libraries after building OpenNurbs project file are located here.
Is it right? Because the name is not zlibx64.lib but zlib.lib

P.S. The two accounts appeared once I started working at EPFL, because we had to get Rhino lab license, so now I switching between different computers. It is confusing ;D

Sorry, but I’m not a Windows, nor Visual Studio user, so I can’t be of much help here.

#pragmas are preprocessor directives for the compiler. This entails that #pragma message( " --- openNURBS Release x64 (64 bit) build." ) will output exactly that message to a terminal or shell, before the compiler gets to work.
It’s probably also important to know that these are Visual C++ directives, which probably don’t work on Linux or macOS.

If I remember correctly, on macOS the build usually gets put into /usr/local/lib or somewhere similar, not inside the opennurbs directory.

Thank you.

Do you know why the visual studio cannot compile the OpenNurbs project?
Or maybe @dale could help with this error ?

How to use console app? I use templet.

@Petras_Vestartas - the repo’s README has build instructions.

– Dale


At this step I get the error above:
Open opennurbs_public.sln, select the platform and configuration, and rebuild all.

Update, the problem was that visual studio did not have certain C++ packages.
It is not enough to download Visual Studio SDK.

After clicking these ones and installing them, it worked. However I did not know if all of them had to be installed:

Dear @Dale

Me again.

I tried to add stadfx file, and I get linking error.
I rebuild project for 64 bit release as required.
What am I missing?

Severity Code Description Project File Line Suppression State
Error LNK1104 cannot open file ‘C:/IBOIS57/_Code/Software/CPP/opennurbs-7.6.21127.19001//bin/x64/Release/freetype263.lib’ PMPConsole C:\IBOIS57_Code\Software\CPP\PMP\PMPConsole\PMPConsole\LINK 1

And it worked only when:

  1. I open this project and build it manually:

  2. This does not work:

#pragma once
// defining OPENNURBS_PUBLIC_INSTALL_DIR enables automatic linking using pragmas
#define OPENNURBS_PUBLIC_INSTALL_DIR "C:/IBOIS57/_Code/Software/CPP/opennurbs-7.6.21127.19001/"
// uncomment the next line if you want to use opennurbs as a DLL
#include "C:/IBOIS57/_Code/Software/CPP/opennurbs-7.6.21127.19001/opennurbs_public.h"
  1. And only if the #define OPENNURBS_IMPORTS is uncommented, it works
#pragma once
// defining OPENNURBS_PUBLIC_INSTALL_DIR enables automatic linking using pragmas
#define OPENNURBS_PUBLIC_INSTALL_DIR "C:/IBOIS57/_Code/Software/CPP/opennurbs-7.6.21127.19001/"
// uncomment the next line if you want to use opennurbs as a DLL
#include "C:/IBOIS57/_Code/Software/CPP/opennurbs-7.6.21127.19001/opennurbs_public.h"

I can build console app with OpenNurbs, but visual studio shows a lot of errors:

The openNURBS toolkit includes several “example” console applications. Have you reviewed these?

– Dale