Xojo Plugin VS 2019 - can't create DLL (rb_plugin_deprecated.h)

Hello,

I am trying to build a Xojo module plugin manually from Visual Studio 2019 and I am running into errors. How do I make a simple dll with Visual Studio 2019 for Xojo? One error occurs when a file called rb_plugin_deprecated.h is not included. The VS settings are Release x86.

PluginMain.cpp 1>C:\\Test\\TestDLL\\TestDLL\\rb_plugin.h(21): fatal error C1083: Cannot open include file: 'rb_plugin_deprecated.h': No such file or directory 1>TestDLL.cpp 1>C:\\Test\\TestDLL\\TestDLL\\rb_plugin.h(21): fatal error C1083: Cannot open include file: 'rb_plugin_deprecated.h': No such file or directory 1>Done building project "TestDLL.vcxproj" -- FAILED.

When I include rb_plugin_deprecated.h, then I get many errors:

PluginMain.cpp 1>C:\\Test\\TestDLL\\TestDLL\\PluginMain.cpp(2480): warning C4244: 'argument': conversion from 'double' to 'RBInteger', possible loss of data 1>C:\\Test\\TestDLL\\TestDLL\\PluginMain.cpp(3117): warning C4244: 'argument': conversion from 'double' to 'RBInteger', possible loss of data 1>C:\\Test\\TestDLL\\TestDLL\\PluginMain.cpp(3225): error C4996: 'REALGetControlGraphicsWithDC': was declared deprecated 1>C:\\Test\\TestDLL\\TestDLL\\PluginMain.cpp(3214): note: see declaration of 'REALGetControlGraphicsWithDC' 1>TestDLL.cpp 1>C:\\Test\\TestDLL\\TestDLL\\PluginMain.cpp(2480): warning C4244: 'argument': conversion from 'double' to 'RBInteger', possible loss of data 1>C:\\Test\\TestDLL\\TestDLL\\PluginMain.cpp(3117): warning C4244: 'argument': conversion from 'double' to 'RBInteger', possible loss of data 1>C:\\Test\\TestDLL\\TestDLL\\PluginMain.cpp(3225): error C4996: 'REALGetControlGraphicsWithDC': was declared deprecated 1>C:\\Test\\TestDLL\\TestDLL\\PluginMain.cpp(3214): note: see declaration of 'REALGetControlGraphicsWithDC' 1>C:\\Test\\TestDLL\\TestDLL\\TestDLL.cpp(12): error C2059: syntax error: '}' 1>C:\\Test\\TestDLL\\TestDLL\\TestDLL.cpp(12): error C2143: syntax error: missing ';' before '}' 1>C:\\Test\\TestDLL\\TestDLL\\TestDLL.cpp(36): error C4996: 'REALRegisterMethod': was declared deprecated 1>C:\\Test\\TestDLL\\TestDLL\\PluginMain.cpp(2489): note: see declaration of 'REALRegisterMethod' 1>Done building project "TestDLL.vcxproj" -- FAILED. ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

Here is my code in the TestDLL.cpp file:

[code]#if WIN32
#include “WinHeader++.h”
#endif
#include “rb_plugin.h”
#include “PluginMain.cpp”
//#include “rb_plugin_deprecated.h”

static double AddTwo(double x, double y);

REALmethodDefinition TestDLLMethods[] = {
(REALproc)AddTwo, REALnoImplementation, “AddTwo(x as double, y as double) as double”, REALconsoleSafe },
};

REALmoduleDefinition TestDLLDefinition = {
kCurrentREALControlVersion,
“TwoDLL”,
TestDLLMethods,
sizeof(TestDLLMethods) / sizeof(REALmethodDefinition),
nil,
0,
nil,
0,
nil,
0,
nil,
0
};

static double AddTwo(double x, double y) {
return x + y;
}

void PluginEntry(void) {
REALRegisterModule(&TestDLLDefinition);
for (long i = 0; i < (sizeof(TestDLLMethods) / sizeof(REALmethodDefinition)); i++) {
REALRegisterMethod(&TestDLLMethods[i]);
}
}[/code]

