Q:

Error linking libxxx.so in Native Client (NaCl)

I am struggling to link libIrrlicht.so file with my example source files.
Here is my makefile
PROJECT:=testirrlicht
LDFLAGS:=-lppapi_gles2 -lppapi_cpp -Iinclude -lppapi libs/libIrrlicht.so
CXX_SOURCES:=testirrlicht.cc
 
THIS_MAKEFILE:=$(abspath $(lastword $(MAKEFILE_LIST)))
NACL_SDK_ROOT?=$(abspath $(dir $(THIS_MAKEFILE))../..)
 
CXXFLAGS:=-pthread -g -Wall -Werror -I./include -D_IRR_STATIC_LIB_ -fabi-version=1
 
OSNAME:=win
TC_PATH:=$(abspath $(NACL_SDK_ROOT)/toolchain/$(OSNAME)_x86_newlib)
CXX:=$(TC_PATH)/bin/i686-nacl-g++
 
CYGWIN ?= nodosfilewarning
export CYGWIN
 
all: $(PROJECT)_x86_32.nexe $(PROJECT)_x86_64.nexe
 
# Define 32 bit compile and link rules for C++ sources
x86_32_OBJS:=$(patsubst %.cc,%_32.o,$(CXX_SOURCES))
$(x86_32_OBJS) : %_32.o : %.cc $(THIS_MAKE)
        $(CXX) -o $@ -c $< -m32 -O0 -g $(CXXFLAGS)
 
$(PROJECT)_x86_32.nexe : $(x86_32_OBJS)
        $(CXX) -o $@ $^ -m32 -O0 -g $(CXXFLAGS) $(LDFLAGS)
 
# Define 64 bit compile and link rules for C++ sources
x86_64_OBJS:=$(patsubst %.cc,%_64.o,$(CXX_SOURCES))
$(x86_64_OBJS) : %_64.o : %.cc $(THIS_MAKE)
        $(CXX) -o $@ -c $< -m64 -O0 -g $(CXXFLAGS)
 
$(PROJECT)_x86_64.nexe : $(x86_64_OBJS)
        $(CXX) -o $@ $^ -m64 -O0 -g $(CXXFLAGS) $(LDFLAGS)
 
 
# Define a phony rule so it always runs, to build nexe and start up server.
.PHONY: RUN 
RUN: all
        python ../httpd.py

