SDL2 app compiles with pepper_42 vs pepper_43

323 views
Skip to first unread message

BL

unread,
May 14, 2015, 4:36:01 PM5/14/15
to native-cli...@googlegroups.com
Hi,
My test SDL2 app used to compile and work fine with pepper_42. 
Starting pepper_43, to resolve complation errors, I need to change sdl2main.cc interface from PSInstance to pp:Instance
//class SDLInstance: public PSInstance {
class SDLInstance: public pp::Instance {
   ...
}

Since compilation errors are resolved, it still has linking error when I change the libs orders to resolve many other linked errors.
Now I have only one linked error as below:
/naclsdk/pepper_43/lib/pnacl/Release/libppapi_simple.a: error: undefined reference to 'PSUserMainGet'
Any advice to resolve linked error: undefined reference to 'PSUserMainGet' ?

Changes in Makefile:
#LIBS = SDL2 ppapi_simple ppapi_gles2 ppapi_cpp ppapi nacl_io pthread
LIBS = SDL2 ppapi_gles2 ppapi_cpp ppapi ppapi_simple nacl_io pthread

Thanks

Ben Smith

unread,
May 14, 2015, 5:00:58 PM5/14/15
to native-cli...@googlegroups.com
Hi BL,

ppapi_simple was switched to a C library recently. It uses the C entrypoints instead of the C++ entrypoints.

You can use the C++ entrypoints by linking with ppapi_simple_cpp instead of ppapi_simple.

-Ben

BL

unread,
May 14, 2015, 5:38:52 PM5/14/15
to native-cli...@googlegroups.com
Thanks Ben. 
Good to know this.
But I switched to link with ppapi_simple_cpp, I got more linked errors.
#LIBS = SDL2 ppapi_simple ppapi_gles2 ppapi_cpp ppapi nacl_io pthread
LIBS = SDL2 ppapi_simple_cpp ppapi_gles2 ppapi_cpp ppapi nacl_io pthread

Linked errors:
  CXX  pnacl/Release/nacl_main.o
  CC   pnacl/Release/sdl2bench_ps.o
  LINK pnacl/Release/sdl-bench_unstripped.bc
/home/ble/naclsdk/pepper_43/toolchain/linux_pnacl/le32-nacl/lib/libppapi_stub.a: error: undefined reference to 'PPP_GetInterface'
/home/ble/naclsdk/pepper_43/toolchain/linux_pnacl/le32-nacl/lib/libppapi_stub.a: error: undefined reference to 'PPP_ShutdownModule'
/home/ble/naclsdk/pepper_43/toolchain/linux_pnacl/le32-nacl/lib/libppapi_stub.a: error: undefined reference to 'PPP_InitializeModule'
/home/ble/naclsdk/pepper_43/lib/pnacl/Release/libppapi_simple_cpp.a: error: undefined reference to 'PSUserMainGet'
make: *** [pnacl/Release/sdl-bench_unstripped.bc] Error 1

With ppapi_simple:
#LIBS = SDL2 ppapi_gles2 ppapi_cpp ppapi ppapi_simple nacl_io pthread
I got only:
  CXX  pnacl/Release/nacl_main.o
  CC   pnacl/Release/sdl2bench_ps.o
  LINK pnacl/Release/sdl-bench_unstripped.bc
/home/ble/naclsdk/pepper_43/lib/pnacl/Release/libppapi_simple.a: error: undefined reference to 'PSUserMainGet'
make: *** [pnacl/Release/sdl-bench_unstripped.bc] Error 1

Am I missing something ?
Thanks

Sam Clegg

unread,
May 15, 2015, 8:36:32 PM5/15/15
to native-cli...@googlegroups.com
This looks like a library ordering issue.

Can you try adding "-Wl,-uPSUserMainGet" to your LDFLAGS? This will
ensure that this symbol is found in libSDL2. Alternatively I believe
you could using --start-goup/--end-group around all the libraries.

