Re: [v8-users] Undefined reference to v8::platform::NewDefaultPlatform

2018-01-02 Thread Zac Hansen
The problem is that when you *compile* with libstdc++ when building against
the v8 external API header, it generates object files looking for symbols
with the libstdc++ names.

At that point there's no winning because you have v8 libs which need libc++
and your object files which need libstdc++.

At least that's how I understand it.

On Tue, Jan 2, 2018 at 1:41 AM, Bogdan Padalko 
wrote:

> Indeed. By "relocation" I mean that it was built using one stdlib and
> moved to the system with another one, but I agree that it's more correct to
> name as stdlib issue rather then relocation issue. I tried to link with
> libc++.so that generated by v8 build, though, no luck with it for some
> reason. For now using is_clang=false works fine, apart that it increases
> php-v8 tests run time with valgrind enabled significantly.
>
>
>
> On Tuesday, January 2, 2018 at 7:59:48 AM UTC+2, Zac Hansen wrote:
>>
>> It's not a "relocation" issue, I'm pretty sure -- it's a stdlib issue.
>>  It looks like the first symbol was from libc++ (the __1 gives it away) and
>> the second was most likely from libstdc++.  <== just a guess but pretty
>> consistent with stuff I've seen before.
>>
>> On Monday, January 1, 2018 at 10:57:12 AM UTC-8, Bogdan Padalko wrote:
>>>
>>> Thanks Ben! This is it. It was my fault building with clang and hoping
>>> that the build will be relocatable.
>>>
>>> Building with GN args:
>>>  is_debug: false,
>>>  is_official_build: true,
>>>  is_component_build: true,
>>>  is_cfi: false,
>>>  is_clang: false,
>>>  v8_use_external_startup_data: false,
>>>  treat_warnings_as_errors: false,
>>>  use_custom_libcxx: false,
>>>  use_sysroot: false,
>>>  use_gold: false
>>>
>>> works perfect!
>>>
>>> Thank you all who's been helping me with this! Happy New Year!
>>>
>>> Regards,
>>> Bogdan
>>>
>>>
>>>
>>>
>>> On Monday, January 1, 2018 at 4:17:54 PM UTC+2, Ben Noordhuis wrote:

 On Mon, Jan 1, 2018 at 3:00 PM, Bogdan Padalko 
 wrote:
 > Hi Zac, thanks for the quick reply!
 >
 > Here's what I see in library:
 >
 > $ objdump -T /opt/libv8-6.5/lib/libv8_libplatform.so  | grep
 NewDefault
 > a850 gDF .text012e  Base
 > _ZN2v88platform18NewDefaultPlatformEiNS0_15IdleTaskSupportEN
 S0_21InProcessStackDumpingENSt3__110unique_ptrINS_17TracingC
 ontrollerENS3_14default_deleteIS5_
 >
 >
 > and this is the error I get later when get php-v8 compiled and try to
 load:
 >
 > _ZN2v88platform18NewDefaultPlatformEiNS0_15IdleTaskSupportEN
 S0_21InProcessStackDumpingESt10unique_ptrINS_17TracingControllerESt14default_deleteIS4_EE

 >
 > As you see, they differs and it looks like I missed something, but
 couldn't
 > grasp what and it looks like this is the cause of
 >
 > /home/vagrant/php-v8/scripts/test_v8/hello_world.cpp:21: undefined
 reference
 > to `v8::platform::NewDefaultPlatform(int,
 v8::platform::IdleTaskSupport,
 > v8::platform::InProcessStackDumping, 
 > std::unique_ptr std::default_delete >)'
 >
 > error too.
 >
 > Happy New Year!
 > Bogdan

 If you run them through c++filt, you'll see the difference:

   v8::platform::NewDefaultPlatform(int, v8::platform::IdleTaskSupport,
 v8::platform::InProcessStackDumping,
 std::__1::unique_ptr)

 vs:

   v8::platform::NewDefaultPlatform(int, v8::platform::IdleTaskSupport,
 v8::platform::InProcessStackDumping,
 std::unique_ptr)

 I'm guessing one is compiled against different headers than the other
 or with a different -std=... flag.  If you built V8 with the bundled
 clang, try rebuilding it with clang=0.

>>> --
> --
> v8-users mailing list
> v8-users@googlegroups.com
> http://groups.google.com/group/v8-users
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "v8-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/v8-users/Jb1VSouy2Z0/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> v8-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [v8-users] Undefined reference to v8::platform::NewDefaultPlatform

2018-01-02 Thread Bogdan Padalko
Indeed. By "relocation" I mean that it was built using one stdlib and moved 
to the system with another one, but I agree that it's more correct to name 
as stdlib issue rather then relocation issue. I tried to link with 
libc++.so that generated by v8 build, though, no luck with it for some 
reason. For now using is_clang=false works fine, apart that it increases 
php-v8 tests run time with valgrind enabled significantly.


On Tuesday, January 2, 2018 at 7:59:48 AM UTC+2, Zac Hansen wrote:
>
> It's not a "relocation" issue, I'm pretty sure -- it's a stdlib issue.  
>  It looks like the first symbol was from libc++ (the __1 gives it away) and 
> the second was most likely from libstdc++.  <== just a guess but pretty 
> consistent with stuff I've seen before.
>
> On Monday, January 1, 2018 at 10:57:12 AM UTC-8, Bogdan Padalko wrote:
>>
>> Thanks Ben! This is it. It was my fault building with clang and hoping 
>> that the build will be relocatable.
>>
>> Building with GN args:
>>  is_debug: false,
>>  is_official_build: true,
>>  is_component_build: true,
>>  is_cfi: false,
>>  is_clang: false,
>>  v8_use_external_startup_data: false,
>>  treat_warnings_as_errors: false,
>>  use_custom_libcxx: false,
>>  use_sysroot: false,
>>  use_gold: false
>>
>> works perfect!
>>
>> Thank you all who's been helping me with this! Happy New Year!
>>
>> Regards,
>> Bogdan
>>
>>
>>
>>
>> On Monday, January 1, 2018 at 4:17:54 PM UTC+2, Ben Noordhuis wrote:
>>>
>>> On Mon, Jan 1, 2018 at 3:00 PM, Bogdan Padalko  
>>> wrote: 
>>> > Hi Zac, thanks for the quick reply! 
>>> > 
>>> > Here's what I see in library: 
>>> > 
>>> > $ objdump -T /opt/libv8-6.5/lib/libv8_libplatform.so  | grep 
>>> NewDefault 
>>> > a850 gDF .text012e  Base 
>>> > 
>>> _ZN2v88platform18NewDefaultPlatformEiNS0_15IdleTaskSupportENS0_21InProcessStackDumpingENSt3__110unique_ptrINS_17TracingControllerENS3_14default_deleteIS5_
>>>  
>>>
>>> > 
>>> > 
>>> > and this is the error I get later when get php-v8 compiled and try to 
>>> load: 
>>> > 
>>> > 
>>> _ZN2v88platform18NewDefaultPlatformEiNS0_15IdleTaskSupportENS0_21InProcessStackDumpingESt10unique_ptrINS_17TracingControllerESt14default_deleteIS4_EE
>>>  
>>>
>>> > 
>>> > As you see, they differs and it looks like I missed something, but 
>>> couldn't 
>>> > grasp what and it looks like this is the cause of 
>>> > 
>>> > /home/vagrant/php-v8/scripts/test_v8/hello_world.cpp:21: undefined 
>>> reference 
>>> > to `v8::platform::NewDefaultPlatform(int, 
>>> v8::platform::IdleTaskSupport, 
>>> > v8::platform::InProcessStackDumping, 
>>> std::unique_ptr>> > std::default_delete >)' 
>>> > 
>>> > error too. 
>>> > 
>>> > Happy New Year! 
>>> > Bogdan 
>>>
>>> If you run them through c++filt, you'll see the difference: 
>>>
>>>   v8::platform::NewDefaultPlatform(int, v8::platform::IdleTaskSupport, 
>>> v8::platform::InProcessStackDumping, 
>>> std::__1::unique_ptr>> std::__1::default_delete >) 
>>>
>>> vs: 
>>>
>>>   v8::platform::NewDefaultPlatform(int, v8::platform::IdleTaskSupport, 
>>> v8::platform::InProcessStackDumping, 
>>> std::unique_ptr>> std::default_delete >) 
>>>
>>> I'm guessing one is compiled against different headers than the other 
>>> or with a different -std=... flag.  If you built V8 with the bundled 
>>> clang, try rebuilding it with clang=0. 
>>>
>>

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [v8-users] Undefined reference to v8::platform::NewDefaultPlatform