Here is my compilation error:
$ make
/cygdrive/d/naclsdk/pepper_18/toolchain/win_x86_newlib/bin/i686-nacl-g++ -o testirrlicht_x86_3.nexe testirrlicht_32.o -m32 -O0 -g -pthread -g -Wall -Werror -I./include -D_IRR_STATIC_LIB_ -abi-version=1 -lppapi_gles2 -lppapi_cpp -Iinclude -lppapi libs/libIrrlicht.so
/x86_64-nacl-ld: warning: libstdc++.so.6, needed by libs/libIrrlicht.so, not found (try using rpath or -rpath-link)
/x86_64-nacl-ld: warning: libm.so.3c8d1f2e, needed by libs/libIrrlicht.so, not found (try usin -rpath or -rpath-link)
/x86_64-nacl-ld: warning: libgcc_s.so.1, needed by libs/libIrrlicht.so, not found (try using -path or -rpath-link)
/x86_64-nacl-ld: warning: libpthread.so.3c8d1f2e, needed by libs/libIrrlicht.so, not found (tr using -rpath or -rpath-link)
/x86_64-nacl-ld: warning: libc.so.3c8d1f2e, needed by libs/libIrrlicht.so, not found (try usin -rpath or -rpath-link)
libs/libIrrlicht.so: undefined reference to `wcscpy@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `glAttachShader'
libs/libIrrlicht.so: undefined reference to `operator new[](unsigned int)@GLIBCXX_3.4'
libs/libIrrlicht.so: undefined reference to `glEnable'
libs/libIrrlicht.so: undefined reference to `glBindAttribLocation'
libs/libIrrlicht.so: undefined reference to `glHint'
libs/libIrrlicht.so: undefined reference to `glLineWidth'
libs/libIrrlicht.so: undefined reference to `wcslen@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `asin@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `glIsEnabled'
libs/libIrrlicht.so: undefined reference to `glGetShaderiv'
libs/libIrrlicht.so: undefined reference to `memset@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `glFrontFace'
libs/libIrrlicht.so: undefined reference to `glGetActiveUniform'
libs/libIrrlicht.so: undefined reference to `glBindRenderbuffer'
libs/libIrrlicht.so: undefined reference to `glDisable'
libs/libIrrlicht.so: undefined reference to `operator delete(void*)@GLIBCXX_3.4'
libs/libIrrlicht.so: undefined reference to `glTexParameterf'
libs/libIrrlicht.so: undefined reference to `glClear'
libs/libIrrlicht.so: undefined reference to `gmtime@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `glFramebufferTexture2D'
libs/libIrrlicht.so: undefined reference to `__cxa_guard_release@CXXABI_1.3'
libs/libIrrlicht.so: undefined reference to `strncpy@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `swprintf@GLIBC_2.2'
libs/libIrrlicht.so: undefined reference to `glGetError'
libs/libIrrlicht.so: undefined reference to `glUniform4iv'
libs/libIrrlicht.so: undefined reference to `mbstowcs@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `strtod@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `glStencilFunc'
libs/libIrrlicht.so: undefined reference to `eglInitialize'
libs/libIrrlicht.so: undefined reference to `fmod@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `glStencilMask'
libs/libIrrlicht.so: undefined reference to `glGetAttachedShaders'
libs/libIrrlicht.so: undefined reference to `sscanf@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `glDisableVertexAttribArray'
libs/libIrrlicht.so: undefined reference to `glDeleteProgram'
libs/libIrrlicht.so: undefined reference to `glGenRenderbuffers'
libs/libIrrlicht.so: undefined reference to `__cxa_guard_acquire@CXXABI_1.3'
libs/libIrrlicht.so: undefined reference to `glUniformMatrix4fv'
libs/libIrrlicht.so: undefined reference to `glUseProgram'
libs/libIrrlicht.so: undefined reference to `glClearColor'
libs/libIrrlicht.so: undefined reference to `glUniformMatrix3fv'
libs/libIrrlicht.so: undefined reference to `strcmp@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `glUniform1iv'
libs/libIrrlicht.so: undefined reference to `sin@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `longjmp@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `eglCreateContext'
libs/libIrrlicht.so: undefined reference to `localtime@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `ftell@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `sinf@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `eglMakeCurrent'
libs/libIrrlicht.so: undefined reference to `glDeleteBuffers'
libs/libIrrlicht.so: undefined reference to `glReadPixels'
libs/libIrrlicht.so: undefined reference to `glDeleteShader'
libs/libIrrlicht.so: undefined reference to `_setjmp@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `eglQueryString'
libs/libIrrlicht.so: undefined reference to `glCheckFramebufferStatus'
libs/libIrrlicht.so: undefined reference to `strtoul@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `puts@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `glEnableVertexAttribArray'
libs/libIrrlicht.so: undefined reference to `glGenFramebuffers'
libs/libIrrlicht.so: undefined reference to `glActiveTexture'
libs/libIrrlicht.so: undefined reference to `glBufferData'
libs/libIrrlicht.so: undefined reference to `acosf@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `atol@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `glColorMask'
libs/libIrrlicht.so: undefined reference to `ferror@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `eglSwapBuffers'
libs/libIrrlicht.so: undefined reference to `floorf@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `glBlendFunc'
libs/libIrrlicht.so: undefined reference to `glDetachShader'
libs/libIrrlicht.so: undefined reference to `tan@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `glGetProgramInfoLog'
libs/libIrrlicht.so: undefined reference to `acos@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `glCopyTexSubImage2D'
libs/libIrrlicht.so: undefined reference to `fwrite@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `getenv@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `fseek@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `glBindTexture'
libs/libIrrlicht.so: undefined reference to `glRenderbufferStorage'
libs/libIrrlicht.so: undefined reference to `fputc@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `glGetProgramiv'
libs/libIrrlicht.so: undefined reference to `glDepthMask'
libs/libIrrlicht.so: undefined reference to `malloc@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `glStencilOp'
libs/libIrrlicht.so: undefined reference to `strstr@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `cosf@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `printf@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `glCreateShader'
libs/libIrrlicht.so: undefined reference to `glDeleteTextures'
libs/libIrrlicht.so: undefined reference to `strncmp@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `glGenerateMipmap'
libs/libIrrlicht.so: undefined reference to `glBlendEquation'
libs/libIrrlicht.so: undefined reference to `glBufferSubData'
libs/libIrrlicht.so: undefined reference to `glCullFace'
libs/libIrrlicht.so: undefined reference to `glCreateProgram'
libs/libIrrlicht.so: undefined reference to `fflush@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `fread@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `stderr@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `memcpy@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `glPixelStorei'
libs/libIrrlicht.so: undefined reference to `glGetIntegerv'
libs/libIrrlicht.so: undefined reference to `strlen@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `glGenBuffers'
libs/libIrrlicht.so: undefined reference to `operator delete[](void*)@GLIBCXX_3.4'
libs/libIrrlicht.so: undefined reference to `__errno_location@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `atan2f@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `atan2@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `glDrawElements'
libs/libIrrlicht.so: undefined reference to `glDeleteFramebuffers'
libs/libIrrlicht.so: undefined reference to `glFramebufferRenderbuffer'
libs/libIrrlicht.so: undefined reference to `cos@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `eglSwapInterval'
libs/libIrrlicht.so: undefined reference to `glUniformMatrix2fv'
libs/libIrrlicht.so: undefined reference to `glTexImage2D'
libs/libIrrlicht.so: undefined reference to `eglGetError'
libs/libIrrlicht.so: undefined reference to `pow@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `glUniform2iv'
libs/libIrrlicht.so: undefined reference to `glDepthFunc'
libs/libIrrlicht.so: undefined reference to `memcmp@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `fopen@GLIBC_2.1'
libs/libIrrlicht.so: undefined reference to `glDrawArrays'
libs/libIrrlicht.so: undefined reference to `fmodf@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `glDeleteRenderbuffers'
libs/libIrrlicht.so: undefined reference to `glClearDepthf'
libs/libIrrlicht.so: undefined reference to `glScissor'
libs/libIrrlicht.so: undefined reference to `time@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `fprintf@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `atof@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `glTexSubImage2D'
libs/libIrrlicht.so: undefined reference to `powf@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `glVertexAttribPointer'
libs/libIrrlicht.so: undefined reference to `atoi@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `glGetBooleanv'
libs/libIrrlicht.so: undefined reference to `strcpy@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `wcscmp@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `memmove@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `glGetString'
libs/libIrrlicht.so: undefined reference to `glBindBuffer'
libs/libIrrlicht.so: undefined reference to `__assert_fail@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `glPolygonOffset'
libs/libIrrlicht.so: undefined reference to `glBindFramebuffer'
libs/libIrrlicht.so: undefined reference to `glLinkProgram'
libs/libIrrlicht.so: undefined reference to `glUniform3iv'
libs/libIrrlicht.so: undefined reference to `abort@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `glUniform1fv'
libs/libIrrlicht.so: undefined reference to `glGetShaderInfoLog'
libs/libIrrlicht.so: undefined reference to `__cxa_pure_virtual@CXXABI_1.3'
libs/libIrrlicht.so: undefined reference to `sprintf@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `glUniform2fv'
libs/libIrrlicht.so: undefined reference to `glShaderSource'
libs/libIrrlicht.so: undefined reference to `__cxa_atexit@GLIBC_2.1.3'
libs/libIrrlicht.so: undefined reference to `exit@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `snprintf@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `eglBindAPI'
libs/libIrrlicht.so: undefined reference to `operator new(unsigned int)@GLIBCXX_3.4'
libs/libIrrlicht.so: undefined reference to `glViewport'
libs/libIrrlicht.so: undefined reference to `glUniform3fv'
libs/libIrrlicht.so: undefined reference to `gettimeofday@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `glUniform4fv'
libs/libIrrlicht.so: undefined reference to `eglGetDisplay'
libs/libIrrlicht.so: undefined reference to `eglTerminate'
libs/libIrrlicht.so: undefined reference to `glGetUniformLocation'
libs/libIrrlicht.so: undefined reference to `glTexParameteri'
libs/libIrrlicht.so: undefined reference to `eglCreateWindowSurface'
libs/libIrrlicht.so: undefined reference to `free@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `logf@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `setlocale@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `fclose@GLIBC_2.1'
libs/libIrrlicht.so: undefined reference to `sqrtf@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `glGenTextures'
libs/libIrrlicht.so: undefined reference to `glCompileShader'
libs/libIrrlicht.so: undefined reference to `ceilf@GLIBC_2.0'
libs/libIrrlicht.so: undefined reference to `eglChooseConfig'
libs/libIrrlicht.so: undefined reference to `sqrt@GLIBC_2.0'
collect2: ld returned 1 exit status
Makefile:58: recipe for target `testirrlicht_x86_32.nexe' failed
make: *** [testirrlicht_x86_32.nexe] Error 1