cheers,
sam
> --
> You received this message because you are subscribed to the Google Groups
> "Native-Client-Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to native-client-di...@googlegroups.com.
> To post to this group, send email to native-cli...@googlegroups.com.
> Visit this group at http://groups.google.com/group/native-client-discuss.
> For more options, visit https://groups.google.com/d/optout.
Message has been deleted

BL

unread,
Aug 15, 2015, 6:41:37 PM8/15/15
to Native-Client-Discuss
Hi Sam,
I built SDL2 libs and migrating to pepper_45, 
nacl cc class is switched from using PSInstance to pp:Instance to link with ppapi_simple_cpp,
LIBS = SDL2maim SDL2 ppapi_simple_cpp ppapi_gles2 ppapi_cpp ppapi jsoncpp pthread nacl_io

The app now is built. After loading, it jumps directly to SDL_main() fine,

but now Javascript messages failed to communicate with nacl cc module. Seems like the pp:Instance
class, constructor, Init, DidChangeView, HandleMessage,...,are no longer valid. 
How could javascripts interface with nacl cc module in this case ?

Thanks

Sam Clegg

unread,
Aug 17, 2015, 6:49:00 PM8/17/15
to native-cli...@googlegroups.com
On Sat, Aug 15, 2015 at 3:41 PM, BL <mele...@gmail.com> wrote:
> Hi Sam,
> I built SDL2 libs and migrating to pepper_45,
> nacl cc class is switched from using PSInstance to pp:Instance to link with
> ppapi_simple_cpp,
> LIBS = SDL2maim SDL2 ppapi_simple_cpp ppapi_gles2 ppapi_cpp ppapi jsoncpp
> pthread nacl_io
>
> The app now is built. After loading, it jumps directly to SDL_main() fine,
>
> but now Javascript messages failed to communicate with nacl cc module. Seems
> like the pp:Instance
> class, constructor, Init, DidChangeView, HandleMessage,...,are no longer
> valid.
> How could javascripts interface with nacl cc module in this case ?

SDL_main is called on a background thread by ppapi_simple, the
pp::Instance module is created and owned by libppapi_simple. If you
want to use the PPAPI and you need access to the instance can access
it by using the ppapi_simple API (PSGetInstanceId), but SDL2 apps
should not be implementing DidChangeView or HandleMessage themselves.
These are all handled internally by ppapi_simple on the main thread
and all the SDL code (and your app code) runs on a background thread.

Also, you should be using ppapi_simple, and not ppapi_simple_cpp, and
you don't need ppapi_cpp at all.
>> > email to native-client-di...@googlegroups.com.
>> > To post to this group, send email to native-cli...@googlegroups.com.
>> > Visit this group at
>> > http://groups.google.com/group/native-client-discuss.
>> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Native-Client-Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to native-client-di...@googlegroups.com.

BL

unread,
Aug 18, 2015, 6:10:30 PM8/18/15
to Native-Client-Discuss
Thanks Sam for the info,
With pepper_42, our app currently released on CWS heavily using message commands between javascripts and nacl CC modules.
First we still need to use ppapi_cpp and use json to send command messages from JS via json to CC nacl module (HandleMessage).
We also use PPAPI to handle keyboard/mouse input via (HandleInputEvent) instead of SDL, we only use SDL2 for display graphics.

Now with pepper_43 and up, pp::Instance module is created and owned by libppapi_simple, how could we handle messages between javascripts and nacl module ?

Thanks
>> > To post to this group, send email to native-cli...@googlegroups.com.
>> > Visit this group at
>> > http://groups.google.com/group/native-client-discuss.
>> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Native-Client-Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an

Sam Clegg

unread,
Aug 20, 2015, 1:57:23 PM8/20/15
to native-cli...@googlegroups.com
On Tue, Aug 18, 2015 at 3:10 PM, BL <mele...@gmail.com> wrote:
> Thanks Sam for the info,
> With pepper_42, our app currently released on CWS heavily using message
> commands between javascripts and nacl CC modules.
> First we still need to use ppapi_cpp and use json to send command messages
> from JS via json to CC nacl module (HandleMessage).
> We also use PPAPI to handle keyboard/mouse input via (HandleInputEvent)
> instead of SDL, we only use SDL2 for display graphics.
>
> Now with pepper_43 and up, pp::Instance module is created and owned by
> libppapi_simple, how could we handle messages between javascripts and nacl
> module ?

