Having trouble getting CEF to compile in an ATL/COM dll

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Having trouble getting CEF to compile in an ATL/COM dll

Postby kdelgado » Mon Oct 27, 2014 8:55 am

We want to be able to encapsulate the CEF in an ATL/COM dll that we will get loaded from several different applications to allow us to display web-based UI. I have had no luck getting the CEF to embed into my dll, specifically, no luck getting everything to link. Based on readings from google, I have tried many things, eg making sure everything is set and compiled with same flags (/MDd in my case), but it will not link. Currently I am getting the following:

1>ChromiumWrapper.obj : error LNK2019: unresolved external symbol "int __cdecl CefExecuteProcess(class CefMainArgs const &,class CefRefPtr<class CefApp>,void *)" (?CefExecuteProcess@@YAHABVCefMainArgs@@V?$CefRefPtr@VCefApp@@@@PAX@Z) referenced in function "public: virtual long __stdcall CChromiumWrapper::BrowseToURL(wchar_t *)" (?BrowseToURL@CChromiumWrapper@@UAGJPA_W@Z)
1>ChromiumWrapper.obj : error LNK2019: unresolved external symbol "bool __cdecl CefInitialize(class CefMainArgs const &,class CefStructBase<struct CefSettingsTraits> const &,class CefRefPtr<class CefApp>,void *)" (?CefInitialize@@YA_NABVCefMainArgs@@ABV?$CefStructBase@UCefSettingsTraits@@@@V?$CefRefPtr@VCefApp@@@@PAX@Z) referenced in function "public: virtual long __stdcall CChromiumWrapper::BrowseToURL(wchar_t *)" (?BrowseToURL@CChromiumWrapper@@UAGJPA_W@Z)
1>ChromiumWrapper.obj : error LNK2019: unresolved external symbol "void __cdecl CefShutdown(void)" (?CefShutdown@@YAXXZ) referenced in function "public: virtual long __stdcall CChromiumWrapper::BrowseToURL(wchar_t *)" (?BrowseToURL@CChromiumWrapper@@UAGJPA_W@Z)
1>ChromiumWrapper.obj : error LNK2019: unresolved external symbol "void __cdecl CefRunMessageLoop(void)" (?CefRunMessageLoop@@YAXXZ) referenced in function "public: virtual long __stdcall CChromiumWrapper::BrowseToURL(wchar_t *)" (?BrowseToURL@CChromiumWrapper@@UAGJPA_W@Z)
1>TestCefApp.obj : error LNK2019: unresolved external symbol "public: static class CefRefPtr<class CefCommandLine> __cdecl CefCommandLine::GetGlobalCommandLine(void)" (?GetGlobalCommandLine@CefCommandLine@@SA?AV?$CefRefPtr@VCefCommandLine@@@@XZ) referenced in function "public: virtual void __thiscall TestCefApp::OnContextInitialized(void)" (?OnContextInitialized@TestCefApp@@UAEXXZ)
1>TestCefApp.obj : error LNK2019: unresolved external symbol "public: static bool __cdecl CefBrowserHost::CreateBrowser(class CefWindowInfo const &,class CefRefPtr<class CefClient>,class CefStringBase<struct CefStringTraitsUTF16> const &,class CefStructBase<struct CefBrowserSettingsTraits> const &,class CefRefPtr<class CefRequestContext>)" (?CreateBrowser@CefBrowserHost@@SA_NABVCefWindowInfo@@V?$CefRefPtr@VCefClient@@@@ABV?$CefStringBase@UCefStringTraitsUTF16@@@@ABV?$CefStructBase@UCefBrowserSettingsTraits@@@@V?$CefRefPtr@VCefRequestContext@@@@@Z) referenced in function "public: virtual void __thiscall TestCefApp::OnContextInitialized(void)" (?OnContextInitialized@TestCefApp@@UAEXXZ)
1>TestCefApp.obj : error LNK2019: unresolved external symbol "bool __cdecl CefCurrentlyOn(enum cef_thread_id_t)" (?CefCurrentlyOn@@YA_NW4cef_thread_id_t@@@Z) referenced in function "public: virtual void __thiscall TestCefApp::OnContextInitialized(void)" (?OnContextInitialized@TestCefApp@@UAEXXZ)
1>TestCefHandler.obj : error LNK2001: unresolved external symbol "bool __cdecl CefCurrentlyOn(enum cef_thread_id_t)" (?CefCurrentlyOn@@YA_NW4cef_thread_id_t@@@Z)
1>TestCefHandler_win.obj : error LNK2001: unresolved external symbol "bool __cdecl CefCurrentlyOn(enum cef_thread_id_t)" (?CefCurrentlyOn@@YA_NW4cef_thread_id_t@@@Z)
1>TestCefHandler.obj : error LNK2019: unresolved external symbol "bool __cdecl CefPostTask(enum cef_thread_id_t,class CefRefPtr<class CefTask>)" (?CefPostTask@@YA_NW4cef_thread_id_t@@V?$CefRefPtr@VCefTask@@@@@Z) referenced in function "public: void __thiscall TestCefHandler::CloseAllBrowsers(bool)" (?CloseAllBrowsers@TestCefHandler@@QAEX_N@Z)
1>TestCefHandler.obj : error LNK2019: unresolved external symbol "void __cdecl CefQuitMessageLoop(void)" (?CefQuitMessageLoop@@YAXXZ) referenced in function "public: virtual void __thiscall TestCefHandler::OnBeforeClose(class CefRefPtr<class CefBrowser>)" (?OnBeforeClose@TestCefHandler@@UAEXV?$CefRefPtr@VCefBrowser@@@@@Z)


