Jump to content

inlinecpp


Macha

Recommended Posts

I just installed the latest Ubuntu on my Mac's virtual machine to confirm what I thought it would need. Here's how my setup went:

- Installed latest Houdini and tried to run hcustom on SOP_Star.C.

- Fails because it can't find csh so installed that.

- Next it fails because it cannot find g++ so installed it.

- Compiles correctly but then fails to link against GLU, GL, X11, Xext, Xi.

- Installed libxi-dev. Now fails to link with just GLU and GL.

- Installed libglu1-mesa-dev. Success.

Link to comment
Share on other sites

  • Replies 44
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Thanks Graham and Peter.

I followed both your advice.

When I try to compile the SOP_Star.c I get the this error:

/usr/bin/ld: cannot find -lGLU
/usr/bin/ld: cannot find -lGL
collect2: ld returned 1 exit status
Link failed

Does that mean I have the wrong compiler, or something else is missing.

I have gcc4.3 and gcc4.4

Edited by Macha
Link to comment
Share on other sites

That looks like the error I was getting and in which should be solved by installing something that contains libGLU, in my case libglu1-mesa-dev. If that doesn't work you can always search for other packages with similar libs in them.

Link to comment
Share on other sites

Glad it's working. Just for kicks I've attached a copy of my custom inline_module which has a bunch of different examples of C++ stuff for Python you can try out. A few things are examples either Luke or I created back when he wrote it but I think most of what's interesting in here is my own things that mostly deal with geometry. Highlights include inserting/removing vertices from primitives, finding points near positions, copying attribute values from one point to another and finding connected points/primitives given a point. Everything should work fine though I haven't had the chance to really look at it much lately.

inline_module.tar.gz

Link to comment
Share on other sites

  • 3 weeks later...

As you can see I am still learning this stuff. I am experimenting with these few lines:

geo = hou.pwd().geometry()

import inlinecpp
geomodule = inlinecpp.createLibrary("cpp_geo_methods_lalala", includes="#include <GU/GU_Detail.h>",function_sources=["""
int numPoints_lalala(const GU_Detail *gdp){ return gdp->points().entries(); }"""])

print geomodule.numPoints_lalala(geo)

I am trying to understand the HDK documentation and how this whole thing is structured.

What is points().entries() ? If it was Python I'd look around in HOM docs and find it somewhere but in HDK docs I can't find a reference to it. I would have thought it comes from GU_Detail.h. I can guess its meaning (in this case) but why can't I find it documented?

What am I missing?

Edited by Macha
Link to comment
Share on other sites

"->points()" is inherited from GEO_Detail and returns a pointlist of all points in the gdp. you´ll need to look at GEO_Detail or at the GU_Detail member list in the hdk docs. "points().entries()" returns the number of points.

hth.

petz

Link to comment
Share on other sites

  • 2 weeks later...

I am going through Graham's file and there's a few questions I have. They may be more cpp related, but anyway:

I often see something like this

(GEO_Face *)gdp->primitives()[primnum]

Why do we use (GEO_Face *)gdp-> and not simply gdp-> ?

--

I also often come across the following arguments in the function definition:

