Getting errors in AreaVol_x64 source code

kyuzo

New member
Hi All,

I'm taking beginner steps in coding, and am trying to make a simple modification to this plugin for my work.

I am using the x64 version of the AreaVol plugin which (according to the text file bundled with it) was: "Updated for LightWave 9.x and compiled for x64 by Michael Wolf, http://www.db-w.com", which was available here: https://forums.newtek.com/showthread.php/93321-Measure-volume-plugin-for-x64
It included the source code.

I am using Visial Studio 2019, and have set it up to use _X86_, _MSWIN; the path to Lightwaves SDK 'include' folder; and the source files. I'm reasonably confident that I haven't missed anything out from the setup detailed in the SDK, but when I load in the source code, I am getting three errors. I don't know enough about coding plugins yet to work out what exactly they mean, but I expected that by using the source code of the actual working plugin, and (hopefully) following the setup instructions of the SDK, that the plugin would load 'as-is' without any errors.

The changes I intend to make are incredibly simple, (basically include a multiplier to change the result from cubic metres to cubic centimetres, and another to change the volume to a weight in grams using a known density of the material we work with) but so far I haven't made any changes yet. I just wanted to go through the process of compiling it to understand the process.

If anyone can take a look at the errors listed on the screen shot and give me a nudge (or shove) in the right direction, I'd much appreciate it.

Have I missed a source file? Has an update to Lightwave broken this? (Unlikely as the plugin itself still works..?)

Cheers,

Derek

View attachment 149072
 

Attachments

  • VolumeWeight-3errors.png
    VolumeWeight-3errors.png
    100.1 KB · Views: 270
Line #80 change to:
if ( message = (LWMessageFuncs *) global( "Info Messages", GFUSE_TRANSIENT ))

You need type-cast from what global returns to proper type.


Line #171 change to:

{ LWMODCOMMAND_CLASS, "AreaVolume", (ActivateFunc *) AreaVolume },

Line #29 change to:
static EDError polycb( void *userdata, const EDPolygonInfo *polygon );

Line #110 change to:
static EDError polycb( void *userdata, const EDPolygonInfo *polygon ) {
MeshEditOp *edit = (MeshEditOp *) userdata;

Remove { from line #111 (it is already at the end of my new replacement)
 
Last edited:
Thank you so much Sensei, I'm guessing those changes are to do with an evolving SDK or something?

All error messages are now gone.


My next issue is when I am compiling it. I was getting a number of linking errors, and have been adding links in Visual Studio to the server.lib that the SDK instructed me to build. The one that I can't seem to get past is:
1>LINK : fatal error LNK1104: cannot open file 'D:\CPP programmming\server\Debug.obj'

In Properties: Linker: Additional Dependencies I have added a path "D:\CPP programmming\server\Debug", but that doesn't seem to be what it wants. The debug.obj does exist.
Do I need to point to it somewhere else as well?

I really appreciate your assistance.

Derek
 
Ernie's original link is down. So I assume you downloaded source code from post #11 from Lightwolf?
I don't have there any 'D:\CPP programmming\server\Debug.obj' nor 'Debug.obj'..

There are just three files:
areavol.c
areavol.txt
areavol.p

So, where/how did you get this Debug.obj??


Try this:
- unpack lwsdk2020.0.1
there is Visual Studio project file there: lwsdk_vc2013
- double click it
- change Debug to Release
- change to x64 (if something else)
- RMB on server_64_dll, open properties, find Platform Target, and set the one that you have installed.
- RMB on server_64_dll, pick Rebuild
It should make server.lib in one of folders.

You need to use it from the main project.



Alternative, which I used a lot, to compilation of static lib, is simply to drag'n'drop files which are used by server_64_dll project, to the main project.
 
Hi Sensei,

Thanks for that. I have mde some progress.

I'm on LW2019, so am using lwsdk2019.0. Hopefully that isn't contributing to any issues.

"Ernie's original link is down. So I assume you downloaded source code from post #11 from Lightwolf?"
- Yes, you are correct.

The debug.obj was created when I tried to follow this section from the 'compiling section of the manual':

"To build an MSVC version of the SDK library,

Create a new project workspace, or insert a new project into an existing workspace. The project type should be "Static Library." Name the project "server".
Settings dialog, C/C++ tab, add _X86_ (or _ALPHA_) and _MSWIN to the preprocessor definitions field.
In the field for additional include directories, type the path to the plug-in SDK include directory.
Add servdesc.c, username.c, startup.c, and shutdown.c to the project. These are located in the SDK\source directory.
Build server.lib."

- It is entirely possibe that I messed that bit up too.. :)

Following your instructions, I got as far as "- RMB on server_64_dll, open properties, find Platform Target, and set the one that you have installed." I've right-clicked on server_64_dll and openend the properties, but haven't found 'Platform Target' yet, and so am unsure at the moment what 'one' I will be setting it to when I do find it.

I shall continue digging around in Visual Studio, and let you know how I get on.

I'm sure once I've got this done one, it'll become easier... i.e. once I know what I'm doing. :)