Here are the instructions to create the plugin:

[code]Manual create Visual Studio 2019 plugin

  1. Create a new project
  2. Dynamic-Link Library with exports (DLL)
  3. Name is TestDLL, at the location C:\Test\, Create
  4. Delete files: pch.h, framework.h, dllmain.cpp, pch.cpp, TestDLL.h, and cpp.hint
  5. In the file TestDLL.h, add the above code.
  6. Properties->C/C+±>Preprocessor->Preprocessor Definitions- Add IGNOREQT, Apply
  7. Properties->C/C+±>Code Generation->Runtime Library, change to Multi-threaded (/MT)
  8. Properties->C/C+±>Code Generation->Enable C++ Exceptions, change to No
  9. Properties->C/C+±>Language->Enable Run-Time Type Information, change to No
  10. Properties->C/C+±>Precompiled Headers->Precompiled Header, change to Not Using Precompiled Headers
    [/code]

Press Build->Rebuild Solution.

Any tips or trick to make a Xojo plugin in Visual Studio 2019? And what is the rb_plugin_deprecated.h file used with in Visual Studio 2019?

Thanks for your help! :slight_smile:

Is it the comma on the end of the line?

Hi Christian,

Good catch. I missed that. Unfortunately, I get the same errors. Here is the modified code:

[code]#if WIN32
#include “WinHeader++.h”
#endif
#include “rb_plugin.h”
#include “PluginMain.cpp”
//#include “rb_plugin_deprecated.h”

static double AddTwo(double x, double y);

REALmethodDefinition TestDLLMethods[] = {
(REALproc)AddTwo, REALnoImplementation, “AddTwo(x as double, y as double) as double”, REALconsoleSafe
};

REALmoduleDefinition TestDLLDefinition = {
kCurrentREALControlVersion,
“TwoDLL”,
TestDLLMethods,
sizeof(TestDLLMethods) / sizeof(REALmethodDefinition),
nil,
0,
nil,
0,
nil,
0,
nil,
0,
};

static double AddTwo(double x, double y) {
return x + y;
}

void PluginEntry(void) {
REALRegisterModule(&TestDLLDefinition);
for (long i = 0; i < (sizeof(TestDLLMethods) / sizeof(REALmethodDefinition)); i++) {
REALRegisterMethod(&TestDLLMethods[i]);
}
}[/code]

so what is output for this new code with deprecated functions commented out?

Here is the output with the rb_plugin_deprecated.h file commented out.

1>------ Rebuild All started: Project: TestDLL, Configuration: Release Win32 ------ 1>PluginMain.cpp 1>C:\\Test\\TestDLL\\TestDLL\\PluginMain.cpp(2480): warning C4244: 'argument': conversion from 'double' to 'RBInteger', possible loss of data 1>C:\\Test\\TestDLL\\TestDLL\\PluginMain.cpp(3117): warning C4244: 'argument': conversion from 'double' to 'RBInteger', possible loss of data 1>C:\\Test\\TestDLL\\TestDLL\\PluginMain.cpp(3225): error C4996: 'REALGetControlGraphicsWithDC': was declared deprecated 1>C:\\Test\\TestDLL\\TestDLL\\PluginMain.cpp(3214): note: see declaration of 'REALGetControlGraphicsWithDC' 1>TestDLL.cpp 1>C:\\Test\\TestDLL\\TestDLL\\PluginMain.cpp(2480): warning C4244: 'argument': conversion from 'double' to 'RBInteger', possible loss of data 1>C:\\Test\\TestDLL\\TestDLL\\PluginMain.cpp(3117): warning C4244: 'argument': conversion from 'double' to 'RBInteger', possible loss of data 1>C:\\Test\\TestDLL\\TestDLL\\PluginMain.cpp(3225): error C4996: 'REALGetControlGraphicsWithDC': was declared deprecated 1>C:\\Test\\TestDLL\\TestDLL\\PluginMain.cpp(3214): note: see declaration of 'REALGetControlGraphicsWithDC' 1>C:\\Test\\TestDLL\\TestDLL\\TestDLL.cpp(36): error C4996: 'REALRegisterMethod': was declared deprecated 1>C:\\Test\\TestDLL\\TestDLL\\PluginMain.cpp(2489): note: see declaration of 'REALRegisterMethod' 1>Done building project "TestDLL.vcxproj" -- FAILED. ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

