构建libvncserver对__gnu_mcount_nc的未定义引用

时间:2014-03-27 09:29:19

标签: android android-ndk undefined-reference vnc-server

我正在尝试将LIBVNCSERVER构建为共享库而不是可执行文件。 构建libVNCSERVER的make文件是

include $(CLEAR_VARS)
LOCAL_PATH := $(INITIAL_PATH)
#for vnc
LIBVNCSERVER_ROOT:=./LibVNCServer-0.9.9
LIBVNCSERVER_SRC_FILES:= \
$(LIBVNCSERVER_ROOT)/libvncserver/main.c \
$(LIBVNCSERVER_ROOT)/libvncserver/rfbserver.c \
$(LIBVNCSERVER_ROOT)/libvncserver/rfbregion.c \
$(LIBVNCSERVER_ROOT)/libvncserver/auth.c \
$(LIBVNCSERVER_ROOT)/libvncserver/sockets.c \
$(LIBVNCSERVER_ROOT)/libvncserver/stats.c \
$(LIBVNCSERVER_ROOT)/libvncserver/corre.c \
$(LIBVNCSERVER_ROOT)/libvncserver/hextile.c \
$(LIBVNCSERVER_ROOT)/libvncserver/rre.c \
$(LIBVNCSERVER_ROOT)/libvncserver/translate.c \
$(LIBVNCSERVER_ROOT)/libvncserver/cutpaste.c \
$(LIBVNCSERVER_ROOT)/libvncserver/httpd.c \
$(LIBVNCSERVER_ROOT)/libvncserver/cursor.c \
$(LIBVNCSERVER_ROOT)/libvncserver/font.c \
$(LIBVNCSERVER_ROOT)/libvncserver/draw.c \
$(LIBVNCSERVER_ROOT)/libvncserver/selbox.c \
$(LIBVNCSERVER_ROOT)/libvncserver/cargs.c \
$(LIBVNCSERVER_ROOT)/libvncserver/ultra.c \
$(LIBVNCSERVER_ROOT)/libvncserver/scale.c \
$(LIBVNCSERVER_ROOT)/libvncserver/zlib.c \
$(LIBVNCSERVER_ROOT)/libvncserver/zrle.c \
$(LIBVNCSERVER_ROOT)/libvncserver/zrleoutstream.c \
$(LIBVNCSERVER_ROOT)/libvncserver/zrlepalettehelper.c \
$(LIBVNCSERVER_ROOT)/common/d3des.c \
$(LIBVNCSERVER_ROOT)/common/vncauth.c \
$(LIBVNCSERVER_ROOT)/common/minilzo.c \
$(LIBVNCSERVER_ROOT)/common/zywrletemplate.c

LOCAL_CFLAGS  +=  -Wall \
                                -O3 \
                                -DLIBVNCSERVER_HAVE_ZLIB
LOCAL_C_INCLUDES += \
                                    $(LOCAL_PATH) \
                                    $(LOCAL_PATH)/$(LIBVNCSERVER_ROOT)/libvncserver \
                                    $(LOCAL_PATH)/$(LIBVNCSERVER_ROOT)/common \
                                    $(LOCAL_PATH)/$(LIBVNCSERVER_ROOT)/rfb \
                                    $(LOCAL_PATH)/$(LIBVNCSERVER_ROOT)/

LOCAL_MODULE    := myvnc
#for profiling
LOCAL_CFLAGS := -pg
#LOCAL_STATIC_LIBRARIES += android-ndk-profiler
LOCAL_ARM_MODE := arm  # remove this if you want thumb mode
LOCAL_SRC_FILES := $(LIBVNCSERVER_SRC_FILES)\
                vncmain.c
LOCAL_LDLIBS += -llog -lz -ldl -lpthread
LOCAL_ARM_NEON := true 
LOCAL_SHARED_LIBRARIES := libz
include $(BUILD_SHARED_LIBRARY)

我从__gnu_mcount_nc文件获得socket.c未定义的引用。

Compile arm    : myvnc <= main.c
Compile arm    : myvnc <= rfbserver.c
Compile arm    : myvnc <= rfbregion.c
Compile arm    : myvnc <= auth.c
Compile arm    : myvnc <= sockets.c
Compile arm    : myvnc <= stats.c
Compile arm    : myvnc <= corre.c
Compile arm    : myvnc <= hextile.c
Compile arm    : myvnc <= rre.c
Compile arm    : myvnc <= translate.c
Compile arm    : myvnc <= cutpaste.c
Compile arm    : myvnc <= httpd.c
Compile arm    : myvnc <= cursor.c
Compile arm    : myvnc <= font.c
Compile arm    : myvnc <= draw.c
Compile arm    : myvnc <= selbox.c
Compile arm    : myvnc <= cargs.c
Compile arm    : myvnc <= ultra.c
Compile arm    : myvnc <= scale.c
Compile arm    : myvnc <= zlib.c
Compile arm    : myvnc <= zrle.c
Compile arm    : myvnc <= zrleoutstream.c
Compile arm    : myvnc <= vncauth.c
Compile arm    : myvnc <= vncmain.c
SharedLibrary  : libmyvnc.so
D:/Android/tool_set/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi-v7a/objs/myvnc/./LibVNCServer-0.9.9/libvncserver/sockets.o: in function rfbShutdownSockets:jni/./LibVNCServer-0.9.9/libvncserver/sockets.c:219: error: undefined reference to '__gnu_mcount_nc'
D:/Android/tool_set/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi-v7a/objs/myvnc/./LibVNCServer-0.9.9/libvncserver/sockets.o: in function rfbDisconnectUDPSock:jni/./LibVNCServer-0.9.9/libvncserver/sockets.c:456: error: undefined reference to '__gnu_mcount_nc'
D:/Android/tool_set/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi-v7a/objs/myvnc/./LibVNCServer-0.9.9/libvncserver/sockets.o: in function rfbCloseClient:jni/./LibVNCServer-0.9.9/libvncserver/sockets.c:464: error: undefined reference to '__gnu_mcount_nc'
D:/Android/tool_set/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi-v7a/objs/myvnc/./LibVNCServer-0.9.9/libvncserver/sockets.o: in function rfbReadExactTimeout:jni/./LibVNCServer-0.9.9/libvncserver/sockets.c:544: error: undefined reference to '__gnu_mcount_nc'
collect2: ld returned 1 exit status
make: *** [obj/local/armeabi-v7a/libmyvnc.so] Error 1

请帮助

1 个答案:

答案 0 :(得分:0)

从CFLAGS中删除-pg,您不需要它来构建库,并且使用它生成的代码将比所需的稍慢。

如果您确实需要分析代码,则需要自己实现__gnu_mcount_nc。有关详细信息,请参阅

http://doc.ironwoodlabs.com/arm-arm-none-eabi/html/getting-started/arm-mcount.html   https://code.google.com/p/android-ndk-profiler/wiki/HowItWorks