Trouble with compiling the native extension example on windows

84 views
Skip to first unread message

Peter Jakobs

unread,
Oct 15, 2014, 8:38:55 AM10/15/14
to mi...@dartlang.org
I'm currently run into problems compiling the sample extension with Visual C++ 2010/2013.
I followed the instruction in the article.

I had no problems make it run on osx, but run into this when I try to compile the dll:

1>dart_sdl.obj : error LNK2019: unresolved external symbol _Dart_Null referenced in function _sample_extension_Init
1>dart_sdl.obj : error LNK2019: unresolved external symbol _Dart_SetNativeResolver referenced in function _sample_extension_Init
1>dart_sdl.obj : error LNK2019: unresolved external symbol _Dart_IsError referenced in function _sample_extension_Init
1>dart_sdl.obj : error LNK2019: unresolved external symbol _Dart_PropagateError referenced in function "struct _Dart_Handle * __cdecl HandleError(struct _Dart_Handle *)" (?HandleError@@YAPAU_Dart_Handle@@PAU1@@Z)
1>dart_sdl.obj : error LNK2019: unresolved external symbol _Dart_ExitScope referenced in function "void __cdecl SystemRand(struct _Dart_NativeArguments *)" (?SystemRand@@YAXPAU_Dart_NativeArguments@@@Z)
1>dart_sdl.obj : error LNK2019: unresolved external symbol _Dart_SetReturnValue referenced in function "void __cdecl SystemRand(struct _Dart_NativeArguments *)" (?SystemRand@@YAXPAU_Dart_NativeArguments@@@Z)
1>dart_sdl.obj : error LNK2019: unresolved external symbol _Dart_NewInteger referenced in function "void __cdecl SystemRand(struct _Dart_NativeArguments *)" (?SystemRand@@YAXPAU_Dart_NativeArguments@@@Z)
1>dart_sdl.obj : error LNK2019: unresolved external symbol _Dart_EnterScope referenced in function "void __cdecl SystemRand(struct _Dart_NativeArguments *)" (?SystemRand@@YAXPAU_Dart_NativeArguments@@@Z)
1>dart_sdl.obj : error LNK2019: unresolved external symbol _Dart_NewBoolean referenced in function "void __cdecl SystemSrand(struct _Dart_NativeArguments *)" (?SystemSrand@@YAXPAU_Dart_NativeArguments@@@Z)
1>dart_sdl.obj : error LNK2019: unresolved external symbol _Dart_IntegerToInt64 referenced in function "void __cdecl SystemSrand(struct _Dart_NativeArguments *)" (?SystemSrand@@YAXPAU_Dart_NativeArguments@@@Z)
1>dart_sdl.obj : error LNK2019: unresolved external symbol _Dart_IntegerFitsIntoInt64 referenced in function "void __cdecl SystemSrand(struct _Dart_NativeArguments *)" (?SystemSrand@@YAXPAU_Dart_NativeArguments@@@Z)
1>dart_sdl.obj : error LNK2019: unresolved external symbol _Dart_IsInteger referenced in function "void __cdecl SystemSrand(struct _Dart_NativeArguments *)" (?SystemSrand@@YAXPAU_Dart_NativeArguments@@@Z)
1>dart_sdl.obj : error LNK2019: unresolved external symbol _Dart_GetNativeArgument referenced in function "void __cdecl SystemSrand(struct _Dart_NativeArguments *)" (?SystemSrand@@YAXPAU_Dart_NativeArguments@@@Z)
1>dart_sdl.obj : error LNK2019: unresolved external symbol _Dart_PostCObject referenced in function "void __cdecl wrappedRandomArray(__int64,struct _Dart_CObject *)" (?wrappedRandomArray@@YAX_JPAU_Dart_CObject@@@Z)
1>dart_sdl.obj : error LNK2019: unresolved external symbol _Dart_NewSendPort referenced in function "void __cdecl randomArrayServicePort(struct _Dart_NativeArguments *)" (?randomArrayServicePort@@YAXPAU_Dart_NativeArguments@@@Z)
1>dart_sdl.obj : error LNK2019: unresolved external symbol _Dart_NewNativePort referenced in function "void __cdecl randomArrayServicePort(struct _Dart_NativeArguments *)" (?randomArrayServicePort@@YAXPAU_Dart_NativeArguments@@@Z)
1>dart_sdl.obj : error LNK2019: unresolved external symbol _Dart_StringToCString referenced in function "void (__cdecl*__cdecl ResolveName(struct _Dart_Handle *,int,bool *))(struct _Dart_NativeArguments *)" (?ResolveName@@YAP6AXPAU_Dart_NativeArguments@@@ZPAU_Dart_Handle@@HPA_N@Z)
1>dart_sdl.obj : error LNK2019: unresolved external symbol _Dart_IsString referenced in function "void (__cdecl*__cdecl ResolveName(struct _Dart_Handle *,int,bool *))(struct _Dart_NativeArguments *)" (?ResolveName@@YAP6AXPAU_Dart_NativeArguments@@@ZPAU_Dart_Handle@@HPA_N@Z)