I think you should comment out the deprecation declaration or change compiler options to not error out deprecated methods.

e.g.

#if defined(_MSC_VER)
	#define REAL_DEPRECATED
//__declspec(deprecated)
	#define REAL_DEPRECATED_(reason)
//__declspec(deprecated(reason))

Thanks for your help Christian.

Is there a way to make a simple DLL example without deprecated methods?

you can leave away the include for deprecated header and not use this methods.

Thanks Christian. Unfortunately there is no indication of the deprecated commands. With the error in Visual Studio, it appears that the rb_plugin header has commands that are deprecated.

1>------ Rebuild All started: Project: TestDLL, Configuration: Release Win32 ------ 1>PluginMain.cpp 1>C:\\Test\\TestDLL\\TestDLL\\rb_plugin.h(21): fatal error C1083: Cannot open include file: 'rb_plugin_deprecated.h': No such file or directory 1>TestDLL.cpp 1>C:\\Test\\TestDLL\\TestDLL\\rb_plugin.h(21): fatal error C1083: Cannot open include file: 'rb_plugin_deprecated.h': No such file or directory 1>Done building project "TestDLL.vcxproj" -- FAILED. ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

I have searched for replaced methods for deprecated functions, and have not found any. Do you have helpful hints as to where I may find replacement functions that are not listed as deprecated?

I couldn’t seem to find the deprecated methods in the Xojo pages: Deprecations

It looks like code in the rb_plugin.h header file is deprecated. If I hear something before tomorrow then we are good. Otherwise, I’ll make a feedback report that the header file is using deprecated methods.

[quote=435007:@Eugene Dakin]void PluginEntry(void) {
REALRegisterModule(&TestDLLDefinition);
for (long i = 0; i < (sizeof(TestDLLMethods) / sizeof(REALmethodDefinition)); i++) {
REALRegisterMethod(&TestDLLMethods[i]);
}
}[/quote]

That’s really deprecated, just do : REALRegisterModule(&TestDLLDefinition);

Just leave in the deprecated header.

REALRegisterModule is sufficient. the REALRegisterMethod was the old way to register global methods. It is now tucked away in the module.

Thanks for the suggestion Alfred. I changed it to REALRegisterModule, and added the deprecated header. Unfortunately, I am getting errors in the PluginMain.cpp Glue code. Here are the errors.

1>------ Rebuild All started: Project: TestDLL, Configuration: Release Win32 ------ 1>PluginMain.cpp 1>C:\\Test\\TestDLL\\TestDLL\\PluginMain.cpp(2480): warning C4244: 'argument': conversion from 'double' to 'RBInteger', possible loss of data 1>C:\\Test\\TestDLL\\TestDLL\\PluginMain.cpp(3117): warning C4244: 'argument': conversion from 'double' to 'RBInteger', possible loss of data 1>C:\\Test\\TestDLL\\TestDLL\\PluginMain.cpp(3225): error C4996: 'REALGetControlGraphicsWithDC': was declared deprecated 1>C:\\Test\\TestDLL\\TestDLL\\PluginMain.cpp(3214): note: see declaration of 'REALGetControlGraphicsWithDC' 1>TestDLL.cpp 1>C:\\Test\\TestDLL\\TestDLL\\PluginMain.cpp(2480): warning C4244: 'argument': conversion from 'double' to 'RBInteger', possible loss of data 1>C:\\Test\\TestDLL\\TestDLL\\PluginMain.cpp(3117): warning C4244: 'argument': conversion from 'double' to 'RBInteger', possible loss of data 1>C:\\Test\\TestDLL\\TestDLL\\PluginMain.cpp(3225): error C4996: 'REALGetControlGraphicsWithDC': was declared deprecated 1>C:\\Test\\TestDLL\\TestDLL\\PluginMain.cpp(3214): note: see declaration of 'REALGetControlGraphicsWithDC' 1>C:\\Test\\TestDLL\\TestDLL\\TestDLL.cpp(43): error C2664: 'void REALRegisterModule(REALmoduleDefinition *)': cannot convert argument 1 from 'REALmethodDefinition *' to 'REALmoduleDefinition *' 1>C:\\Test\\TestDLL\\TestDLL\\TestDLL.cpp(43): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast 1>Done building project "TestDLL.vcxproj" -- FAILED. ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