A:

Fixed the problem.
I built library in glibc and the sample application using newlib. Now, I changed both to glibc and partially fixed some problem.
$ make
/cygdrive/d/naclsdk/pepper_18/toolchain/win_x86_glibc/bin/i686-nacl-gcc -o testirrlicht_x86_32.nexe testirrlicht_32.o -m32 -O0 -g -Wall -Iinclude -lpthread -lppapi_cpp -lppapi -lstdc++ -lgcc -lppapi_gles2 libs/libIrrlicht.so
/libexec/../lib/gcc/x86_64-nacl/4.4.3/../../../../x86_64-nacl/lib/../lib32/libppapi_cpp.so: warning: warning: pthread_cancel is not implemented and will always fail
libs/libIrrlicht.so: undefined reference to `eglCreateWindowSurface'
libs/libIrrlicht.so: undefined reference to `eglBindAPI'
libs/libIrrlicht.so: undefined reference to `eglCreateContext'
libs/libIrrlicht.so: undefined reference to `eglMakeCurrent'
libs/libIrrlicht.so: undefined reference to `eglGetDisplay'
libs/libIrrlicht.so: undefined reference to `eglChooseConfig'
libs/libIrrlicht.so: undefined reference to `eglInitialize'
libs/libIrrlicht.so: undefined reference to `eglQueryString'
/libexec/../lib/gcc/x86_64-nacl/4.4.3/../../../../x86_64-nacl/lib/../lib32/libppapi_cpp.so: undefined reference to `pp::CreateModule()'
libs/libIrrlicht.so: undefined reference to `eglSwapInterval'
libs/libIrrlicht.so: undefined reference to `eglSwapBuffers'
libs/libIrrlicht.so: undefined reference to `eglGetError'
libs/libIrrlicht.so: undefined reference to `eglTerminate'
collect2: ld returned 1 exit status
Makefile:58: recipe for target `testirrlicht_x86_32.nexe' failed
make: *** [testirrlicht_x86_32.nexe] Error 1

