Community
3ds Max Programming
Welcome to Autodesk’s 3ds Max Forums. Share your knowledge, ask questions, and explore popular 3ds Max SDK, Maxscript and Python topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

3dsMax 2013 64-bit SDK project: LNK2001 and LNK2019 errors...

12 REPLIES 12
SOLVED
Reply
Message 1 of 13
michael_lawler
2595 Views, 12 Replies

3dsMax 2013 64-bit SDK project: LNK2001 and LNK2019 errors...

First off, I'm a novice C++ programmer... and a novice with the 3ds Max SDK-- that makes me doubly dangerous. Smiley Tongue

 

I've been fixing an old broken game exporter (original source code was for Max6)... I have it fixed and working with improvements and new features and it compiles fine in version 3ds Max 2012, but I'm getting Linker errors (like others here...) trying to convert this to 3ds Max 2013 and UNICODE.  This plugin exports dotXSI 3.0 files and is compiled against the old XSIFTK (rebranded as Crosswalk)...

 

It compiled perfectly with 3ds Max 2012 SDK and Crosswalk 2012.5 SDK.  So now I'm trying to compile it using 3ds Max 2013 with Crosswalk 2013 SDK -- which supports 3ds Max 2013. 

 

I get three LNK errors when it hits the link stage:

1>------ Build started: Project: MAXExporter, Configuration: Release x64 ------
1>  BipedChain.cpp
1>  DllEntry.cpp
1>  dotXSIMapper.cpp
1>  EnvelopConverter.cpp
1>  MAXExporter.cpp
1>  MAXHelpers.cpp
1>  XSIExportOptions.cpp
1>  Generating Code...
1>     Creating library .\x64\Release/dotXSIExport.lib and object .\x64\Release/dotXSIExport.exp
1>dotXSIMapper.obj : error LNK2019: unresolved external symbol "public: char const * __cdecl NURBSObject::GetName(void)" (?GetName@NURBSObject@@QEAAPEBDXZ) referenced in function "private: class CdotXSITemplates * __cdecl CdotXSIMapper::ExportNURBS_CV(class INode *,class CdotXSITemplates *)" (?ExportNURBS_CV@CdotXSIMapper@@AEAAPEAVCdotXSITemplates@@PEAVINode@@PEAV2@@Z)
1>MAXExporter.obj : error LNK2001: unresolved external symbol "public: virtual class FPInterface * __cdecl ClassDesc::GetInterface(char const *)" (?GetInterface@ClassDesc@@UEAAPEAVFPInterface@@PEBD@Z)
1>MAXExporter.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl MaxSDK::Util::OutOfRangeException::OutOfRangeException(char const *)" (__imp_??0OutOfRangeException@Util@MaxSDK@@QEAA@PEBD@Z) referenced in function "public: __cdecl MaxSDK::Util::TabOutOfRangeException::TabOutOfRangeException(char const *)" (??0TabOutOfRangeException@Util@MaxSDK@@QEAA@PEBD@Z)
1>./x64/Release/dotXSIExport.dle : fatal error LNK1120: 3 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

The first is obvious as I can see it's having issues with the GetName function for NURBSObject.  This snippet of code causing this first LNK 2019 error is given below:

 

ADD_XSI_TEMPLATE ( l_pSISurface, "SI_NurbsSurface" );

TCHAR l_szBuffer[256];
CSIBCString l_bcString = l_pNURBS->GetName(); /* Why is this line giving me LNK2019 error? */
ConvertSpaces2Dashes ( l_bcString );
_tcsncpy ( l_szBuffer, l_bcString.GetText(), l_bcString.GetLength() );
l_szBuffer [ l_bcString.GetLength() ] = 0;
l_pSISurface->SetInstanceName ( l_szBuffer );

 I can eliminate the corresponding LNK2019 error by replacing the l_pNURBS->GetName() with a simple _T("myNURBSObject");  And the LNK2019 goes away-- but how do I fix this properly to get the Nurbs Object name???

 

