License delivery maintenance is planned for Saturday, July 26, between 12:00 and 20:00 CEST. During this time, you may experience outages or limited availability across our services, including BIMcloud SaaS, License Delivery, Graphisoft ID (for customer and company management), Graphisoft Store, and BIMx Web Viewer. More details…
2023-11-30
07:18 AM
- last edited on
2024-09-17
12:45 PM
by
Doreena Deng
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;
}
Thanks
Solved! Go to Solution.
2023-12-02 10:52 PM
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());
2023-12-02 10:52 PM
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());