4

I want to integrate cobalt as a browser in my project.The plan is to do this by having cobalt as a shared library. A detailed explanation would be appreciated.

My specific question would be as to how can i build the cobalt browser as a shared library.

Midhun
  • 744
  • 2
  • 15
  • 31
  • tried creating a target as cobalt_shared_lib with type as 'shared_library' in the cobalt.gyp file but the build is giving me error that 'shared_library' is not supported for target cobalt_shared_lib. But the same target gets built without any errors in case of 'static_library' as type instead of 'shared_library'. – Midhun Jun 05 '18 at 10:30
  • 1
    We currently do not support building Cobalt as a shared library and do not have a guideline for that. Can you explain me why you need Cobalt as a shared library and what "I want to integrate cobalt as a browser in my project." means in detail? – Daniel Juyung Seo Jun 05 '18 at 15:57
  • To paraphrase Daniel's question: how do you imagine the API for such a library to look like? – mmotorny Jun 05 '18 at 18:43
  • @Midhun This is a soft reminder. – Daniel Juyung Seo Jun 07 '18 at 05:44
  • @DanielJuyungSeo thanks for asking. We would like to build another application which uses the apis from cobalt. We need this for a specific device target. If we could have a shared library, then we could create our end user applications which uses the cobalt browser library functionalities. This would avoid us shipping the source code. – Midhun Jun 07 '18 at 05:59
  • @DanielJuyungSeo Also if not as a shared library is there a provision to build it as a static library using cmake especially. Are there any documentation available for that. – Midhun Jun 07 '18 at 14:10
  • @Midhun Thanks for the explanation. Unfortunately, that'll require a dedicated effort and we have no plan to do that yet. We're open for your contribution but considering Cobalt is moving really fast, it would be tough to maintain. – Daniel Juyung Seo Jun 07 '18 at 15:57
  • @DanielJuyungSeo as far as i understand cobalt is derived from chromium. Chromium as shared_library is possible then why not cobalt(please correct me if i'am wrong). Also i would like to know if individual components like net, crypto etc can be build as a shared library. – Midhun Jun 13 '18 at 13:22
  • Chromium only supports building separate modules as shared libraries, not the main Chromium binary. Cobalt indeed derives a lot of code from Chromium but our build system has many modification to enable larger portability, thus some features might be unavailable. In particular, we don't build Cobalt modules as shared libraries. – mmotorny Jun 13 '18 at 17:53

1 Answers1

0

The easiest way to integrate Cobalt in another binary is to rename main() function from your Starboard implementation (I'm assuming your OS is POSIX-like) into something like cobalt_main() and change the type in cobalt target (located in cobalt/browser/cobalt.gyp) to shared_library. Deeper integrations will require more effort.

I'm not quite sure if you even need to build Cobalt as a shared library. Perhaps you can simply run the same Cobalt binary but point it to another app?

mmotorny
  • 320
  • 1
  • 7
  • I tried the method that you told but resulted in the following error actually, there are many more but all are of same type. `error: ../../cobalt/base/wrap_main_starboard.h:34: can't create dynamic relocation R_X86_64_32S against symbol '__asan_option_detect_stack_use_after_return' defined in obj/cobalt/browser/cobalt.main.o` Also i have been searching for this `R_X86_64_32S`. What is this and why is it resulting in error. – Midhun Jun 14 '18 at 05:46