Take a look at ppapi_simple/ps_event.h and how SDL2 uses this to
process input events:
https://github.com/spurious/SDL-mirror/blob/master/src/video/nacl/SDL_naclevents.c

For messages from JS you can register your handler with
PSEventRegisterMessageHandler if you want to handle them synchronously
on the main thread, or you can modify NACL_PumpEvents to handle them
on the SDL thread.

Input events I would suggest just using SDLs existing event model. If
they are shortcoming there perhaps we can improve the SDL2 code.
Using SDL2 to just do rendering and handrolling the event loop might
be possible but its not really a supported way to use SDL2 and will
likely involve solving a lot of the problems that the SDL2 port
already solved.

cheers,
sam
>> >> > email to native-client-di...@googlegroups.com.
>> >> > To post to this group, send email to native-cli...@googlegroups.com.
>> >> > Visit this group at
>> >> > http://groups.google.com/group/native-client-discuss.
>> >> > For more options, visit https://groups.google.com/d/optout.
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "Native-Client-Discuss" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> > an
>> > email to native-client-di...@googlegroups.com.
>> > To post to this group, send email to native-cli...@googlegroups.com.
>> > Visit this group at
>> > http://groups.google.com/group/native-client-discuss.
>> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Native-Client-Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to native-client-di...@googlegroups.com.

BL

unread,
Aug 25, 2015, 8:21:30 PM8/25/15
to Native-Client-Discuss
Hi Sam,
I built the SDL2 libraries successfully from naclports branch of "pepper_44" github.

Build the teststreaming (using teststreaming.c) under:
/depot_tools/src/out/build/sdl2/sdl2-2.0.3/test/teststreaming.c
Attached the package teststreaming with complte makefile and bin.
Run the test, NaCl module crashed during SDL_CreateRenderer() API. Are you aware of this crash or any fixes lately ?

Thanks
>> >> > To post to this group, send email to native-cli...@googlegroups.com.
>> >> > Visit this group at
>> >> > http://groups.google.com/group/native-client-discuss.
>> >> > For more options, visit https://groups.google.com/d/optout.
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "Native-Client-Discuss" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> > an
>> > To post to this group, send email to native-cli...@googlegroups.com.
>> > Visit this group at
>> > http://groups.google.com/group/native-client-discuss.
>> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Native-Client-Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
nacl-teststreaming.tar.gz

BL

unread,
Sep 30, 2015, 1:48:00 PM9/30/15
to Native-Client-Discuss
Hi Sam,
Just inform you that we found the cause of the crash in the SDL API: SDL_CreateRenderer().
We built teststeaming.c, PNACL toolchain with PEPPER_44 or 45 on naclports "pepper_44" github branch.

The SDL_CreateRendere() crashes due to the codes for NACL is not defined in SDL_render_gles2.c.
Any reason why these codes have not been enabled for building  SDL2 lib ?
Thanks

/naclports/out/build/sdl2/sdl2-2.0.3/src/render/opengles2/SDL_render_gles2.c
Add to GLES2_LoadFunctions(GLES2_DriverContext * data) the case define for SDL_VIDEO_NACL
#elif SDL_VIDEO_DRIVER_NACL
#define __SDL_NOGETPROCADDR__

