diff --git a/AdsLib/.gitattributes b/AdsLib/.gitattributes new file mode 100644 index 00000000..028bef88 --- /dev/null +++ b/AdsLib/.gitattributes @@ -0,0 +1,2 @@ +*.h text eol=lf +*.cpp text eol=lf \ No newline at end of file diff --git a/AdsLib/AdsLib.h b/AdsLib/AdsLib.h index a9ecb732..1455578d 100644 --- a/AdsLib/AdsLib.h +++ b/AdsLib/AdsLib.h @@ -13,6 +13,9 @@ #include "Sockets.h" +#ifdef __cplusplus +extern "C" { +#endif /** * Reads data synchronously from an ADS server. * @param[in] port port number of an Ads port that had previously been opened with AdsPortOpenEx(). @@ -188,3 +191,7 @@ long GetRemoteAddress(const std::string &remote, AmsNetId &netId); #define AdsAddRoute bhf::ads::AddLocalRoute #define AdsDelRoute bhf::ads::DelLocalRoute #define AdsSetLocalAddress bhf::ads::SetLocalAddress + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/AdsLib/standalone/AdsLib.cpp b/AdsLib/standalone/AdsLib.cpp index 6f80f4c9..4317231c 100644 --- a/AdsLib/standalone/AdsLib.cpp +++ b/AdsLib/standalone/AdsLib.cpp @@ -6,6 +6,7 @@ #include "AdsLib.h" #include "AmsRouter.h" +extern "C" { static AmsRouter &GetRouter() { static AmsRouter router; @@ -286,3 +287,4 @@ long AdsSyncSetTimeoutEx(long port, uint32_t timeout) ASSERT_PORT(port); return GetRouter().SetTimeout((uint16_t)port, timeout); } +} \ No newline at end of file diff --git a/AdsLib/standalone/AdsLib.h b/AdsLib/standalone/AdsLib.h index 76e8aa4e..c188492b 100644 --- a/AdsLib/standalone/AdsLib.h +++ b/AdsLib/standalone/AdsLib.h @@ -5,7 +5,9 @@ #pragma once #include "AdsDef.h" - +#ifdef __cplusplus +extern "C" { +#endif /** * The connection (communication port) to the message router is * closed. The port to be closed must previously have been opened via @@ -38,3 +40,6 @@ long AdsGetLocalAddressEx(long port, AmsAddr *pAddr); * @return [ADS Return Code](https://infosys.beckhoff.com/content/1031/tcadscommon/html/ads_returncodes.htm?id=1666172286265530469) */ long AdsSyncSetTimeoutEx(long port, uint32_t timeout); +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/meson.build b/meson.build index d3677d84..30ff5cb7 100644 --- a/meson.build +++ b/meson.build @@ -95,6 +95,15 @@ adslib = static_library('AdsLib', install: true, ) +adslib_so = shared_library('adslib', + [common_files, router_files], + include_directories: inc, + install: true, + name_prefix: '', + name_suffix: 'so', + dependencies: [dependency('threads')], +) + install_libs = [ adslib ] adslib_dep = declare_dependency(