wrapping CEF3 with a shared library

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.

wrapping CEF3 with a shared library

Postby trivigy » Wed Apr 27, 2016 12:38 pm

Hey, I am trying to wrap cef in a shared library on linux 64 but I am getting errors when CefInitialize is executed. Here is the crude structure I have so far. I am getting some kind of an allocation error and I am really at a loss of how to deal with. I read some information about people running into a similar problem working on a mfcdll but since I am on linux I figured I'll ask if anyone knows how to resolve this. Much help appreciated.

Code: Select all
Starting Application
[0427/131338:FATAL:content_main_runner.cc(644)] Check failed: base::allocator::IsAllocatorInitialized().
#0 0x7f8cc093177e base::debug::StackTrace::StackTrace()
#1 0x7f8cc0945d6b logging::LogMessage::~LogMessage()
#2 0x7f8cc38933f6 content::ContentMainRunnerImpl::Initialize()
#3 0x7f8cc085996f CefContext::Initialize()
#4 0x7f8cc085976b CefInitialize()
#5 0x7f8cc080d476 cef_initialize
#6 0x7f8cc5c13d90 CefInitialize()
#7 0x7f8cc5bfb27a MyClass::init()
#8 0x000000400d12 main
#9 0x7f8cc5291830 __libc_start_main
#10 0x000000400be9 _start

Aborted (core dumped)


This the wrapper which I compile as a shared library.
Code: Select all
class MyClass {
public:
    MyClass();
    int init(int argc, char *argv[]);
    ~MyClass();
private:
};


Code: Select all
MyClass::MyClass() {}
MyClass::~MyClass() {}

int MyClass::init(int argc, char *argv[]) {
    CefMainArgs main_args(argc, argv);
    CefRefPtr<ClientApp> app(new ClientApp);

        int exit_code = CefExecuteProcess(main_args, app.get(), NULL);
        if (exit_code >= 0) {
            return 1;
        }

    // TODO REMOVE
    XSetErrorHandler(XErrorHandlerImpl);
    XSetIOErrorHandler(XIOErrorHandlerImpl);

    CefSettings settings;

    settings.remote_debugging_port = 8888;  // TODO REMOVE
    CefInitialize(main_args, settings, app.get(), NULL);

    CefRunMessageLoop();
    CefShutdown();

    std::cout << "haza" << std::endl;
    return 0;
}


This is the application.
Code: Select all
int main(int argc, char *argv[]) {
    std::cout << "Starting Application" << std::endl;
    MyClass application;
    application.init(argc, argv);

    return 0;
}
trivigy
Newbie
 
Posts: 2
Joined: Wed Apr 27, 2016 12:27 pm

Re: wrapping CEF3 with a shared library

Postby magreenblatt » Wed Apr 27, 2016 1:03 pm

Here are the comments from the source code: https://code.google.com/p/chromium/code ... r.cc&l=612

The CEF binaries are built with tcmalloc by default. You need to either run with LD_PRELOAD=libcef.so or build CEF locally without tcmalloc. See https://bitbucket.org/chromiumembedded/cef/issues/1827 for additional details.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: wrapping CEF3 with a shared library

Postby trivigy » Wed Apr 27, 2016 1:22 pm

Oh nice. LD_PRELOAD works like magic. So unfortunate that I am not experienced enough with c/c++ to know some of these tricks. I am also going to read on and see how to recompile this without the tcmalloc.

Thanks a tons! If you ever need anything feel free to reach out.
trivigy
Newbie
 
Posts: 2
Joined: Wed Apr 27, 2016 12:27 pm


Return to Support Forum

Who is online

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