Here is the updated TestDLL.cpp code:

[code]#if WIN32
#include “WinHeader++.h”
#endif
#include “rb_plugin.h”
#include “PluginMain.cpp”
//#include “rb_plugin_deprecated.h”

//#if defined(_MSC_VER)
//#define REAL_DEPRECATED
//_declspec(deprecated)
//#define REAL_DEPRECATED
(reason)
//__declspec(deprecated(reason))
//#endif

static double AddTwo(double x, double y);

REALmethodDefinition TestDLLMethods[] = {
(REALproc)AddTwo, REALnoImplementation, “AddTwo(x as double, y as double) as double”, REALconsoleSafe
};

REALmoduleDefinition TestDLLDefinition = {
kCurrentREALControlVersion,
“TwoDLL”,
TestDLLMethods,
sizeof(TestDLLMethods) / sizeof(REALmethodDefinition),
nil,
0,
nil,
0,
nil,
0,
nil,
0,
};

static double AddTwo(double x, double y) {
return x + y;
}

void PluginEntry(void) {
REALRegisterModule(&TestDLLDefinition);
for (long i = 0; i < (sizeof(TestDLLMethods) / sizeof(REALmethodDefinition)); i++) {
REALRegisterModule(&TestDLLMethods[i]);
}
}[/code]

Not sure why its not compiling… any suggestions are appreciated.

Eugene,
you are creating havoc with the SDK. Checkout rb_plugin.h :

[code]#ifndef RB_PLUGIN_H
#define RB_PLUGIN_H

#include “REALplugin.h”
#if defined( __cplusplus )
#include “rb_plugin_cpp.h”
#endif

// This will be used in stage 2 of phasing out the
// deprecated functionality. It’s not used now because
// it would require users to have to modify existing
// projects so they compile.
#include “rb_plugin_deprecated.h”
#include <stdbool.h>
[/code]

Don’t remove headers from inclusion. Leaving in “rb_plugin_deprecated.h” ensures that the latter half of PluginMain.cpp is creating havoc given the line numbers PluginMain.cpp(3225): error C4996: ‘REALGetControlGraphicsWithDC’:

There should not be a problem leaving it as is, and for your info, some calls that are deprecated are still a necessity!

Lastly: as I said:

void PluginEntry(void) { REALRegisterModule(&TestDLLDefinition); }

Because you are registering the methods already in the module. Xojo sees REALRegisterModule and then parses out all the methods, properties, whatever is IN THE MODULE. You shouldn’t tell Xojo to register them by REALRegisterModule(&TestDLLMethods[i]);

This, REALRegisterModule(&TestDLLMethods[I]), is also going to create havoc/

Thanks for pointing out the rb_plugin.h file and for removing the if-loop array in the PluginEntry method. I am getting errors in various methods within PluginMain.cpp:

