Archicad C++ API
About Archicad add-on development using the C++ API.

LNK 2019 Unresolved external symbol

Aathil
Participant

I have a function to get the library part index from name. 
The function uses GS::DefineConstatntUTF16CharacterOrString() method.
On building this function is not resolved. And is giving the following error:

 

ArchiCADElements.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) unsigned short const * __cdecl GS::DefineConstantUTF16CharacterOrString(char const * &)" (__imp_?DefineConstantUTF16CharacterOrString@GS@@YAPEBGAEAPEBD@Z) referenced in function "int __cdecl GetLibraryIndex(char const *,enum API_LibTypeID)" (?GetLibraryIndex@@YAHPEBDW4API_LibTypeID@@@Z)

 


The function is defined in uchar_t.h . Correct me if I am wrong, the corresponding dependency library is :
\Support\Modules\GSRoot\Win\GSRootImp.LIB which is already included in the project's additional libraries.

 

How to fix this issue?

 

#include "uchar_t.hpp"
#include "ACAPinc.h"
#include "APIEnvir.h"
#include "ArchiCADElements.hpp"

Int32 GetLibraryIndex(const char* name, API_LibTypeID typeId)
{
GSErrCode err;
API_LibPart searchPart;

auto str = GS::DefineConstantUTF16CharacterOrString(name);

GS::ucscpy(searchPart.docu_UName, str);

err = ACAPI_LibPart_Search(&searchPart, false);

if (searchPart.location != nullptr)

delete searchPart.location;

if (err == NoError)

return searchPart.index;

std::cout << "Could not find library part with name:" << name << std::endl;
return 0;
}

Aathil_0-1701324921403.png

 

Thanks

 

1 ACCEPTED SOLUTION
1 REPLY 1
Solution
kolioi
Booster

If you open uchar_t.hpp header file, you can see that you're not allowed to use the function DefineConstantUTF16CharacterOrString() alone. That function is called from the macro L(str) which takes as a parameter string or character constants only. You can not call the function with a variable because it doesn't have implementation.

In your case, you have to convert multibyte string to wide-character string. There are several ways to do that but maybe the easiest way is to use GS::UniString. Something like this

GS::ucscpy(searchPart.docu_UName, GS::UniString(name).ToCStr().Get());

 

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!