Using C++ Visual Studio 2013 with GXAPI

Options
CarlosAlbuquerque
edited May 2023 in Oasis montaj
Hi ,

I'm using GX API 8.4 C++ 64-bit with Visual Studio 2013 stand alone. I want to upgrade it to use the 9.2 version.
On the 9.2 documantation says that the 64-bit header is "cpp\include\gxcpp_dbus.h" this is not present in the installation. Is this the right header? where can I find/get it.

Building the example provided "cpp\examples\cpp\gridstat" with Visual Studio 2013 64-bit I get some build errors:
Error 1 error C2143: syntax error : missing ';' before 'std::weak_ptr<_Ty>' C:\Program Files\Geosoft\GX Developer\cpp\include\gxcpp_geogx.h 3795 gridstat
Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int C:\Program Files\Geosoft\GX Developer\cpp\include\gxcpp_geogx.h 3795 gridstat
Error 3 error C2228: left of '.lock' must have class/struct/union C:\Program Files\Geosoft\GX Developer\cpp\include\gxcpp_geogx.h 3891 gridstat
Error 4 error C3536: 'cur_ctx': cannot be used before it is initialized C:\Program Files\Geosoft\GX Developer\cpp\include\gxcpp_geogx.h 3891 gridstat
Error 5 error C3536: 'cur_ctx': cannot be used before it is initialized C:\Program Files\Geosoft\GX Developer\cpp\include\gxcpp_geogx.h 3892 gridstat
Error 6 error C2664: 'std::shared_ptr::shared_ptr(std::shared_ptr &&) throw()' : cannot convert argument 1 from 'int' to 'std::nullptr_t' C:\Program Files\Geosoft\GX Developer\cpp\include\gxcpp_geogx.h 3892 gridstat
Error 7 error C2597: illegal reference to non-static member 'geosoft::gx::geogx::GXContext::currentContext' C:\Program Files\Geosoft\GX Developer\cpp\include\gxcpp_geogx.h 3895 gridstat
Error 8 error C2228: left of '.lock' must have class/struct/union C:\Program Files\Geosoft\GX Developer\cpp\include\gxcpp_geogx.h 3900 gridstat
Error 9 error C3536: 'cur_ctx': cannot be used before it is initialized C:\Program Files\Geosoft\GX Developer\cpp\include\gxcpp_geogx.h 3900 gridstat
Error 10 error C3536: 'cur_ctx': cannot be used before it is initialized C:\Program Files\Geosoft\GX Developer\cpp\include\gxcpp_geogx.h 3901 gridstat
Error 11 error C2664: 'std::shared_ptr::shared_ptr(std::shared_ptr &&) throw()' : cannot convert argument 1 from 'int' to 'std::nullptr_t' C:\Program Files\Geosoft\GX Developer\cpp\include\gxcpp_geogx.h 3901 gridstat
Error 12 error C2597: illegal reference to non-static member 'geosoft::gx::geogx::GXContext::currentContext' C:\Program Files\Geosoft\GX Developer\cpp\include\gxcpp_geogx.h 3904 gridstat
Error 13 error C2228: left of '.lock' must have class/struct/union C:\Program Files\Geosoft\GX Developer\cpp\include\gxcpp_geogx.h 3909 gridstat
Error 14 error C3536: 'cur_ctx': cannot be used before it is initialized C:\Program Files\Geosoft\GX Developer\cpp\include\gxcpp_geogx.h 3909 gridstat
Error 15 error C3536: 'cur_ctx': cannot be used before it is initialized C:\Program Files\Geosoft\GX Developer\cpp\include\gxcpp_geogx.h 3910 gridstat
Error 16 error C2664: 'std::shared_ptr::shared_ptr(std::shared_ptr &&) throw()' : cannot convert argument 1 from 'int' to 'std::nullptr_t' C:\Program Files\Geosoft\GX Developer\cpp\include\gxcpp_geogx.h 3910 gridstat
Error 17 error C2143: syntax error : missing ';' before 'std::weak_ptr<_Ty>' C:\Program Files\Geosoft\GX Developer\cpp\include\gxcpp_geogx.h 32094 gridstat
Error 18 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int C:\Program Files\Geosoft\GX Developer\cpp\include\gxcpp_geogx.h 32094 gridstat
Error 19 error C2761: 'std::weak_ptr<_Ty> geosoft::gx::geogx::GXContext::currentContext' : member function redeclaration not allowed C:\Program Files\Geosoft\GX Developer\cpp\include\gxcpp_geogx.h 32094 gridstat


I find-out that this issue is because the thread_local that is not fully supported in 2013. Any workaround for this issue.

Thanks,
Carlos Albuquerque

Comments

  • JacquesBeaurain
    JacquesBeaurain Posts: 29 Calcite Rank Badge
    edited June 2017
    Options
    Hi Carlos,

    The dbus version was used to provide a client/server based API between 64-bit apps and the 32-bit libraries in 8.4 and is no longer needed.

    Since the geogx_cpp.h is a header only C++ API to wrap the geogx C API, I think you might be able to work around the VS 2013 incompatibility by defining a macro to the non-standard declspec thread local declaration as follows:

    #define thread_local __declspec( thread )

    Regards,
    Jacques Beaurain


  • CarlosAlbuquerque
    edited June 2017
    Options
    Hi Jacques,

    I tryed to define this macro and I got these errors when building the example gridstat:
    Error 1 error C2483: 'geosoft::gx::geogx::GXContext::currentContext' : object with constructor or destructor cannot be declared 'thread' C:\Program Files\Geosoft\GX Developer\cpp\include\gxcpp_geogx.h 3795 gridstat
    Error 2 error C2483: 'private: static std::weak_ptr geosoft::gx::geogx::GXContext::currentContext' : object with constructor or destructor cannot be declared 'thread' C:\Program Files\Geosoft\GX Developer\cpp\include\gxcpp_geogx.h 3795 gridstat
    Error 3 error C2483: 'geosoft::gx::geogx::GXContext::currentContext' : object with constructor or destructor cannot be declared 'thread' C:\Program Files\Geosoft\GX Developer\cpp\include\gxcpp_geogx.h 32094 gridstat

    The only way that I find out to make it compile is defining an empty macro thread_local. What will be the implication of doing like this? Do you use threads in Geosoft library?

    Thanks,
    Carlos Albuquerque
  • JacquesBeaurain
    Options
    Hi Carlos,

    The context instance wraps the C opaque pointer returned by pCreat_GEO and maintain its life time using a thread_local smart pointer The object is integral in the resolution of GX API calls to our internal API implementations, but it is not thread safe.

    The thread_local specifier on that instance is enforcing creating a context per thread to use the API, but it can
    be defined out with an empty macro and everything will continue to function, as long as you do not use different threads to make API calls.

    Hope this helps,

    Jacques
This discussion has been closed.