chakra-core / ChakraCore

ChakraCore is an open source Javascript engine with a C API.
MIT License
9.13k stars 1.2k forks source link

Embedding ChakraCore into OS X application #1532

Closed Kureev closed 8 years ago

Kureev commented 8 years ago

Hi there,

I'm trying to embed ChakraCore into OS X application. I managed to do it without any issues at compile time, but the app doesn't run tho (doesn't even hit breakpoint in int main func). Any ideas what can go wrong there?

UPD: Maybe related to https://github.com/Microsoft/ChakraCore/issues/1237

obastemur commented 8 years ago

@Kureev Did you see our ChakraCore samples? https://github.com/Microsoft/Chakra-Samples/tree/master/ChakraCore%20Samples/Hello%20World

Comparing to that what do you do different?

Kureev commented 8 years ago

@obastemur I'm actually trying to run Hello World example from the OS X application. I'm using ObjectiveC++ to run it. It compiles without errors (in XCode), but after that nothing happens (expected behavior - I see Hello World in the console). I can share my git repo if needed

Kureev commented 8 years ago

Will it help if I share my XCode example?

P.S. I suspect it fails when I try to create a JS runtime (if I remove code below this line (inclusive), it works). Will be nice if you can point me to the right direction and I debug it by myself.

obastemur commented 8 years ago

(if I remove code below this line (inclusive), it works

?

Will it help if I share my XCode example?

Sure

Kureev commented 8 years ago

I mean if I remove everything below JsCreateRuntime(incl) from HelloWorld example - everything works.

Here's my research project: https://github.com/Kureev/GoldenGate

P.S. Thanks for the fast feedback, really appreciate it ❤️

obastemur commented 8 years ago

@Kureev it is all about the order of the libs. See updated project file at https://gist.github.com/obastemur/73bec7c23e02aeba67200f4c1cd2cad9

I was able to see Hello World on the console.

sscc

obastemur commented 8 years ago

Closing for now. Thanks for bringing it up.

Kureev commented 8 years ago

Indeed, reordering libraries helped!

Thank you for your time and assistance. I know, it's a bit a side track, but could you be so kind to explain why dependency order matters?

obastemur commented 8 years ago

why dependency order matters?

a - Library X depends on Library Y. [ Y->X ] b - Library X depends on Library Z too. (Y shares an interface with Z that we override) [Z->Y->X]

Failing on (a) may produce a linker error (see below), failing on (b) may produce an undefined runtime behavior.

IIRC VS linker does pretty decent job. GCC et. all depends on the order I've just mentioned previously.