Page 1 of 1

Windows: Newbe link error

PostPosted: Mon Sep 19, 2011 4:31 am
by Even
Hi,

I'm completely new in the universe of CEF and even chromium. I was successfull at compiling libcef using the cef solution on VS2010 after some work on it. But I'm trying to get working a small "empty" projet that would be independant from the huge cef solution that takes loads of time to open using VS2010.

Right now, I have written a very simple code that looks like :
Code: Select all
RECT r = {0, 0, 1000, 1000};

CefWindowInfo info;
info.SetAsChild(hWnd, r);

CefBrowserSettings settings;

CefBrowser::CreateBrowser(info, 0, L"http://www.google.com", settings);

I'm saving you the boring stuff about the window initialization for the moment, if you feel like you need it, just ask.

I have added libcef.lib in the linker libraries to be able to link with it.

The problem is that when VS2010 links, I get the following error :
Code: Select all
1>main.obj : error LNK2019: unresolved external symbol "public: static bool __cdecl CefBrowser::CreateBrowser(class CefWindowInfo &,class CefRefPtr<class CefClient>,class CefStringBase<struct CefStringTraitsUTF16> const &,class CefStructBase<struct CefBrowserSettingsTraits> const &)" (?CreateBrowser@CefBrowser@@SA_NAAVCefWindowInfo@@V?$CefRefPtr@VCefClient@@@@ABV?$CefStringBase@UCefStringTraitsUTF16@@@@ABV?$CefStructBase@UCefBrowserSettingsTraits@@@@@Z) referenced in function "long __stdcall WndProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WndProc@@YGJPAUHWND__@@IIJ@Z)


I tried to add the libcef_dll_wrapper.lib to the linker but then the error messages just change to become :
Code: Select all
1>msvcprtd.lib(MSVCP100D.dll) : error LNK2005: "public: __thiscall std::_Container_base12::~_Container_base12(void)" (??1_Container_base12@std@@QAE@XZ) already defined in libcef_dll_wrapper.lib(v8handler_cpptoc.obj)
[... (put here other errors of the same type on other symbols, same lib involved)]


Then I tried to add "msvcprtd.lib" in the "Ignore Specific Default Libraries" option of the linker to prevent those symbols to be defined at two different places. Problem: the program starts but immediately fails with the following error:
Code: Select all
Assertion failed!

Program: ...
File: C:\Chromium\src\cef\libcef_dll/cpptoc/cpptoc.h
Line: 70

Expression: cls


Any ideas of what I have done wrong here?

Thanks a lot for your time and help.

Re: Windows: Newbe link error

PostPosted: Mon Sep 19, 2011 11:21 am
by Even
OK, after digging some more, I found that I couldn't pass 0 to get a default implementation for CefClient. Using a very simple class was the solution. It took me some time to find the IMPLEMENT_REFCOUNTING macro but using it is was really a piece of cake.

After that I found the CefRunMessageLoop function and everything sorted fine. Sorry for the useless post. At least it might help someone one day (hope so).

In this set of mind, I'll add there the simple code I used to create a CefClient implementation here:
Code: Select all
class ClientHandler: public CefClient
{
public:

IMPLEMENT_REFCOUNTING(ClientHandler);
};


You can then use it this way:
Code: Select all
CefRefPtr<CefClient> client(new ClientHandler);

CefBrowser::CreateBrowser(info, client, L"http://www.google.com/", browser_settings);


Hope this helps...

Re: Windows: Newbe link error

PostPosted: Fri May 18, 2012 10:24 am
by antoine1fr
Hi Even

I am sorry for bumping this old post.
I am having the same linking issue that you had with the function CefBrowser::CreateBrowser.

Here is my C++ code:

Code: Select all
class ClientHandler : public CefClient
{
public:
   IMPLEMENT_REFCOUNTING(ClientHandler);
}; // Client

int main(void)
{
   CefRefPtr<CefClient> handler(new ClientHandler);
   CefWindowInfo info;
   CefBrowserSettings settings;
   CefBrowser::CreateBrowser(info, handler, L"http://www.google.com", settings);
   return EXIT_SUCCESS;
}


And here is the linker output message :

Code: Select all
main.obj : error LNK2019: unresolved external symbol "public: static bool __cdecl CefBrowser::CreateBrowser(class CefWindowInfo &,class CefRefPtr<class CefClient>,class CefStringBase<struct CefStringTraitsUTF16> const &,class CefStructBase<struct CefBrowserSettingsTraits> const &)" (?CreateBrowser@CefBrowser@@SA_NAAVCefWindowInfo@@V?$CefRefPtr@VCefClient@@@@ABV?$CefStringBase@UCefStringTraitsUTF16@@@@ABV?$CefStructBase@UCefBrowserSettingsTraits@@@@@Z) referenced in function _main
C:\Users\Antoin\documents\visual studio 2010\Projects\cef_test\Debug\cef_test.exe : fatal error LNK1120: 1 unresolved externals


After reading your post I tried to link against libcef_dll_wrapper.lib in addition to just libcef.lib but nothing changed.

Do you have any ideas of what I am doing wrong ?

Thanks

Re: Windows: Newbe link error

PostPosted: Sat May 19, 2012 11:07 pm
by keshav
Olrit check these few things, -> make sure ur using MT insted of MD runtime libraries, after that use V90 which says visual studio 2008 compiler, if u still get an error post again

Re: Windows: Newbe link error

PostPosted: Sat May 19, 2012 11:09 pm
by keshav
also u might have to cast ur clienthandler before passing it to createBrowser

Re: Windows: Newbe link error

PostPosted: Mon Jun 04, 2012 2:54 am
by mako123
I'm having the same unresolved symbol ( CefBrowser::CreateBrowser ) issue.

I used VS2010 to build the cefclient example executable succesfully using the provided VS solution and it runs and shows web content.
The configuration of the cefclient in the solution just links to libcef.lib.

Therefore I doubt it could be a configuration/preprocessor issue when building my own executable ?
I don't use VS to actually build my executable, I use make to directly call compiler/linker. Maybe I miss something when calling compiler/linker ?
Any further hints available ?