The remaining two LNK2001 and LNK2019 errors have me dumbfounded and don't give me any insights as to where the errors originate within the MAXExporter.cpp file. 

 

PLEASE HELP ME!!!  Smiley Frustrated

 

Thanks!

12 REPLIES 12
Message 2 of 13

Hi Michael, I got your private message. First about the 2013 plugin wizard, it was pretty broken, and especially did not work for x64 targets. I posted an updated one here that should be better for 2013. Find the link on this page: http://getcoreinterface.typepad.com/blog/2013/09/3ds-max-c-sdk-training.html Make sure you have the ones from the blog. There were only subtle differences I made to get it working better for x64. Note that you will know on the page that has the environment locations because I added two fields specific to x64, so it should show 5 instead of the original 3 fields.

 

Next, in your project settings, make sure the "General", "Character Set" value is set to "Use Unicode Character Set". Then go to the C/C++ settings, choose the "Preprocessor" section, then in the "Preprocessor Definitions" make certain that UNICODE and _UNICODE is defined. It may not show if you are using the Wizard, which uses the property pages (or if you directly imported the property pages. But you can see if it is set, by clicking "Edit..." and then looking through the values in the bottom of the dialog under the "Inherited Values" section. Usually it will be right at the bottom of that list.

 

Lastly, make certain all your strings are using Unicode types. 3ds Max types like TCHAR and TSTR support it directly, but make sure you are referring to the 2013 headers files, too. For static strings, you must put the _T macro around it. For example a call like:

 

mprintf("Hello world") in 2012, would need to be compiled like: mprintf(_T("Hello World"))

 

all strings need to be wrapped with the macro, or be of a Unicode type to work correctly.

 

I am not familiar with the XSI tools. What is "CSIBCString" defined as? You might drill down to see what that string is ultimately defined as... Hopefully it is also UNICODE or you might have to do some conversion.

 

Hope it helps,

kevin

 


Kevin Vandecar
Developer Technical Services
Autodesk Developer Network



Message 3 of 13

Kevin, thanks for the quick reply... I imported/converted my Max 2012 VS2008sp1 project into VS2010sp1.  I then manually edited the project properties following some online guidance for Unicode conversion.  All of your suggestions:  "Unicode Character Set" and Preproccessor definitions were changed as you say.  The Softimage XSI File Transfer Kit (XSIFTK) was rebranded as Crosswalk... now Autodesk Crosswalk.  You can find all those XSI headers in the Crosswalk installation directories:

 

.\SDK\include\Core

.\SDK\include\FTK

 

...and I compile against the 64-bit XSIFtk.lib in folder:  .\SDK\lib\nt-x86-64

 

CSIBCString is the XSIFTK equivalent class of cstring... you can find it's header file in the Crosswalk  \Core folder cited above.  Since I'm using Crosswalk 2013 SDK-- I'm assuming it is UNICODE compatible with 3dsMax 2013 SDK?

 

One thing I have not done, as you stated, was that ALL strings had to be wrapped in _T( )... but is this only required for 3ds Max functions? What about standard Windows API functions?

 

In the one clear LNK 2019 error regarding the NURBSObject::GetName() method... the Max 2013 SDK says that it is const MCHAR* (someone else also suggested that I wrap a GetString method around l_pNURBS->GetName() ...so I'll give that a try).

 

Thanks!

Message 4 of 13

Someone suggested this:

 

What you are experiencing now is very tricky at times.
 I've had similar issues often when converting old code.

 One thing I use on all my 2014 projects is this function here:

Code:
std::string getstring(const wchar_t* wstr)
{
	std::wstring ws(wstr);
	std::string str(ws.begin(), ws.end());
	return str;
}


try it on your getname call:


Code:
getstring(l_pNURBS->GetName());

see if that helps.

 ...and it did not work.  It gave me this error:

1>dotXSIMapper.cpp(724): error C2664: 'getstring' : cannot convert parameter 1 from 'const char *' to 'const wchar_t *'

1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast 

 Any other suggestions?  I also tried copying the const char* into another temp string but that didn't work either.
...and yes, I have: #include "surf_api.h" in my list of includes...

I also tried this (which in my mind should have worked):

CSIBCString l_bcString = CSIBCString( l_pNURBS->GetName() );

...because intellisense say l_pNURBS->GetName() is type:  const char*

and CSIBString has this constructor: 
CSIBCString(const SI_Char *in_pString );  //where SI_Char is typedef for char

What libs are associated with NURBS objects/surfaces???

Thanks!

Message 5 of 13

edmodel.lib is what I am linked to for the NURBS library.
Message 6 of 13

After doing some Googling... (and reading similar issues from other people) I think I don't have the proper version of Windows SDK installed.  I have Windows SDK v6.0A (which I think is good for VS2008) and I think I need to download and install Windows SDK 7.1 and make sure that VS2010sp1 is pointing to SDK 7.1 for any resources it would use from the Windows SDK???  Worth a shot...  I'll post if that resolved my issues.

Message 7 of 13

Downloading and installing Windows SDK v7.1 (which required me to first uninstall VS2010 SP1 and redistributable packages), then re-installing VS2010 SP1, and then installing the Windows SDK 7.1 VS2010 SP1 VC-Compiler patch... ultimately had no effect on my Linker errors.  I set the platform toolset to use Windows7.1SDK and attempted to build the solution, but got the same Linker errors that I originally posted.  So I switched the Platform Toolset back to VC100...

 

...any suggestions?

Message 8 of 13

@kevinvandecar -- The Max 2012 x64 source code (which compiles successfully) and the Max 2013 x64 source code (which fails with the 3 Link errors) has been emailed to you...

Thanks for your help.
Message 9 of 13

@kevinvandecar -- Have you made any breakthroughs?  Any progress/news at all?

Message 10 of 13

Kevin -- I finally got the Max 2013 x64 project to compile... 

 

To achieve this I had to use your updated Max2013 Plugin Wizard and create a new exporter project-- which readily compiled.  Then I began populating my code into this empty project piece-meal... and incrementally building the solution often-- fixing the ansi/unicode errors as I went.  Doing it this way was long and tedious, taking me an entire day... but it compiled and I never got those original linking errors.

 

Currently, the compiled Max 2013 plugin is crashing; building a Hybrid version and running a debug session  revealed that it is crashing at the MAXHelpers method:

 

TCHAR* GetNodeName( INode*);

 

This is because this TCHAR* defaults to Unicode and I kept all of the dotXSI Templates in ANSI... so I need to revise this method to be CHAR* instead.  I hope to have this resolved as soon as I can find the time to get back to it. 

Message 11 of 13
marcello
in reply to: michael_lawler

I have a similar problem.

I managed to compile an exporter plugin for Max 2014 with UNICODE. The problem is that, on the other side, the importer is not able to read the binary files exported this way. I tried to setup MBCS but apparently I can't, as I have LINKER errors similars to the ones mentioned in this post (I suppose that the maxsdk lib/dll are available ONLY as unicode).

 

Is there a way to compile a plugin for max 2014 WITHOUT using unicode?

 

Thanks in advance for any help!

Message 12 of 13
kevinvandecar
in reply to: marcello

Sorry, no. 3ds Max side needs to have Unicode. The other people here who solved it, performed string conversion to maintain the ANSI side. Note you can set compiler settings on a per file basis, which you may need to do for this conversion idea. We do not directly support this idea, so I do not have any sample code to provide. Sorry for that.

 

Good luck.

kevin

 


Kevin Vandecar
Developer Technical Services
Autodesk Developer Network



Message 13 of 13

Exactly... as Kevin stated--  I had to do unicode-to-ansi string conversions because I kept the dotXSI side of things as ANSI. 

 

By the way the dotXSI 3.0 exporter works perfectly in Max 2013/2014... I hope to get back to this and compile a version for Max 2015 one day soon.

 

Good Luck!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report