How to include SDK source in extension

Hi. I’m working on a native extension that lets me communicate with an Intel RealSense camera from Haxe, under Windows.

I have a basic extension working in Haxe using CFFI Prime, just passing integers and such. But now I want to incorporate some RealSense SDK source into the native code and start passing real data.

I’m having linkage or missing file errors when building the extension with lime rebuild . windows from the projects root. I’ve been trying two methods, one trying to include static libraries, the other trying to include source. I’ve also tried both at once. I’ve been able to produce results from the RealSense SDK in VisualStudio in test projects, but as far as I’m aware I can’t build the native extensions there (please correct me if I’m wrong!).

What is the correct way to compile with Lime/Haxe, including/linking C++ source files from an SDK and static libraries (.lib) in a specified location?

My base project is a Lime generated extension.

I think I’ve got it finding source using the Build.xml file, like this:

<compilerflag value="-Iinclude"/>
<compilerflag value="-IC:/Program Files (x86)/Intel/RSSDK/opensource/include"/>

I placed the corresponding cpp file in my project folder because I made some changes to it. Including that was the same as the usual cpp files in the project (still in Build.xml):

<file name="common/libpxc.cpp" />

Still not sure how to include static libraries (.lib).


I’m still not sure how to include static libraries (.lib) in the build.

You should be able to do it in your Build.xml for the extension, for example, the Lime NDLL uses some libs on the Windows target:

Then it will be linked into the binary for your extension

1 Like

Thanks Joshua! I’ll give that a go.

Unfortunately, I’m still getting my linkage issues. I’ll continue working through it, but I’ll post some details here in case someone has some suggestions.

This is the output from lime rebuild . windows

C:\Development\Haxe\RealSense>lime rebuild . windows

Compiling group: common
cl.exe -Iinclude -IC:/Program Files (x86)/Intel/RSSDK/opensource/include -IC:/Program Files (x86)/Intel/RSSDK/Sample/core/Common/Include -IC:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include -IC:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/atlmfc/include -IC:/Program Files (x86)/Windows Kits/10/Include/10.0.10240.0/ucrt -nologo /WX- /fp:precise -DHX_WINDOWS -D_USING_V140_SDK71_ -GR -O2(optim-std) -Zi(debug) -FdC:\Development\Haxe\RealSense\project\obj/msvc19xp/vc.pdb(debug) -Od(debug) -O2(release) -Os(optim-size) -FS -Oy- -c -EHs -GS- -arch:SSE -IC:/HaxeToolkit/haxe/lib/hxcpp/3,4,49/include -DHXCPP_VISIT_ALLOCS(haxe) -DHXCPP_API_LEVEL=0(haxe) -D_CRT_SECURE_NO_DEPRECATE -D_ALLOW_MSC_VER_MISMATCH -D_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH -wd4996 ... tags=[haxe,static]
 - common/libpxc.cpp
 - common/ExternalInterface.cpp
 - common/RealSense.cpp
Link: ../ndll/Windows/realsense-19.ndll
   Creating library obj/lib/realsense-19.lib and object obj/lib/realsense-19.exp
74631147_libpxc.obj : error LNK2019: unresolved external symbol __imp__RegCloseKey@4 referenced in function "void __cdecl getLocalRuntime(wchar_t *,unsigned long)" (?getLocalRuntime@@YAXPA_WK@Z)
74631147_libpxc.obj : error LNK2019: unresolved external symbol __imp__RegOpenKeyExW@20 referenced in function "void __cdecl getLocalRuntime(wchar_t *,unsigned long)" (?getLocalRuntime@@YAXPA_WK@Z)
74631147_libpxc.obj : error LNK2019: unresolved external symbol __imp__RegGetValueW@28 referenced in function "void __cdecl getLocalRuntime(wchar_t *,unsigned long)" (?getLocalRuntime@@YAXPA_WK@Z)
obj/lib/realsense-19.ndll : fatal error LNK1120: 3 unresolved externals 

If I’m not mistaken, the particular symbols it can’t find there (RegCloseKey, RegOpenKeyEx, RegGetValue) exist in AdvAPI32.Lib, a file present in the Windows SDK (which I have). I’ve even tried putting that file (x86 version) into the project folder in case it was an environmental path issue, but I had the same result.

I’ve taken the includes and linkage information from a working VisualStudio project and tried to replicated it in my Build.xml, which looks like this:

	<include name="${HXCPP}/build-tool/BuildCommon.xml"/>
	<files id="common">
		<compilerflag value="-Iinclude"/>
		<!-- <compilerflag value="-IC:/Program Files (x86)/Intel/RSSDK/opensource/include"/> -->
		<compilerflag value="-IC:/Program Files (x86)/Intel/RSSDK/include"/>
		<compilerflag value="-IC:/Program Files (x86)/Intel/RSSDK/Sample/core/Common/Include"/>
		<compilerflag value="-IC:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include" />
		<compilerflag value="-IC:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/atlmfc/include" />
		<compilerflag value="-IC:/Program Files (x86)/Windows Kits/10/Include/10.0.10240.0/ucrt" />
		<section if="windows">
			<lib name="libpxc.lib" />
			<lib name="libpxcmd.lib" />
			<lib name="libpxcutils.lib" />
			<lib name="libpxcutilsmd.lib" />
			<lib name="kernel32.lib" />
			<lib name="user32.lib" />
			<lib name="gdi32.lib" />
			<lib name="winspool.lib" />
			<lib name="comdlg32.lib" />
			<lib name="AdvAPI32.Lib" />
			<lib name="shell32.lib" />
			<lib name="ole32.lib" />
			<lib name="oleaut32.lib" />
			<lib name="uuid.lib" />
			<lib name="odbc32.lib" />
			<lib name="odbccp32.lib" />			
		<file name="common/libpxc.cpp" />
		<file name="common/ExternalInterface.cpp"/>
		<file name="common/RealSense.cpp"/>
	<set name="SLIBEXT" value=".lib" if="windows"/>
	<set name="SLIBEXT" value=".a" unless="windows"/>
	<set name="SLIBEXT" value=".so" if="webos"/>
	<set name="DEBUGEXTRA" value="-debug" if="fulldebug" />
	<target id="NDLL" output="${LIBPREFIX}realsense${MSVC_LIB_VERSION}${DEBUGEXTRA}${LIBEXTRA}" tool="linker" toolid="${STD_MODULE_LINK}">
		<outdir name="../ndll/${BINDIR}"/>
		<ext value=".ndll" if="windows || mac || linux"/>
		<files id="common"/>
	<target id="default">
		<target id="NDLL"/>

Do any of these libraries help?


EDIT: Well, looks like you’ve got them. Perhaps some of the libraries conflict?

I’ve not had any luck as yet, but when I have a bit more time to play, I’m going to try building most functionality in VisualStudio where the linkage is working, as a self contained static library. I will hopefully then be able to include that in a simpler interface C++ file for Haxe.