Thank you
 
Ignore current project, and make new one.

Drag'n'drop servdesc.c, username.c, startup.c, and shutdown.c to the project.
Drag'n'drop areavol.c
(or copy, and rename their extensions to .cpp)

set _MSWIN
set include folder path
set extension to .p
etc. etc.

I just noticed in your screen-shot that you did not go "static lib route", but also added lwsdk\source files to the project.
You should go one way, or go another way, not both at the same times, because you will have duplicated entries during linking.

But you added one too many files.
servmain.c should not be there..
Instead use serv.def file:
In Linker > Input > Definition Module File use lwsdk\source\serv.def

And disable precompiled headers (you should have no pch.cpp)
(It might be trouble making if you have couple files .c and other one .cpp .. I have seen such issues, and had to fix it by mass rename of files to .cpp )
 
Thanks Sensei.

I'd like to think we're (well, you're) getting close to solving this. I have followed your points, and built up a screen grab of each stage so you can see if or where I'm going wrong.

View attachment 149076

When I try to build the project, I get the following notifications:

1>------ Build started: Project: Test, Configuration: Debug Win32 ------
1>pch.cpp
1>servdesc.c
1>D:\CPP programmming\lwsdk2019.0\source\servdesc.c(28,1): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "pch.h"' to your source?
1>shutdown.c
1>D:\CPP programmming\lwsdk2019.0\source\shutdown.c(19,1): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "pch.h"' to your source?
1>startup.c
1>D:\CPP programmming\lwsdk2019.0\source\startup.c(20,1): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "pch.h"' to your source?
1>username.c
1>D:\CPP programmming\lwsdk2019.0\source\username.c(19,1): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "pch.h"' to your source?
1>Generating Code...
1>Done building project "Test.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========



The only outstanding issue appears to center around "pch.h". I tried adding #include "pch.h" near the top of the code, right after #include "math.h" on line 17, but that doesn't help at all.

I'm really thankful for your help andn patience with this. I realise my coding/developing skills are embryonic, and while the SDK documentation is available and no doubt 100% accurate, it's very 'concise' information, and I'm struggling to find any 'tutorial style' information out there to help with this configuration process. Also, LW plugin developers appear to be a dying breed unfortunately. In these parts, at least...

Regards,

Derek
 

Attachments

  • TestProject-build.png
    TestProject-build.png
    210.5 KB · Views: 269
No, you should not use _X86 as it means 32 bit Intel. Ernie wrote it in times there was no 64 bit LightWave.


When turning off Precompiled Headers you need to delete the all references too e.g. pch.h and pch.c and pch.cpp ..
i.e. RMB on file, "Remove", and then "Delete".
And use "Clean", "Rebuild", not just "Build".


When you're compiling, try to edit the all settings at once by clicking on "Configuration: Debug (Active)" and change to "All".
Because you want "Release" version after all.
Otherwise you will have to copy the all settings from "Debug" config to "Release" config once again..


Also, LW plugin developers appear to be a dying breed unfortunately. In these parts, at least...

How many 3rd party plugins did you buy? Ever... Recently..
No buyers, no 3rd party plug-ins..



ps. When you're in "Error List" or "Output" mode (at least in VS 2015 which I have here), you can simply double click on error/warning entry, and VS will open line which has error/warning.
 
Last edited:
No, you should not use _X86 as it means 32 bit Intel. Ernie wrote it in times there was no 64 bit LightWave.
Well that probably shouldn't be a surprise, but it's also a bit offputting, as it gives me reason to think that the entire SDK documentation is 20 years out of date, and someone like me who is coming to it new is going to struggle to separate relevant information from deprecated information. I have no illusions that the documentation is ever going to be updated.


When turning off Precompiled Headers...
I've had a quick try but ended up getting different error messages. I will try again with a fresh project again and see how I get on.


When you're compiling, try to edit the all settings at once by clicking on "Configuration: Debug (Active)" and change to "All".
Because you want "Release" version after all.
Otherwise you will have to copy the all settings from "Debug" config to "Release" config once again..
I will need to investigate and digest this. I have had difficulty finding relevant tutorials online for Visual studio. Maybe I'm not using the right search terms.


ps. When you're in "Error List" or "Output" mode (at least in VS 2015 which I have here), you can simply double click on error/warning entry, and VS will open line which has error/warning.
Thanks, that sounds like a useful tip.



How many 3rd party plugins did you buy? Ever... Recently..
No buyers, no 3rd party plug-ins..
I remember the 'good ole days' when there were loads of users to support plugin developers, and there was a large pool of talent who could code simple plugins and the number of free plugins available was astounding. It was just the sign of a healthy community who were enthusiastic. Obviously the number of users AND 3rd party developers has declined together.
Personally speaking, over the years I have bought plugins when the budget has allowed and I have had need of them that I can justify. My work for employment tends to be quite tends to be incredibly short deadlines, and fairly 'bread and butter' modelling, but I have invested in LWCad, LW Remodeler, Jovian (before it was integrated), and right before our last conversation about a plugin, I'd spent my plugin budget on Norm's rope editor. I've also bought tutorial DVDs from Splinegod, and picked up almost all the tutorials that Rebel Hill has done. I'm very much a 'teach a man to fish' rather than a 'give a man a fish' kind of person.

Back in March, I was going to 'complete the set' and pick up the outstanding RH tutorials but seeing as Craig is now MIA, that isn't happening. So here's a thought... The money I was going to pay Craig for those tutorials, I'd happily send your way if you could put together a step-by-step idiots guide to setting up a project in Visual Studio: from creating a new project; all the settings I need to configure; and the process for debugging and compiling. And maybe an updated version of one of the exercises from the SDK such as creating a simple node with a colour slider or something so I have a 'modern' example to use as a jumping off point rather than a 20-year out of date example. And any other good beginners tips and tricks you think would help. PM me if you're interested. I don't care about presentation or production values - it's just the neccessary information I' interested in.

My skills with C++ are still fairly basic, but that part I find pretty straightforward to learn as I've been coding in some shape or form since I had an Acorn Electron back in the 80s. I'm not a complete idiot, and have coded entire websites from scratch, and written plugins for an editorial system the publisher I worked for, but I am just totally unfamiliar with Visual Studio and the process of creating a lightwave plugin in it. I just need a 'jump start' in that area.

Cheers,

Derek
 
Last edited:
I can record video "how to compile your project from download to the final product" but without voice.

And maybe an updated version of one of the exercises from the SDK such as creating a simple node with a colour slider or something so I have a 'modern' example to use as a jumping off point rather than a 20-year out of date example.

I never compiled and never used these LWSDK examples.

But they are still relevant.
 
Thank you so much for all your help, Sensei.

I followed your video at the weekend, and managed to get the 'straight' source code to compile successfully. There were so many settings needing configured, there's no way I could have figured them out on my own: I was barely aware of half of them. Your video was indispensable, and it has been saved to my hard drive for future reference. :)

Unfortunately, at the weekend, I then renamed the source file, within the project to make the changes I wanted but every time I rebuiit the plugin, my changes weren't being reflected. I guess renaming things within a project is not the correct way to do things... Guessing it screws up internal links and references, etc... LOL

Anyway, I have redone the whole procedure again from scratch today, and I started with my new name for the plugin, then made my very simple changes, and it is working as intended.

Here's what I changed:

//sprintf(buf[0], "Area: %lg square meters", area);
//sprintf(buf[1], "Volume: %lg cubic meters", fabs(volume));


sprintf(buf[0], "Volume: %lg cubic cm", fabs(volume*pow(100,3)));
sprintf(buf[1], "Weight: %lg grams", fabs(volume* pow(100,3)*1.135));


And screen grab of it in action is attached. This is a very simple thing, but will save me a lot of faffing about when getting a project to the correct weight.

Well, this 'simple project' has provided me with a wealth of things about Visual Studio to go away and google so that I understand them properly, and I'm sure you could have done the whole thing in five minutes flat instead of the weeks of fumbling around it's taken me. But thanks again for your help. Really appreciate it.

Regards,

Derek
 

Attachments

  • ScreenGrab.JPG
    ScreenGrab.JPG
    25.2 KB · Views: 265
Unfortunately, at the weekend, I then renamed the source file, within the project to make the changes I wanted but every time I rebuiit the plugin, my changes weren't being reflected. I guess renaming things within a project is not the correct way to do things... Guessing it screws up internal links and references, etc... LOL

In this video tutorial I showed how to properly rename project, files and plug-in name:
https://forums.newtek.com/showthrea...oject-In-Visual-Studio-Tutorial-Full-HD-video

ps. Did you notice that original code is giving incorrect results?
I made Box 1,1,1 meters wide, and it should show 1 m^3 volume...
Check carefully results..
 
Back
Top