2018-01-01 Thread Zac Hansen
It's not a "relocation" issue, I'm pretty sure -- it's a stdlib issue.   It 
looks like the first symbol was from libc++ (the __1 gives it away) and the 
second was most likely from libstdc++.  <== just a guess but pretty 
consistent with stuff I've seen before.

On Monday, January 1, 2018 at 10:57:12 AM UTC-8, Bogdan Padalko wrote:
>
> Thanks Ben! This is it. It was my fault building with clang and hoping 
> that the build will be relocatable.
>
> Building with GN args:
>  is_debug: false,
>  is_official_build: true,
>  is_component_build: true,
>  is_cfi: false,
>  is_clang: false,
>  v8_use_external_startup_data: false,
>  treat_warnings_as_errors: false,
>  use_custom_libcxx: false,
>  use_sysroot: false,
>  use_gold: false
>
> works perfect!
>
> Thank you all who's been helping me with this! Happy New Year!
>
> Regards,
> Bogdan
>
>
>
>
> On Monday, January 1, 2018 at 4:17:54 PM UTC+2, Ben Noordhuis wrote:
>>
>> On Mon, Jan 1, 2018 at 3:00 PM, Bogdan Padalko  
>> wrote: 
>> > Hi Zac, thanks for the quick reply! 
>> > 
>> > Here's what I see in library: 
>> > 
>> > $ objdump -T /opt/libv8-6.5/lib/libv8_libplatform.so  | grep NewDefault 
>> > a850 gDF .text012e  Base 
>> > 
>> _ZN2v88platform18NewDefaultPlatformEiNS0_15IdleTaskSupportENS0_21InProcessStackDumpingENSt3__110unique_ptrINS_17TracingControllerENS3_14default_deleteIS5_
>>  
>>
>> > 
>> > 
>> > and this is the error I get later when get php-v8 compiled and try to 
>> load: 
>> > 
>> > 
>> _ZN2v88platform18NewDefaultPlatformEiNS0_15IdleTaskSupportENS0_21InProcessStackDumpingESt10unique_ptrINS_17TracingControllerESt14default_deleteIS4_EE
>>  
>>
>> > 
>> > As you see, they differs and it looks like I missed something, but 
>> couldn't 
>> > grasp what and it looks like this is the cause of 
>> > 
>> > /home/vagrant/php-v8/scripts/test_v8/hello_world.cpp:21: undefined 
>> reference 
>> > to `v8::platform::NewDefaultPlatform(int, 
>> v8::platform::IdleTaskSupport, 
>> > v8::platform::InProcessStackDumping, 
>> std::unique_ptr> > std::default_delete >)' 
>> > 
>> > error too. 
>> > 
>> > Happy New Year! 
>> > Bogdan 
>>
>> If you run them through c++filt, you'll see the difference: 
>>
>>   v8::platform::NewDefaultPlatform(int, v8::platform::IdleTaskSupport, 
>> v8::platform::InProcessStackDumping, 
>> std::__1::unique_ptr> std::__1::default_delete >) 
>>
>> vs: 
>>
>>   v8::platform::NewDefaultPlatform(int, v8::platform::IdleTaskSupport, 
>> v8::platform::InProcessStackDumping, 
>> std::unique_ptr> std::default_delete >) 
>>
>> I'm guessing one is compiled against different headers than the other 
>> or with a different -std=... flag.  If you built V8 with the bundled 
>> clang, try rebuilding it with clang=0. 
>>
>

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [v8-users] Undefined reference to v8::platform::NewDefaultPlatform

2018-01-01 Thread Ben Noordhuis
On Mon, Jan 1, 2018 at 3:00 PM, Bogdan Padalko  wrote:
> Hi Zac, thanks for the quick reply!
>
> Here's what I see in library:
>
> $ objdump -T /opt/libv8-6.5/lib/libv8_libplatform.so  | grep NewDefault
> a850 gDF .text012e  Base
> _ZN2v88platform18NewDefaultPlatformEiNS0_15IdleTaskSupportENS0_21InProcessStackDumpingENSt3__110unique_ptrINS_17TracingControllerENS3_14default_deleteIS5_
>
>
> and this is the error I get later when get php-v8 compiled and try to load:
>
> _ZN2v88platform18NewDefaultPlatformEiNS0_15IdleTaskSupportENS0_21InProcessStackDumpingESt10unique_ptrINS_17TracingControllerESt14default_deleteIS4_EE
>
> As you see, they differs and it looks like I missed something, but couldn't
> grasp what and it looks like this is the cause of
>
> /home/vagrant/php-v8/scripts/test_v8/hello_world.cpp:21: undefined reference
> to `v8::platform::NewDefaultPlatform(int, v8::platform::IdleTaskSupport,
> v8::platform::InProcessStackDumping, std::unique_ptr std::default_delete >)'
>
> error too.
>
> Happy New Year!
> Bogdan