foo(GU_Detail *gdp,...

or

foo(const GU_Detail *gdp,...

What is the reason for having it a const sometimes? Is it to protect the argument from being changed later on, or is it more efficient, or something else?

Link to comment
Share on other sites

Oh, I think I get it... we need to cast gdp into GEO_Face. But why *? Because it is a pointer? But it already is a pointer?

(I am trying to loop over all the prims of a geometry, hard to figure out...)

Edited by Macha
Link to comment
Share on other sites

You often need to cast to GEO_Face because a GEO_Primitive is too general an object. For example I often want to use the baryCenter method to get the center of a primitive, however to do that I need to make sure my primitive is something that is higher order and has the related pieces to have that method.

The difference between passing a GU_Detail * and a const GU_Detail * is about how I want to be able to use this method basically. When converting from a hou.Geometry object we can either get a const or non-const GU_Detail based on where the geometry object is. If the hou.Geometry is from inside a cooking Python SOP then the geometry is able to be modified and hence is not constant. If the geometry is from say hou.node(somepathtoasop).geometry() then it is a frozen geometry object and hence a const GU_Detail *. By writing a function that takes a const detail I can call the function from geometry that is either frozen or unfrozen. If it isn't constant than I know that the function can only be used when you are in a valid context to modify the geometry.

Link to comment
Share on other sites

  • 3 weeks later...

Now that I can run this on Linux, I would like to try it on Windows.

I can compile the SOP_Star.C, but I cannot run this inlinecpp code (works in Linux):

geo = hou.pwd().geometry()

import inlinecpp
geomodule = inlinecpp.createLibrary("cpp_geo_methods_lalala", includes="#include <GU/GU_Detail.h>",function_sources=["""
int numPoints_lalala(const GU_Detail *gdp){ return gdp->points().entries(); }"""])

print geomodule.numPoints_lalala(geo)

I attached the error that I get.

I think it has to do with it not being able to find the file ...\VC\bin\amd64\cl

However, cl.exe does exist in C:\Program Files (x86)\Microsoft Visual Studio 8\VC\bin

Perhaps this should be in C:\Program Files\... instead but then I don't understand why it compiles the Star Sop.

What is the real problem?

post-4013-129844047989_thumb.jpg

Edited by Macha
Link to comment
Share on other sites

Hey guys,

I cleared my computer 2 weeks ago but I had it setup properly on Windows. It's complete setup that not only works correctly with inlineCpp but also allows to deploy plugins directly from VS without using makefiles. Just hit F5 (or it was F6 ?) and it will build it. If I find time this week I will prepare complete instruction and add VS solution to it. It's based on Realflow 5 SDK Help, odForce Wiki and partially on cybermax tutorial but it's prepared more correctly.

Link to comment
Share on other sites

I had it setup for 64 bit but it's not a problem to make it work with 32 bit. You just create four different project properties, first two that targets 32 debug and realease mode and second pair for 64 bit. Than you can easilly switch deploy type without changing projects. It pretty easy to setup, when you do once you will know what to look for next time.

Edited by SWANN
Link to comment
Share on other sites

Oh wow, thanks to a secret coding elf the problem is solved. I had to set the environment variable in the environment variable window, not the command line alone. Now I can compile both the star sop and my inlinecpp!

Wohoo! More beer for everyone!

Edited by Macha
Link to comment
Share on other sites

Hey guys,

I cleared my computer 2 weeks ago but I had it setup properly on Windows. It's complete setup that not only works correctly with inlineCpp but also allows to deploy plugins directly from VS without using makefiles. Just hit F5 (or it was F6 ?) and it will build it. If I find time this week I will prepare complete instruction and add VS solution to it. It's based on Realflow 5 SDK Help, odForce Wiki and partially on cybermax tutorial but it's prepared more correctly.

WOW, I just can not wait!!

Thanks Swann.

Link to comment
Share on other sites

Guest Swann

1. Install Visual Studio 2005 (full version, express edition doesn't work) and remember to select custom install and add in C++ selection "x64 bit compiler tools" if you wan't to target 64-bit Houdini. You will also need to install two pathes after installation completes if you plan to use it on Vista or 7.

2. You need to add MSVCDir system variable and set it's value to point to VC directory in your Visual Studio install directory.

firstq.jpg

3. run Houdini "Command Line Tools" and write:

hcustom -d foo.cpp

hit Enter and it will print something simmilar to this

secondk.jpg

In the image above I already selected interesting part, you have to do this by RMB and pick "Mark" than select text and copy it to some editor and format it to make it a little more readable.

thirdq.jpg

Left side represents all parameters formated. On the right side you can see those that are not needed so delete them. One thing to node, if you repeat this step with 32-bit Houdini you will not only get different Houdini path but VS "libpath" pathes will be updated to point to 32 compiler tools.

4. Run Visual Studio and pick | File->New->Project->Win32->Win32 Project | name it, hit OK then NEXT and select "DLL" and "Empty Project" and Finish.

You should get screen simmilar to this.

vs1r.jpg

RMB on you project name select Add->Existing Item and go to you Houdini\toolkit\samples\SOP directory and pick any pair *.C and *.h pair you want, in my case it will be SOP_Star.C and SOP_Star.h.

vs2x.jpg

Go to Solution Platforms and select "Configuration Manager"

vs25.jpg

Add there new Project Platform, make it x64 and close.

vs26.jpg

RMB on your project name and this time choose "Properties". It should open this window:

vs4i.jpg

Here we will be mostly interested in C/C++ and Linker sections.

1. If you wan't to set some options to target every platform set Configuration and Platform to "All Platforms".

In my case I will set it to for x64 and Release.

2. In "C/C++ -> General -> Additional Include Directories" set to your Houdini/toolkit/include install directory.

In "C/C++ -> Command Line" paste first part of variables you grabed from command line tools. In my case it's this part


-TP 
-Zc:forScope 
-DVERSION="11.0.667" 
-DI386 
-DWIN32 
-DSWAP_BITFIELDS 
-D_WIN32_WINNT=0x0501 
-DWINVER=0x0501  
-I . 
-I "C:/VisualStudio8/VC/include" 
-I "C:/VisualStudio8/VC/PlatformSDK/include" 
 -I "D:/Programs/HOUDIN~1.667/toolkit/include/htools" 
-I "D:/Programs/HOUDIN~1.667/toolkit/include" 
-MD 
-EHsc 
-GR 
-DSESI_LITTLE_ENDIAN 
-DMAKING_DSO 

"Linker -> General -> Output File" set to

 $(OutDir)\$(ProjectName)_release_x64.dll

For 32 bit version set it to x32 or whatever name you like, just make sure extension is set to DLL.

Make sure also that "Linker -> Advanced -> Target Machine" is set to

MachineX64 (/MACHINE:X64)

if its for x64.

To "Linker -> Command Line" paste last part of variables that you grabed, in my case it's


/libpath:"C:/VisualStudio8/VC/lib/amd64" 
/libpath:"C:/VisualStudio8/VC/PlatformSDK/lib/amd64"  
"D:/Programs/HOUDIN~1.667/custom/houdini/dsolib/*.a" 
 "D:/Programs/HOUDIN~1.667/custom/houdini/dsolib/*.lib" 

Click OK, select you solution configuration and Platform configuration. Since I prepared my project here for "relase x64" this will be my choice.

vs5j.jpg

Now, if you have this all correctly set, you can build solution from Build menu and it should compile dll for you.

Below you can find solution that is set for 32 and 64 bit versions of Houdini that I have on my computer. Use it to compare or just modify it to match your setup.

Sometimes you can get compile error 31 that says something about "mt.exe", just go to "Build -> Rebuild Solution" and it should compile OK.

In attached solution there is additional directory from Resharper. If you set your solution from scratch on your machine you will not have this directory. Don't worry, it's from plugin I use for C# development, by default it adds his own setup directory for any new solution.

There is another way to override settings in properties.

vs6b.jpg

You can use "View -> Property Manager" and there you can "Add New Project Property Sheet" and modify you setup instead of RMB on your solution name and modyfing Properties there.

If you can't see Error Window go to "View -> Other Windows -> Error Window" to turn it on.

It will show many warnings but you can ignore them, they are all from casts between different types.

I had it prepared a little different before but by accident when I was cleaning my computer I deleted Template_Solution. Anyway this should work.

Check RealFlow SDK MAnual http://thevault.realflow.com/c++_sdk__user's_manual-45.html for more info how to use Property Manager to setup project.

DOWNLOAD:

Template_HDK_Solution

Edited by SWANN
Link to comment
Share on other sites

Hey Swann,

thanks for taking the time to write all that info! I am sure it will come in handy next time I need to compile for windows.

(This would make a great addition to the odwiki too :) ).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...