William Hesse

unread,
Oct 15, 2014, 8:56:58 AM10/15/14
to General Dart Discussion
These link failures are due to it not finding the dart vm library when linking.  This should be taken care of by the following step in the building and linking instructions:

Change the following settings in the project’s properties:
  1. Configuration properties / Linker / Input / Additional dependencies: Add dart-sdk\bin\dart.lib, from the downloaded Dart SDK.

This could fail if you are compiling a 64-bit version of the DLL - there is no 64-bit version of the Dart VM for Windows, and the dll and the library file dart.lib only provide the 32-bit dart binary API.  Is this a 32-bit or 64-bit project you are trying to build?  Only a 32-bit native extension will work.

Does the file dart-sdk\bin\dart.lib exist?


--
For other discussions, see https://groups.google.com/a/dartlang.org/
 
For HOWTO questions, visit http://stackoverflow.com/tags/dart
 
To file a bug report or feature request, go to http://www.dartbug.com/new

To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.



--
William Hesse

Peter Jakobs

unread,
Oct 15, 2014, 2:16:51 PM10/15/14
to mi...@dartlang.org
Im compiling for the 32bit version. Linker/Inpu/Additional dependencies is set to:" C:\dart\dart-sdk\bin\dart.lib;%(AdditionalDependencies)" which should work (the file exists yes), but it doesn't.

Still getting:

1>------ Build started: Project: dart_sdl, Configuration: Release Win32 ------
1>dart_sdl.obj : error LNK2001: unresolved external symbol _Dart_IsError
1>dart_sdl.obj : error LNK2001: unresolved external symbol _Dart_ExitScope

...
...

1>dart_sdl.obj : error LNK2001: unresolved external symbol _Dart_NewSendPort
1>C:\Users\user\documents\visual studio 2013\Projects\dart_sdl\Release\dart_sdl.dll : fatal error LNK1120: 18 unresolved externals


Am Mittwoch, 15. Oktober 2014 14:56:58 UTC+2 schrieb William Hesse:
These link failures are due to it not finding the dart vm library when linking.  This should be taken care of by the following step in the building and linking instructions:

Change the following settings in the project’s properties:
  1. Configuration properties / Linker / Input / Additional dependencies: Add dart-sdk\bin\dart.lib, from the downloaded Dart SDK.

This could fail if you are compiling a 64-bit version of the DLL - there is no 64-bit version of the Dart VM for Windows, and the dll and the library file dart.lib only provide the 32-bit dart binary API.  Is this a 32-bit or 64-bit project you are trying to build?  Only a 32-bit native extension will work.

Does the file dart-sdk\bin\dart.lib exist?


--
William Hesse

tekz omnisoft

unread,
Oct 15, 2014, 3:01:15 PM10/15/14
to mi...@dartlang.org
I too found the native-extensions-for-standalone-dart-vm article to be a great reference. For my VS2010 configs, these items extremely important:
1. Add <dart-sdk 32bit> or <dart-sdk 64bit> \bin\dart.lib to linker input
2. Add <dart-sdk 32bit> or <dart-sdk 64bit> \dart\dart-sdk\ to C++ AdditionalIncludeDirectories
3. Add DART_SHARED_LIB to preprocessor defs <-- bit me several times, so I added it to "All Configurations"

I am a bit confused by 
 - there is no 64-bit version of the Dart VM for Windows, and the dll and the library file dart.lib only provide the 32-bit dart binary API
Maybe it means both 32bit & 64bit are not shipped together, which makes sense. For me, DartVM (64bit) native extensions are alive and well for sometime now.  I have always developed with the DartEditor(64bit) version and separate download of 32bit Dart SDK just to create the 32bit versions of the dlls.

https://github.com/osstekz/dxConsole has both 32bit and 64bit native extension dlls in \bin (defaults to 64bit)

From the demo in \example folder:
============== dxConsole: Dart Console Library for Windows  (CommandMode)==============
Dart VM (64bit): 1.7.0-dev.4.6 (Tue Oct 14 00:47:02 2014) on "windows_x64"
Page size: 4096kb Endianness: Little-endian --checked: true
StdIn: terminal StdOut: pipe StdErr: pipe

Cheers!

Peter Jakobs

unread,
Oct 15, 2014, 3:59:31 PM10/15/14
to mi...@dartlang.org
Okay the problem was actually that I tried to compile 32bit and not 64bit.. it worked now finally, thanks!
Reply all
Reply to author
Forward
0 new messages