If you run them through c++filt, you'll see the difference:

  v8::platform::NewDefaultPlatform(int, v8::platform::IdleTaskSupport,
v8::platform::InProcessStackDumping,
std::__1::unique_ptr)

vs:

  v8::platform::NewDefaultPlatform(int, v8::platform::IdleTaskSupport,
v8::platform::InProcessStackDumping,
std::unique_ptr)

I'm guessing one is compiled against different headers than the other
or with a different -std=... flag.  If you built V8 with the bundled
clang, try rebuilding it with clang=0.

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [v8-users] Undefined reference to v8::platform::NewDefaultPlatform

2017-12-31 Thread Zac Hansen
If you look at the symbols in your libs is it in there anywhere?

On Saturday, December 30, 2017 at 10:01:28 AM UTC-8, Bogdan Padalko wrote:
>
> Thanks for quick reply! Unfortunately, it's the same. I ended up with 
> hello world example after to trying out to use NewDefaultPlatform with 
> php-v8 (
> https://github.com/pinepain/php-v8/blob/53a562e10c23e5f835b2ccdb20967f9c4aef529e/src/php_v8_a.cc#L34),
>  
> which yield me there
>
> /home/vagrant/.phpbrew/php/7.2-debug/bin/php: symbol lookup error: /home/
> vagrant/php-v8/modules/v8.so: undefined symbol: 
> _ZN2v88platform18NewDefaultPlatformEiNS0_15IdleTaskSupportENS0_21InProcessStackDumpingESt10unique_ptrINS_17TracingControllerESt14default_deleteIS4_EE
>
> With CreateDefaultPlatform it works just fine, and there was no other 
> changes to sources except of using v8 6.5.116 and using NewDefaultPlatform. 
> Bare 6.5.116 with CreateDefaultPlatform works fine.
>
>
> On Saturday, December 30, 2017 at 7:28:25 PM UTC+2, Ben Noordhuis wrote:
>>
>> On Sat, Dec 30, 2017 at 5:54 PM, Bogdan Padalko  
>> wrote: 
>> > Hi! 
>> > 
>> > I'm trying to adapt changes from 
>> > 
>> https://github.com/v8/v8/commit/ffee558e14e28fc8b1f9a3c10ea3615e0d686c7b 
>> to 
>> > replace CreateDefaultPlatform with NewDefaultPlatform calls, however, 
>> for 
>> > some reason I'm getting 
>> > 
>> > /home/vagrant/php-v8/scripts/test_v8/hello_world.cpp:21: undefined 
>> reference 
>> > to `v8::platform::NewDefaultPlatform(int, 
>> v8::platform::IdleTaskSupport, 
>> > v8::platform::InProcessStackDumping, 
>> std::unique_ptr> > std::default_delete >)' 
>> > 
>> > error with the following code: 
>> > 
>> > #include  
>> > #include  
>> > 
>> > #include  
>> > #include  
>> > 
>> > using namespace v8; 
>> > 
>> > void weak_callback(const 
>> v8::WeakCallbackInfo& 
>> > data) { 
>> >   printf("Weak callback called\n"); 
>> >   data.GetParameter()->Reset(); 
>> > } 
>> > 
>> > int main(int argc, char* argv[]) { 
>> >   // Initialize V8. 
>> >   v8::V8::InitializeICU(); 
>> > //  v8::Platform *platform = v8::platform::CreateDefaultPlatform(); 
>> > //  v8::V8::InitializePlatform(platform); 
>> > 
>> >   std::unique_ptr platform = 
>> > v8::platform::NewDefaultPlatform(); 
>> >   v8::V8::InitializePlatform(platform.get()); 
>> > 
>> >   V8::Initialize(); 
>> > 
>> >   v8::Isolate::CreateParams create_params; 
>> >   create_params.array_buffer_allocator = 
>> > v8::ArrayBuffer::Allocator::NewDefaultAllocator(); 
>> > 
>> >   // Create a new Isolate and make it the current one. 
>> >   Isolate* isolate = v8::Isolate::New(create_params); 
>> > 
>> >   v8::Persistent test; 
>> > 
>> >   { 
>> > Isolate::Scope isolate_scope(isolate); 
>> > 
>> > // Create a stack-allocated handle scope. 
>> > HandleScope handle_scope(isolate); 
>> > 
>> > // Create a new context. 
>> > Local context = Context::New(isolate); 
>> > 
>> > // Enter the context for compiling and running the hello world 
>> script. 
>> > Context::Scope context_scope(context); 
>> > 
>> > 
>> > test.Reset(isolate, String::NewFromUtf8(isolate, "Hello' + ', 
>> > World!'")); 
>> > test.SetWeak(, weak_callback, 
>> v8::WeakCallbackType::kParameter); 
>> > 
>> > 
>> > // Create a string containing the JavaScript source code. 
>> > Local source = String::NewFromUtf8(isolate, "(2+2*2) + ' ' 
>> + 
>> > 'Hello' + ', World!'"); 
>> > 
>> > // Compile the source code. 
>> > 

Re: [v8-users] Undefined reference to v8::platform::NewDefaultPlatform

2017-12-30 Thread Bogdan Padalko
Thanks for quick reply! Unfortunately, it's the same. I ended up with hello 
world example after to trying out to use NewDefaultPlatform with php-v8 
(https://github.com/pinepain/php-v8/blob/53a562e10c23e5f835b2ccdb20967f9c4aef529e/src/php_v8_a.cc#L34),
 
which yield me there

/home/vagrant/.phpbrew/php/7.2-debug/bin/php: symbol lookup error: /home/
vagrant/php-v8/modules/v8.so: undefined symbol: 
_ZN2v88platform18NewDefaultPlatformEiNS0_15IdleTaskSupportENS0_21InProcessStackDumpingESt10unique_ptrINS_17TracingControllerESt14default_deleteIS4_EE

With CreateDefaultPlatform it works just fine, and there was no other 
changes to sources except of using v8 6.5.116 and using NewDefaultPlatform. 
Bare 6.5.116 with CreateDefaultPlatform works fine.


On Saturday, December 30, 2017 at 7:28:25 PM UTC+2, Ben Noordhuis wrote:
>
> On Sat, Dec 30, 2017 at 5:54 PM, Bogdan Padalko  > wrote: 
> > Hi! 
> > 
> > I'm trying to adapt changes from 
> > https://github.com/v8/v8/commit/ffee558e14e28fc8b1f9a3c10ea3615e0d686c7b 
> to 
> > replace CreateDefaultPlatform with NewDefaultPlatform calls, however, 
> for 
> > some reason I'm getting 
> > 
> > /home/vagrant/php-v8/scripts/test_v8/hello_world.cpp:21: undefined 
> reference 
> > to `v8::platform::NewDefaultPlatform(int, v8::platform::IdleTaskSupport, 
> > v8::platform::InProcessStackDumping, 
> std::unique_ptr > std::default_delete >)' 
> > 
> > error with the following code: 
> > 
> > #include  
> > #include  
> > 
> > #include  
> > #include  
> > 
> > using namespace v8; 
> > 
> > void weak_callback(const 
> v8::WeakCallbackInfo& 
> > data) { 
> >   printf("Weak callback called\n"); 
> >   data.GetParameter()->Reset(); 
> > } 
> > 
> > int main(int argc, char* argv[]) { 
> >   // Initialize V8. 
> >   v8::V8::InitializeICU(); 
> > //  v8::Platform *platform = v8::platform::CreateDefaultPlatform(); 
> > //  v8::V8::InitializePlatform(platform); 
> > 
> >   std::unique_ptr platform = 
> > v8::platform::NewDefaultPlatform(); 
> >   v8::V8::InitializePlatform(platform.get()); 
> > 
> >   V8::Initialize(); 
> > 
> >   v8::Isolate::CreateParams create_params; 
> >   create_params.array_buffer_allocator = 
> > v8::ArrayBuffer::Allocator::NewDefaultAllocator(); 
> > 
> >   // Create a new Isolate and make it the current one. 
> >   Isolate* isolate = v8::Isolate::New(create_params); 
> > 
> >   v8::Persistent test; 
> > 
> >   { 
> > Isolate::Scope isolate_scope(isolate); 
> > 
> > // Create a stack-allocated handle scope. 
> > HandleScope handle_scope(isolate); 
> > 
> > // Create a new context. 
> > Local context = Context::New(isolate); 
> > 
> > // Enter the context for compiling and running the hello world 
> script. 
> > Context::Scope context_scope(context); 
> > 
> > 
> > test.Reset(isolate, String::NewFromUtf8(isolate, "Hello' + ', 
> > World!'")); 
> > test.SetWeak(, weak_callback, 
> v8::WeakCallbackType::kParameter); 
> > 
> > 
> > // Create a string containing the JavaScript source code. 
> > Local source = String::NewFromUtf8(isolate, "(2+2*2) + ' ' + 
> > 'Hello' + ', World!'"); 
> > 
> > // Compile the source code. 
> > 

Re: [v8-users] Undefined reference to v8::platform::NewDefaultPlatform

2017-12-30 Thread Ben Noordhuis
On Sat, Dec 30, 2017 at 5:54 PM, Bogdan Padalko  wrote:
> Hi!
>
> I'm trying to adapt changes from
> https://github.com/v8/v8/commit/ffee558e14e28fc8b1f9a3c10ea3615e0d686c7b to
> replace CreateDefaultPlatform with NewDefaultPlatform calls, however, for
> some reason I'm getting
>
> /home/vagrant/php-v8/scripts/test_v8/hello_world.cpp:21: undefined reference
> to `v8::platform::NewDefaultPlatform(int, v8::platform::IdleTaskSupport,
> v8::platform::InProcessStackDumping, std::unique_ptr std::default_delete >)'
>
> error with the following code:
>
> #include 
> #include 
>
> #include 
> #include 
>
> using namespace v8;
>
> void weak_callback(const v8::WeakCallbackInfo&
> data) {
>   printf("Weak callback called\n");
>   data.GetParameter()->Reset();
> }
>
> int main(int argc, char* argv[]) {
>   // Initialize V8.
>   v8::V8::InitializeICU();
> //  v8::Platform *platform = v8::platform::CreateDefaultPlatform();
> //  v8::V8::InitializePlatform(platform);
>
>   std::unique_ptr platform =
> v8::platform::NewDefaultPlatform();
>   v8::V8::InitializePlatform(platform.get());
>
>   V8::Initialize();
>
>   v8::Isolate::CreateParams create_params;
>   create_params.array_buffer_allocator =
> v8::ArrayBuffer::Allocator::NewDefaultAllocator();
>
>   // Create a new Isolate and make it the current one.
>   Isolate* isolate = v8::Isolate::New(create_params);
>
>   v8::Persistent test;
>
>   {
> Isolate::Scope isolate_scope(isolate);
>
> // Create a stack-allocated handle scope.
> HandleScope handle_scope(isolate);
>
> // Create a new context.
> Local context = Context::New(isolate);
>
> // Enter the context for compiling and running the hello world script.
> Context::Scope context_scope(context);
>
>
> test.Reset(isolate, String::NewFromUtf8(isolate, "Hello' + ',
> World!'"));
> test.SetWeak(, weak_callback, v8::WeakCallbackType::kParameter);
>
>
> // Create a string containing the JavaScript source code.
> Local source = String::NewFromUtf8(isolate, "(2+2*2) + ' ' +
> 'Hello' + ', World!'");
>
> // Compile the source code.
> 

[v8-users] Undefined reference to v8::platform::NewDefaultPlatform

2017-12-30 Thread Bogdan Padalko
Hi! 

I'm trying to adapt changes from 
https://github.com/v8/v8/commit/ffee558e14e28fc8b1f9a3c10ea3615e0d686c7b to 
replace CreateDefaultPlatform with NewDefaultPlatform calls, however, for 
some reason I'm getting

/home/vagrant/php-v8/scripts/test_v8/hello_world.cpp:21: undefined 
reference to `v8::platform::NewDefaultPlatform(int, 
v8::platform::IdleTaskSupport, v8::platform::InProcessStackDumping, 
std::unique_ptr)'

error with the following code:

#include 
#include 

#include 
#include 

using namespace v8;

void weak_callback(const v8::WeakCallbackInfo& 
data) {
  printf("Weak callback called\n");
  data.GetParameter()->Reset();
}

int main(int argc, char* argv[]) {
  // Initialize V8.
  v8::V8::InitializeICU();
//  v8::Platform *platform = v8::platform::CreateDefaultPlatform();
//  v8::V8::InitializePlatform(platform);

  std::unique_ptr platform = v8::platform::NewDefaultPlatform
();
  v8::V8::InitializePlatform(platform.get());

  V8::Initialize();

  v8::Isolate::CreateParams create_params;
  create_params.array_buffer_allocator = v8::ArrayBuffer::Allocator::
NewDefaultAllocator();

  // Create a new Isolate and make it the current one.
  Isolate* isolate = v8::Isolate::New(create_params);

  v8::Persistent test;

  {
Isolate::Scope isolate_scope(isolate);

// Create a stack-allocated handle scope.
HandleScope handle_scope(isolate);

// Create a new context.
Local context = Context::New(isolate);

// Enter the context for compiling and running the hello world script.
Context::Scope context_scope(context);


test.Reset(isolate, String::NewFromUtf8(isolate, "Hello' + ', World!'"
));
test.SetWeak(, weak_callback, v8::WeakCallbackType::kParameter);


// Create a string containing the JavaScript source code.
Local source = String::NewFromUtf8(isolate, "(2+2*2) + ' ' + 
'Hello' + ', World!'");

// Compile the source code.