1>------ Rebuild All started: Project: TestDLL, Configuration: Release Win32 ------ 1>PluginMain.cpp 1>C:\\Test\\TestDLL\\TestDLL\\PluginMain.cpp(2480): warning C4244: 'argument': conversion from 'double' to 'RBInteger', possible loss of data 1>C:\\Test\\TestDLL\\TestDLL\\PluginMain.cpp(3117): warning C4244: 'argument': conversion from 'double' to 'RBInteger', possible loss of data 1>C:\\Test\\TestDLL\\TestDLL\\PluginMain.cpp(3225): error C4996: 'REALGetControlGraphicsWithDC': was declared deprecated 1>C:\\Test\\TestDLL\\TestDLL\\PluginMain.cpp(3214): note: see declaration of 'REALGetControlGraphicsWithDC' 1>TestDLL.cpp 1>C:\\Test\\TestDLL\\TestDLL\\PluginMain.cpp(2480): warning C4244: 'argument': conversion from 'double' to 'RBInteger', possible loss of data 1>C:\\Test\\TestDLL\\TestDLL\\PluginMain.cpp(3117): warning C4244: 'argument': conversion from 'double' to 'RBInteger', possible loss of data 1>C:\\Test\\TestDLL\\TestDLL\\PluginMain.cpp(3225): error C4996: 'REALGetControlGraphicsWithDC': was declared deprecated 1>C:\\Test\\TestDLL\\TestDLL\\PluginMain.cpp(3214): note: see declaration of 'REALGetControlGraphicsWithDC' 1>Done building project "TestDLL.vcxproj" -- FAILED. ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

Line 2480 in PluginMain.cpp compains about conversion from double to RBInteger.

void GraphicsDrawLine(REALgraphics graphicsObject, double x1, double y1, double x2, double y2) { if (REALGetRBVersion() < 2018.02) { static void(*pGraphicsDrawLine)(REALgraphics, RBInteger, RBInteger, RBInteger, RBInteger) = nil; if (!pGraphicsDrawLine) pGraphicsDrawLine = (void(*)(REALgraphics, RBInteger, RBInteger, RBInteger, RBInteger)) CallResolver("RuntimeGraphicsDrawLine"); if (pGraphicsDrawLine) pGraphicsDrawLine(graphicsObject, x1, y1, x2, y2); //Line 2480 } else { static void(*pGraphicsDrawLine)(REALgraphics, double, double, double, double) = nil; if (!pGraphicsDrawLine) pGraphicsDrawLine = (void(*)(REALgraphics, double, double, double, double)) CallResolver("RuntimeGraphicsDrawLine"); if (pGraphicsDrawLine) pGraphicsDrawLine(graphicsObject, x1, y1, x2, y2); } }

GraphicsDrawLine is also deprecated in rb_plugin_deprecated.h (line 238).

To ignore deprecation, I turned off SDL (Security Lifecycle Development Checks) by clicking:
Properties->C/C+±>General->SDL check, change to No
An I get the same errors.

I also added _CRT_SECURE_NO_WARNINGS to ignore deprecated warnings in:
Properties->C/C+±>Preprocessor->Preprocessor Definitions

Still getting the above same errors. Not sure what else needs to be tweaked. I appreciate your help :slight_smile:

Edit: Here is the modified TestDLL.cpp code:

[code]#if WIN32
#include “WinHeader++.h”
#endif
#include “rb_plugin.h”
#include “PluginMain.cpp”
#include “rb_plugin_deprecated.h”

static double AddTwo(double x, double y);

REALmethodDefinition TestDLLMethods[] = {
(REALproc)AddTwo, REALnoImplementation, “AddTwo(x as double, y as double) as double”, REALconsoleSafe
};

REALmoduleDefinition TestDLLDefinition = {
kCurrentREALControlVersion,
“TwoDLL”,
TestDLLMethods,
sizeof(TestDLLMethods) / sizeof(REALmethodDefinition),
nil,
0,
nil,
0,
nil,
0,
nil,
0,
};

static double AddTwo(double x, double y) {
return x + y;
}

void PluginEntry(void) {
REALRegisterModule(&TestDLLDefinition);
}[/code]

First thing first. You should not include PluginMain.cpp. That is a source file, not a header. Or in other words a cpp is a member of the target. So is your cpp file that defines and registers a module.

Second,

#include "rb_plugin.h" 

is sufficient because rb_plugin.h already includes “rb_plugin_deprecated.h”. The compiler will know.

so remove:

#include "PluginMain.cpp" #include "rb_plugin_deprecated.h"

and check Visual c compiler settings. It should not treat deprecation as error.

Thanks Alfred and Christian, My inclusion of #include “PluginMain.cpp” was causing the problems.

Problem solved :slight_smile: