fuzzybinary / dart-embedding-example Goto Github PK
View Code? Open in Web Editor NEW[Deprecated] An example of embedding Dart in an existing C++ application
[Deprecated] An example of embedding Dart in an existing C++ application
After I build , there is no libdart.a but libdart_precompiled_runtime.a.
When I link it report can not find symbol:
dart::bin::observatory_assets_archive
, dart::bin::observatory_assets_archive_len
, CompileAndReadScript
I want to link and run AOT binary , I guess I has to replace CompileAndReadScript
part. please help to give some tips.
I've just been trying to follow along with the readme to get the embedding example set up but have hit a snag in the "Modifying some GN files" section of the doc. Namely, when trying to execute the ninja libdart
command in the generated DebugX64 directory, I get the following error:
C:\src\depot_tools\dart-sdk\sdk\out\DebugX64>ninja libdart
ninja: error: unknown target 'libdart', did you mean 'dart'?
I'm not sure if this is caused by incorrectly generating the ninja files in previous steps or if changes have been made to the Dart SDK or depot_tools that would've changed the target I'd be attempting to build, so I was wondering if you might be able shed a little light on that.
Additionally, how do you actually run the code in this repo? Simply cloning it into Visual Studio and attempting a build throws the following error:
\dart-embedding-example\dart\platform\assert.h(12,1): fatal error C1189: #error: neither DEBUG nor NDEBUG defined
Does the source need to be placed within the depot_tools\dart-sdk
directory and then built from within there? Or is it something else that I'm missing entirely?
Thanks in advance!
Heya -- thank you for maintaining these examples!
As far as I can tell, you've never been able to build shared/static libs with Dart Native. Only binaries.
Looking at the embedding example and the embedding API here, I'm curious if the approach that .NET took with DNNE (Dotnet Native Exports) would be viable?
The way this works is that you can mark functions with an attribute, to be exported (and the C99 code to generate for it if needed). At build time, it uses reflection to codegen a .h
that:
And then it compiles this for you automatically.
private const string ReaperPluginInfoStructString = @"
struct reaper_plugin_info_t
{
int caller_version;
void* hwnd_main;
int (*Register)(const char* name, void* infostruct);
void* (*GetFunc)(const char* name);
};
";
public struct ReaperPluginInfo {} // omitted
[UnmanagedCallersOnly]
[DNNE.C99DeclCode(ReaperPluginInfoStructString)]
public static int ReaperPluginEntry(IntPtr hInstance, [DNNE.C99Type("struct reaper_plugin_info_t*")] ReaperPluginInfo* rec)
// Auto-generated by dnne-gen
// .NET Assembly: ReaperDNNE
// Declare exported functions
#ifndef __DNNE_GENERATED_HEADER_REAPERDNNE__
#define __DNNE_GENERATED_HEADER_REAPERDNNE__
#include <stddef.h>
#include <stdint.h>
#include <dnne.h>
// Additional code provided by user
struct reaper_plugin_info_t
{
int caller_version;
void* hwnd_main;
int (*Register)(const char* name, void* infostruct);
void* (*GetFunc)(const char* name);
};
// Computed from ReaperDNNE.MyReaperPlugin.ReaperPluginEntry
DNNE_API int32_t DNNE_CALLTYPE ReaperPluginEntry(intptr_t hInstance, struct reaper_plugin_info_t* rec);
#endif // __DNNE_GENERATED_HEADER_REAPERDNNE__
// Define exported functions
#ifdef DNNE_COMPILE_AS_SOURCE
// Forward declarations
extern void* get_callable_managed_function(
const char_t* dotnet_type,
const char_t* dotnet_type_method,
const char_t* dotnet_delegate_type);
extern void* get_fast_callable_managed_function(
const char_t* dotnet_type,
const char_t* dotnet_type_method);
// String constants
static const char_t* t1_name = DNNE_STR("ReaperDNNE.MyReaperPlugin, ReaperDNNE");
// Exports
// Computed from ReaperDNNE.MyReaperPlugin.ReaperPluginEntry
static int32_t (DNNE_CALLTYPE* ReaperPluginEntry_ptr)(intptr_t hInstance, struct reaper_plugin_info_t* rec);
DNNE_API int32_t DNNE_CALLTYPE ReaperPluginEntry(intptr_t hInstance, struct reaper_plugin_info_t* rec)
{
if (ReaperPluginEntry_ptr == NULL)
{
const char_t* methodName = DNNE_STR("ReaperPluginEntry");
ReaperPluginEntry_ptr = get_fast_callable_managed_function(t1_name, methodName);
}
return ReaperPluginEntry_ptr(hInstance, rec);
}
#endif // DNNE_COMPILE_AS_SOURCE
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.