MaxSDK GUP plugin linker errors

MaxSDK GUP plugin linker errors

Anonymous
Not applicable
1,754 Views
2 Replies
Message 1 of 3

MaxSDK GUP plugin linker errors

Anonymous
Not applicable

Hi there!

 

I am new to maxsdk, but already completed multiple input-output plugins (like our own gltf exporter in C++).

I prefer adding further integration to our plugins via menu items in the main menu so I changed architecture to create a *.gup instead of *.dli and add a single button on GUP plugin start that would run a maxscript command I am reading from a file near the plugin.

 

The problem is that I cannot instantiate a GUP plugin class because of the following linker errors:

 

1>------ Build started: Project: SDPlugin, Configuration: Debug x64 ------
1>cl : Command line warning D9025: overriding '/permissive-' with '/permissive'
1>dllmain.cpp
1> Creating library C:\MagosIT\Autodesk\SpaceDesigner\impex\SDPlugin\x64\Debug\sdplugin.lib and object C:\MagosIT\Autodesk\SpaceDesigner\impex\SDPlugin\x64\Debug\sdplugin.exp
1>dllmain.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl GUP::GUP(void)" (__imp_??0GUP@@QEAA@XZ) referenced in function "public: __cdecl MaxScriptSdGui::MaxScriptSdGui(void)" (??0MaxScriptSdGui@@QEAA@XZ)
1>dllmain.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl GUP::~GUP(void)" (__imp_??1GUP@@UEAA@XZ) referenced in function "int `public: __cdecl MaxScriptSdGui::MaxScriptSdGui(void)'::`1'::dtor$0" (?dtor$0@?0???0MaxScriptSdGui@@QEAA@XZ@4HA)
1>dllmain.obj : error LNK2001: unresolved external symbol "public: virtual class BitmapManager * __cdecl GUP::Bmi(void)" (?Bmi@GUP@@UEAAPEAVBitmapManager@@XZ)
1>dllmain.obj : error LNK2001: unresolved external symbol "public: virtual unsigned __int64 __cdecl GUP::Control(unsigned long)" (?Control@GUP@@UEAA_KK@Z)
1>dllmain.obj : error LNK2001: unresolved external symbol "public: virtual int __cdecl GUP::EnumTree(class ITreeEnumProc *)" (?EnumTree@GUP@@UEAAHPEAVITreeEnumProc@@@Z)
1>dllmain.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl GUP::ExecuteFileScript(wchar_t const *)" (?ExecuteFileScript@GUP@@UEAA_NPEB_W@Z)
1>dllmain.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl GUP::ExecuteStringScript(wchar_t const *)" (?ExecuteStringScript@GUP@@UEAA_NPEB_W@Z)
1>dllmain.obj : error LNK2001: unresolved external symbol "public: virtual enum IOResult __cdecl GUP::Load(class ILoad *)" (?Load@GUP@@UEAA?AW4IOResult@@PEAVILoad@@@Z)
1>dllmain.obj : error LNK2001: unresolved external symbol "public: virtual class Interface * __cdecl GUP::Max(void)" (?Max@GUP@@UEAAPEAVInterface@@XZ)
1>dllmain.obj : error LNK2001: unresolved external symbol "public: virtual class DllDir * __cdecl GUP::MaxDllDir(void)" (?MaxDllDir@GUP@@UEAAPEAVDllDir@@XZ)
1>dllmain.obj : error LNK2001: unresolved external symbol "public: virtual struct HINSTANCE__ * __cdecl GUP::MaxInst(void)" (?MaxInst@GUP@@UEAAPEAUHINSTANCE__@@XZ)
1>dllmain.obj : error LNK2001: unresolved external symbol "public: virtual struct HWND__ * __cdecl GUP::MaxWnd(void)" (?MaxWnd@GUP@@UEAAPEAUHWND__@@XZ)
1>dllmain.obj : error LNK2001: unresolved external symbol "public: virtual enum IOResult __cdecl GUP::Save(class ISave *)" (?Save@GUP@@UEAA?AW4IOResult@@PEAVISave@@@Z)
1>C:\MagosIT\Autodesk\SpaceDesigner\impex\SDPlugin\x64\Debug\sdplugin.gup : fatal error LNK1120: 13 unresolved externals
1>Done building project "SDPlugin.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========

 

I am using classes and functions from the SDK already in my project and those worked before and still works now so I have no idea why they the linker does not find these.

 

This is my additional includes directory:

 

<IncludePath>..\..\..\maxsdk\include;$(IncludePath)</IncludePath>
<LibraryPath>..\..\..\maxsdk\lib\x64\Release;$(LibraryPath)</LibraryPath>

 

- with the given paths of course existing and containing the 2020 MaxSDK. I also see a file there called gup.lib that seems to be maybe what should contain these functions?

 

If I comment out the instantiation of the gup plugin class, I can build my app and earlier import-export plugins still work and build. I return a class for gup as usual from the class desc:

 

void* Create(BOOL /*loading = FALSE*/) override {
    //FIXME:return new MaxScriptSdGui();
    return nullptr;
}

 

^^only return nullptr now so that the project builds.

 

 

The plugin class is this:

 

class MaxScriptSdGui : public GUP, ActionCallback, DynamicMenuCallback { ..... }

 

 

Likely I can drop ActionCallback now as it became a DynamicMenuCallback if needed, but I see no problem with that being there.

 

The source-level documentation of the "missing" functions are like this:

 

 

/*! \remarks Implemented by the System.\n\n
This method will execute the specified MAXScript file.
\par Parameters:
<b>MCHAR *file</b>\n\n
The file name for the script file.
\return TRUE indicates if the script was successfully sent to
MAXScript; FALSE if it was not sent. Note that this does not reflect
the result of the script. */
GUPExport virtual bool ExecuteFileScript ( const MCHAR *file );

 

 

- so I think the implementation should be there for these functions indeed. What do I do wrong?!
Opening the gup.lib file I see that for exemple this ExecuteFileScript (and others) are listed there.

 

((see attachment))

 

Further information
- This is purely C++ plugin so far
- I only have maxsdk and max2020 - not other products.
- PlatformToolset: v141
- WindowsTargetPlatformVersion: 10.0.17763.0
- My project was NOT made using the project wizards (I was unable to make them work at all) - but everything linked / worked until now
- Windows 10, x64, VS2017 as usual. 3dsmax and maxsdk version is both 2020 version.

 

Original goal:
- My aim is to put out a simple menu, that runs a maxscript contained in the plugin package itself which contains a more complicated GUI that interfaces with the C++ plugin parts when needed. For this is why I started using GUP as it supposedly runs at startup and sounds like a good place to create a single ("connect to server") menu button for running the script and building GUI.
- I am open to alternatives to what I am doing currently, but I want this to happen automatically on startup with no "installers" or other things that would "install" maxscript GUI elements or such. I cannot believe it is so hard to put up a simple menu item 😞

 

Any help is appreciated.
Richard - MagosIT

 

PS.: If I cannot make this work in a *.gup plugin. Is there an other way to do similar startup-gui-additions in a *.dli kind plugin that contains SceneImport and SceneExport plugin classes? I am not really sure of how life-cycle is for import/export plugins but I know that I can likely force my DLL to not “auto defer” and maybe then there would be some workaround to do operations at startup, but I still prefer to know a proper solution as *.gup sounds to be what I need instead of these hackz… just open to any suggestions…

 

PS.: Instead of doing it the GOP way, I can maybe try to do it in my DLLs "LibInitialize()" but that sound like a really-really awful idea even if I would force to not use "auto defer" plugin loading... Maybe I can try running a script at that point using ExecuteMaxScriptScript that brings-in the file?

 

EDIT:

I get similar errors when I try to do an ExecuteMAXScriptScript(..) call:

__declspec( dllexport ) int LibInitialize() {
	// TODO: Perform initialization here.

	// FIXME: Remove test code to see if we can evaluate maxscript here or not
	ExecuteMAXScriptScript(_T(R"(
try(DestroyDialog RL_Test)catch()
	Rollout RL_Test "The Test Dialog"
	(
		button btn_ok "Ok"
		on btn_ok pressed do
		(
			Destroydialog RL_Test
			)
		)
	CreateDialog RL_Test
	)"));

	return TRUE;
}

 See errors:

1>------ Build started: Project: SDPlugin, Configuration: Debug x64 ------
1>cl : Command line warning D9025: overriding '/permissive-' with '/permissive'
1>dllmain.cpp
1>c:\magosit\autodesk\spacedesigner\maxsdk\include\maxscript\macros\value_locals.h(487): warning C4535: calling _set_se_translator() requires /EHa
1>   Creating library C:\MagosIT\Autodesk\SpaceDesigner\impex\SDPlugin\x64\Debug\sdplugin.lib and object C:\MagosIT\Autodesk\SpaceDesigner\impex\SDPlugin\x64\Debug\sdplugin.exp
1>dllmain.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) int __cdecl ExecuteMAXScriptScript(wchar_t const *,int,class FPValue *,int)" (__imp_?ExecuteMAXScriptScript@@YAHPEB_WHPEAVFPValue@@H@Z) referenced in function "int __cdecl LibInitialize(void)" (?LibInitialize@@YAHXZ)
1>dllmain.obj : error LNK2001: unresolved external symbol "struct HINSTANCE__ * hInstance" (?hInstance@@3PEAUHINSTANCE__@@EA)
1>C:\MagosIT\Autodesk\SpaceDesigner\impex\SDPlugin\x64\Debug\sdplugin.gup : fatal error LNK1120: 2 unresolved externals
1>Done building project "SDPlugin.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========

Is there something that is maybe in some extra libs while everything else is in the same file or what might be the problem?

0 Likes
1,755 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable

Pfff… I am rarely using VS and MSBuild to develop C++ being mostly linux guy so now I see the lib files were not marked to be used (see attachment).

 

Tip for others 1: You can use /VERBOSE:LIB as a command line linker option to see what files it search for. From that moment it became clear that I somewhere added the files manually that it search but failed to add the gup.lib now.

 

Top for others 2: It might be beneficial to grep through *.lib files to see which give you access to which functions if in doubt

0 Likes
Message 3 of 3

istan
Advisor
Advisor

Besides Grep there exist many other useful tools like Total Commander and Sysinternals..

0 Likes