I've tried a few things to get rid of that, and it just ends up trading those linker errors for others.

So, what I am really after is a basic sample project (visual studio 2013) that embeds the CEF in an atl/com dll and actually compiles and links. I have seen a few posts here from people doing what I am attempting to do, so I assume it is possible.

Any help is greatly appreciated! Thanks!
kdelgado
Newbie
 
Posts: 6
Joined: Mon Oct 27, 2014 7:58 am

Re: Having trouble getting CEF to compile in an ATL/COM dll

Postby magreenblatt » Mon Oct 27, 2014 10:07 am

It looks like you're not linking the libcef_dll_wrapper static library.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Having trouble getting CEF to compile in an ATL/COM dll

Postby kdelgado » Mon Oct 27, 2014 10:21 am

magreenblatt wrote:It looks like you're not linking the libcef_dll_wrapper static library.


No, built it as a dll. However, I previously DID try linking with the static version, which as I mentioned yielded a different set of linker errors. I've tried many, MANY different configurations based on things I have found via google search, but nothing yet has linked properly. That's why I am after a working sample to figure out what special joojoo I am missing.
kdelgado
Newbie
 
Posts: 6
Joined: Mon Oct 27, 2014 7:58 am

Re: Having trouble getting CEF to compile in an ATL/COM dll

Postby magreenblatt » Mon Oct 27, 2014 10:25 am

kdelgado wrote:
magreenblatt wrote:It looks like you're not linking the libcef_dll_wrapper static library.


No, built it as a dll.

That likely doesn't work for you because the symbols defined by libcef_dll_wrapper will not be exported from a DLL by default.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Having trouble getting CEF to compile in an ATL/COM dll

Postby kdelgado » Mon Oct 27, 2014 12:30 pm

magreenblatt wrote:That likely doesn't work for you because the symbols defined by libcef_dll_wrapper will not be exported from a DLL by default.


When I build libcef_dll_wrapper as a static lib, my atl/com dll will build and link. However, when I try to link the .exe project (C++) that references THAT dll, it get a different set of errors:

1>TestHostDlg.obj : error LNK2001: unresolved external symbol "public: virtual long __stdcall CChromiumWrapper::BrowseToURL(wchar_t *)" (?BrowseToURL@CChromiumWrapper@@UAGJPA_W@Z)
1>TestHostDlg.obj : error LNK2001: unresolved external symbol _IID_IChromiumWrapper
1>TestHostDlg.obj : error LNK2001: unresolved external symbol _LIBID_TestSharedLibLib
1>TestHostDlg.obj : error LNK2001: unresolved external symbol _CLSID_ChromiumWrapper


From a different .Net test .exe, I can add a reference to the COM dll and build fine (it runs but dies, probably due to message pump stuff, but that's another issue for later). It is good that I can load it from .Net, but I have requirements to be able to load it from unmanaged code as well.
kdelgado
Newbie
 
Posts: 6
Joined: Mon Oct 27, 2014 7:58 am

Re: Having trouble getting CEF to compile in an ATL/COM dll

Postby magreenblatt » Mon Oct 27, 2014 12:40 pm

It looks like your atl/com dll is not properly exporting symbols. You might want to start with a simple working atl/com dll example so that you fully understand the atl/com requirements before trying to integrate CEF into it.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Having trouble getting CEF to compile in an ATL/COM dll

Postby kdelgado » Mon Oct 27, 2014 12:49 pm

magreenblatt wrote:It looks like your atl/com dll is not properly exporting symbols. You might want to start with a simple working atl/com dll example so that you fully understand the atl/com requirements before trying to integrate CEF into it.


I initially started with just the ATL dll and the test host exe, and it worked fine. Linking problems only came into play once I started adding CEF.
kdelgado
Newbie
 
Posts: 6
Joined: Mon Oct 27, 2014 7:58 am

Re: Having trouble getting CEF to compile in an ATL/COM dll

Postby kdelgado » Mon Oct 27, 2014 12:57 pm

Now, it is possible that at some point with all the stuff I was trying that something in that initial set-up got hosed. Literally have tried every suggestion I have found online.

Going to make another initial com.dll & host c++ exe and start from scratch. Again. Why not.
kdelgado
Newbie
 
Posts: 6
Joined: Mon Oct 27, 2014 7:58 am

Re: Having trouble getting CEF to compile in an ATL/COM dll

Postby magreenblatt » Mon Oct 27, 2014 1:17 pm

kdelgado wrote:1>TestHostDlg.obj : error LNK2001: unresolved external symbol "public: virtual long __stdcall CChromiumWrapper::BrowseToURL(wchar_t *)" (?BrowseToURL@CChromiumWrapper@@UAGJPA_W@Z)
1>TestHostDlg.obj : error LNK2001: unresolved external symbol _IID_IChromiumWrapper
1>TestHostDlg.obj : error LNK2001: unresolved external symbol _LIBID_TestSharedLibLib
1>TestHostDlg.obj : error LNK2001: unresolved external symbol _CLSID_ChromiumWrapper

Your atl/com DLL should mark these symbols as exported, otherwise the exe won't be able to link them. See for example http://msdn.microsoft.com/en-us/library/a90k134d.aspx.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Having trouble getting CEF to compile in an ATL/COM dll

Postby kdelgado » Mon Oct 27, 2014 4:29 pm

magreenblatt wrote:Your atl/com DLL should mark these symbols as exported, otherwise the exe won't be able to link them. See for example http://msdn.microsoft.com/en-us/library/a90k134d.aspx.


No, shouldn't have to export COM interfaces.

I finally got it to work via #import on the dll (which i had tried before), although it isn't how we'd want to do it in production. This is proof of concept so now I'm onto actually getting the chromium browser window to show. I had read somewhere that you aren't supposed to call CefInitialize if you are loading it from a dll, just have to find that post now...

Thanks.
kdelgado
Newbie
 
Posts: 6
Joined: Mon Oct 27, 2014 7:58 am


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 50 guests