Your linker errors have nothing to do with your d/C++ bindings. It looks like your dll is missing critical stuff referenced by your C++ code. Find where WebCore and WebView are implemented and ensure they're part of the dll (or add extra object files on the command line)
Chris Williams Wrote: > I'm trying to connect over to the C++ package called Awesomium > (http://princeofcode.com/awesomium.php), which is decently small. I've > created the files dawesome.h, dawesome.cpp, and dawesome.di, which you can > see at the bottom of this post. Awesomium's library file was an import > library, so I used coffimplib to convert it. I am using dmc to compile my > files, using Digital Mars' stlport package. > > But so when, at the end, I try to compile a full EXE on a test program > (dawesome_test.d), I get some linker errors combining it with my bindings > (dawesome.obj) and awesomium's converted library: > > T:\programs\Dawesome>t:\dmd\windows\bin\dmd.exe dawesome_test.d dawesome.obj > awesomium.lib > OPTLINK (R) for Win32 Release 8.00.1 > Copyright (C) Digital Mars 1989-2004 All rights reserved. > dawesome.obj(dawesome) > Error 42: Symbol Undefined > ?load...@webview@Awesomium@@qaexabv?$basic_str...@st > d...@dv?$char_traits@s...@d@1...@v?$allocator@s...@d@1@@std@ (void syscall > Awesomium::We > bView::loadURL(basic_string<>::d::DV?$char_traits::std::D::WebView const > &,alloc > ator<>::d::D::WebView )) > dawesome.obj(dawesome) > Error 42: Symbol Undefined > ?setcustomresponsep...@webcore@Awesomium@@QAEXHABV?$ > basic_str...@std@dv?$char_tra...@std@d...@1@v?$alloca...@std@d...@1@@std@ > (void syscal > l Awesomium::WebCore::setCustomResponsePage(int > ,basic_string<>::d::DV?$char_tra > its::std::D::WebCore const &,allocator<>::d::D::WebCore )) > dawesome.obj(dawesome) > Error 42: Symbol Undefined > ?setbasedirect...@webcore@Awesomium@@QAEXABV?$basic_ > str...@std@dv?$char_tra...@std@d...@1@v?$alloca...@std@d...@1@@std@ (void > syscall Awes > omium::WebCore::setBaseDirectory(basic_string<>::d::DV?$char_traits::std::D::Web > Core const &,allocator<>::d::D::WebCore )) > --- errorlevel 3 > > I'm very new to D and was always more a C guy than a C++ guy, so I'm really > not sure where in the chain I might have gone wrong. > > Here are my files: > > dawesome.h > ----------------------------------------------- > #ifndef __DAWESOME_H__ > #define __DAWESOME_H__ > > extern "C" { > > struct listen_funcs { > void (*onBeginNavigation)(const char* url); > void (*onBeginLoading)(const char* url, int statusCode, const wchar_t* > mimeType); > void (*onFinishLoading)(); > void (*onReceiveTitle)(const wchar_t* title); > void (*onChangeTooltip)(const wchar_t* tooltip); > void (*onChangeKeyboardFocus)(int isFocused); > }; > > int dawesome_init(struct listen_funcs* l_funcs, const char* baseDir, int > width, int height); > void dawesome_cleanup(); > > void dawesome_setCustomResponsePage(int statusCode, const char* filePath); > void dawesome_loadURL(const char* url); > void dawesome_loadHTML(const char* html); > void dawesome_loadFile(const char* path); > > void dawesome_render(unsigned char* destination, int destRowSpan, int > destDepth); > void dawesome_resize(int width, int height); > > } > > #endif > ----------------------------------------------- > > > dawesome.cpp > ----------------------------------------------- > #include "dawesome.h" > #include "WebCore.h" > > #include <string> > > using namespace Awesomium; > > class MyListener : public WebViewListener { > private: > struct listen_funcs* my_listener; > > public: > MyListener(struct listen_funcs* listener) { > my_listener = listener; > } > > void onBeginNavigation(const std::string& url) { > if (my_listener->onBeginNavigation != NULL) { > my_listener->onBeginNavigation(url.c_str()); > } > } > > void onBeginLoading(const std::string& url, int statusCode, const > std::wstring& mimeType) { > if (my_listener->onBeginLoading != NULL) { > my_listener->onBeginLoading( > url.c_str(), > statusCode, > mimeType.c_str() > ); > } > } > > void onFinishLoading() { > if (my_listener->onFinishLoading != NULL) { > my_listener->onFinishLoading(); > } > } > > void onCallback(const std::string& name, const Awesomium::JSArguments& > args) {} > > void onReceiveTitle(const std::wstring& title) { > if (my_listener->onReceiveTitle != NULL) { > my_listener->onReceiveTitle(title.c_str()); > } > } > > void onChangeTooltip(const std::wstring& tooltip) { > if (my_listener->onChangeTooltip != NULL) { > my_listener->onChangeTooltip(tooltip.c_str()); > } > } > > void onChangeCursor(const HCURSOR& cursor) {} > > void onChangeKeyboardFocus(bool isFocused) { > if (my_listener->onChangeKeyboardFocus != NULL) { > my_listener->onChangeKeyboardFocus( > isFocused ? 1 : 0 > ); > } > } > }; > > //------------- > WebCore* core; > WebView* view; > MyListener* listener; > > int dawesome_init(struct listen_funcs* l_funcs, const char* baseDir, int > width, int height) { > std::string str(baseDir); > > core = new WebCore(LOG_VERBOSE); > core->setBaseDirectory(str); > view = core->createWebView(width, height, false, true, 70); > if (view == NULL) return 0; > > listener = new MyListener(l_funcs); > view->setListener(listener); > > return 1; > } > > void dawesome_cleanup() { > view->destroy(); > delete core; > delete listener; > } > > void dawesome_setCustomResponsePage(int statusCode, const char* filePath) { > std::string str(filePath); > core->setCustomResponsePage(statusCode, str); > } > > void dawesome_loadURL(const char* url) { > std::string str(url); > view->loadURL(str, "", ""); > } > > void dawesome_loadHTML(const char* html) { > std::string str(html); > view->loadURL(str); > } > > void dawesome_loadFile(const char* path) { > std::string str(path); > view->loadURL(str); > } > > void dawesome_render(unsigned char* destination, int destRowSpan, int > destDepth) { > view->render(destination, destRowSpan, destDepth, 0); > } > > void dawesome_resize(int width, int height) { > view->resize(width, height); > } > ----------------------------------------------- > > dawesome.di > ----------------------------------------------- > extern (C) { > > struct listen_funcs { > void (*onBeginNavigation)(char* url); > void (*onBeginLoading)(char* url, int statusCode, wchar* mimeType); > void (*onFinishLoading)(); > void (*onReceiveTitle)(wchar* title); > void (*onChangeTooltip)(wchar* tooltip); > void (*onChangeKeyboardFocus)(int isFocused); > } > > int dawesome_init(listen_funcs* l_funcs, char* baseDir, int width, int > height); > void dawesome_cleanup(); > > void dawesome_setCustomResponsePage(int statusCode, char* filePath); > void dawesome_loadURL(char* url); > void dawesome_loadHTML(char* html); > void dawesome_loadFile(char* path); > > void dawesome_render(ubyte* destination, int destRowSpan, int destDepth); > void dawesome_resize(int width, int height); > > } > -----------------------------------------------
