Write an OpenSTAAD Program in VS C++

I want to learn to write an OpenSTAAD code in Visual Studio 2023 C++. I followed the steps as listed in STAAD.Pro Help OpenSTAAD. The code given by Bentely is look like:

#import "C:\Program Files\Bentley\Engineering\STAAD.Pro CONNECT Edition\STAAD\StaadPro.dll" named_guids
using namespace OpenSTAADUI;
using namespace std;
namespace OSApp = OpenSTAADUI;

int main()
{
OSApp::IOpenSTAADUIPtr OSAppPtr;
try
{
CoInitialize(NULL);
HRESULT hr = OSAppPtr.CreateInstance(__uuidof(OSApp::OpenSTAAD));

if (hr != S_OK)
{
printf("Unable to connect to STAAD.Pro application!\n");
return 1;
}

hr = OSAppPtr.GetActiveObject(__uuidof(OSApp::OpenSTAAD));
if (hr != S_OK)
{
printf("Unable to connect to an active instance of STAAD.Pro application!\n");
return 1;
}
}
catch (_com_error& e)
{
_bstr_t bstrDescription = e.Description();
printf("COM Error! %s\n", bstrDescription);
}
}

The problem is when reaching the Linking stage, an error occur about 'StaadPro.dll' saying that: "Error LNK1302 only support linking safe .netmodules; unable to link ijw/native .netmodule". I am grateful for any help I receive.

Parents Reply Children
No Data