static int GLES2_LoadFunctions(GLES2_DriverContext * data)
{
#if SDL_VIDEO_DRIVER_UIKIT
#define __SDL_NOGETPROCADDR__
#elif SDL_VIDEO_DRIVER_ANDROID
#define __SDL_NOGETPROCADDR__
#elif SDL_VIDEO_DRIVER_PANDORA
#define __SDL_NOGETPROCADDR__
#elif SDL_VIDEO_DRIVER_NACL
#define __SDL_NOGETPROCADDR__
#endif

#if defined __SDL_NOGETPROCADDR__
#define SDL_PROC(ret,func,params) data->func=func;
#else
#define SDL_PROC(ret,func,params) \
    do { \
        data->func = SDL_GL_GetProcAddress(#func); \
        if ( ! data->func ) { \
            return SDL_SetError("Couldn't load GLES2 function %s: %s\n", #func, SDL_GetError()); \
        } \
    } while ( 0 );
#endif /* _SDL_NOGETPROCADDR_ */

George varghese

unread,
Mar 3, 2016, 5:59:52 AM3/3/16
to Native-Client-Discuss
Hi,

I got the same error , pepper version is 47.

libppapi_simple.a: error: undefined reference to 'PSUserMainGet'

how to resolve it.

Regards,
George 
 

George varghese

unread,
Mar 8, 2016, 11:25:09 PM3/8/16
to Native-Client-Discuss
Hi,

Please note the pepper version is 47.

I modified as LIBS as saie above,
Please see the make file,

DEPS = ppapi_simple_cpp nacl_io
LIBS = SDL2_test SDL2 ppapi_simple SDL2main SDL2 $(DEPS) ppapi_gles2 ppapi_cpp ppapi pthread nacl_io
CFLAGS := -Wall -I$(NACL_SDK_ROOT)/SDL/include/SDL2
SOURCES = sdlgkmediastreamvideo.cc
PNACL_LDFLAGS += -L$(NACL_SDK_ROOT)/SDL/lib -Wl,-uPSUserMainGet


After that I got the below error,

C:\nacl_sdk\pepper_47\toolchain\win_pnacl\bin\le32-nacl-ld.gold.exe: error: C:/nacl_sdk/pepper_47/lib/pnacl/Release/libppapi_simple_cpp.a: multiple definition of 'pp::CreateModule()'
C:\nacl_sdk\pepper_47\toolchain\win_pnacl\bin\le32-nacl-ld.gold.exe: pnacl/Release/sdlgkmediastreamvideo.o: previous definition here
C:/nacl_sdk/pepper_47/lib/pnacl/Release/libppapi_simple.a: error: undefined reference to 'PSUserMainGet'
Makefile:150: recipe for target 'pnacl/Release/GKNewMediaPluginSDL_unstripped.bc' failed
make: *** [pnacl/Release/GKNewMediaPluginSDL_unstripped.bc] Error 1

Then I commented below code in my c file,

namespace pp {

Module* CreateModule() {
  return new GKMediaStreamModule();
}


Again building , I got the below error,

make[1]: Leaving directory 'C:/nacl_sdk/pepper_47/src/nacl_io'
  LINK pnacl/Release/GKNewMediaPluginSDL_unstripped.bc 
C:/nacl_sdk/pepper_47/toolchain/win_pnacl/le32-nacl/lib/libppapi_stub.a: error: undefined reference to 'PPP_InitializeModule'
C:/nacl_sdk/pepper_47/toolchain/win_pnacl/le32-nacl/lib/libppapi_stub.a: error: undefined reference to 'PPP_ShutdownModule'
C:/nacl_sdk/pepper_47/toolchain/win_pnacl/le32-nacl/lib/libppapi_stub.a: error: undefined reference to 'PPP_GetInterface'
make: *** [pnacl/Release/GKNewMediaPluginSDL_unstripped.bc] Error 1
Makefile:150: recipe for target 'pnacl/Release/GKNewMediaPluginSDL_unstripped.bc' failed



If anybody is got the same error, please reply

Regards,
George

dellwyse...@gmail.com

unread,
Mar 10, 2016, 8:07:40 PM3/10/16
to Native-Client-Discuss
Hi George,
I had no problem using SDL2 on pepper_47 or pepper_49.
My makefile below for my app.
LIBS = SDL2main SDL2 ppapi_gles2 ppapi_simple_cpp ppapi_cpp ppapi jsoncpp nacl_io pthread

I believe you must build the libSDL2main and libSDL2 from each webports branch, pepper_47 and pepper_49, respectively.
If I link SDL2 libs built from pepper_47 work pepper_49 it won't work. Hope this helps.
Reply all
Reply to author
Forward
0 new messages