undefined reference to `log' 问题解决

尝试gcc 编译出现问题。
如:gcc -o lz77 main.o lz77.o tree.o bitio.o
bitio.o: In function `bitof':
bitio.c:(.text+0xd): undefined reference to `log'
bitio.c:(.text+0x1a): undefined reference to `ceil'
collect2: error: ld returned 1 exit status
Makefile:13: recipe for target 'lz77' failed
make: *** [lz77] Error 1
调整修改为 g++后问题消除

I am trying to compile the implementation of the RFC 3797 random selection algorithm by Donald Eastlake (code: http://kambing.ui.ac.id/minix/other/rfc3797/). However, I am getting a linker error:

rfc3797.c:(.text+0xe7f): undefined reference to `log'

I am trying to make it with the provided Makefile, which explicitly links against the math libraray, but I still get the error:

cc -lm -o randomselection rfc3797.c MD5.c

How can I compile this program?


以上是我编译时出现的问题,在stack overflow 上同样有人问:

我在makefile 调整编译器问题解决。

发布了3 篇原创文章 · 获赞 8 · 访问量 2万+
展开阅读全文

arm-linux-androideabi-gcc 交叉编译报错

07-21

对Linux下的一个开源代码进行交叉编译,准备移植到Android平台上。但是一直报错。 编辑脚本如下: export NDKROOT="/home/bupt/android-ndk-r9d" export PREBUILT=$NDKROOT/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64 export SYSROOT=$NDKROOT/platforms/android-18/arch-arm export CC=$PREBUILT/bin/arm-linux-androideabi-gcc export LD=$PREBUILT/bin/arm-linux-androideabi-ld export AS=$PREBUILT/bin/arm-linux-androideabi-gcc export AR=$PREBUILT/bin/arm-linux-androideabi-ar export RANLIB=$PREBUILT/bin/arm-linux-androideabi-ranlib export STRIP=$PREBUILT/bin/arm-linux-androideabi-strip CFLAGS="--sysroot=$NDKROOT/platforms/android-18/arch-arm -fPIC -DX264_VERSION -DANDROID -DHAVE_PTHREAD -D__ARM_ARCH_7__ -D__ARM_ARCH_7A__ -march=armv7-a -fomit-frame-pointer -mfloat-abi=softfp -mfpu=neon -I$TOOLCHAINS_INCLUDE -I$NDKROOT/platforms/android-18/arch-arm/usr/include" export CFLAGS LDFLAGS="-Wl,-T,$PREBUILT/arm-linux-androideabi/lib/ldscripts/armelf_linux_eabi.x -Wl,-rpath-link=$NDKROOT/platforms/android-18/arch-arm/usr/lib -L$NDKROOT/platforms/android-18/arch-arm/usr/lib -nostdlib -lc -lm -ldl -lgcc" export LDFLAGS ./configure --prefix=/home/bupt/clamav/clamav-0.98.4/clamav-android --host=arm-linux-androideabi --with-openssl=/usr/lib config.log报错如下: configure:3820: /home/bupt/android-ndk-r9d/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -V >&5 arm-linux-androideabi-gcc: error: unrecognized option '-V' arm-linux-androideabi-gcc: fatal error: no input files compilation terminated. configure:3831: $? = 1 configure:3820: /home/bupt/android-ndk-r9d/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -qversion >&5 arm-linux-androideabi-gcc: error: unrecognized option '-qversion' arm-linux-androideabi-gcc: fatal error: no input files compilation terminated. ================================== home/bupt/android-ndk-r9d/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/include-fixed/limits.h:169:61: error: no include path in which to search for limits.h configure:4461: $? = 1 但是在这个文件夹下可以找到这个.h文件。 conftest.c:13:0: fatal error: assert.h: No such file or directory compilation terminated. 其他报错信息都是以上这种找不到头文件等。 =========================== 命令行报错为: configure: ****** mempool support disabled (mmap not available or not usable) checking for ld used by GCC... /home/bupt/android-ndk-r9d/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld checking if the linker (/home/bupt/android-ndk-r9d/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld) is GNU ld... yes checking for shared library run path origin... done checking check.h usability... no checking check.h presence... no checking for check.h... no configure: unable to compile/link with check checking for libxml2 installation... not found configure: ****** libxml2 support unavailable checking for OpenSSL installation... configure: error: OpenSSL not found. 求解决方案!!!!!!!!!!!!!! 问答

NDK开发的时候遇到error: undefined reference to 错误

04-25

大家好,我在正在将C++的一些代码通过ndk调用到android项目里面去,但是在出现了一个很奇怪的错误; /bin/ld: ./obj/local/armeabi/objs/TestNDK2/TestNDK2.o: in function Java_com_example_testndk2_MainActivity_stringTestNdk(_JNIEnv*, _jobject*):jni/TestNDK2.cpp:15: error: undefined reference to 'CFeatureExtract::CFeatureExtract()' collect2: ld returned 1 exit status make: *** [obj/local/armeabi/libTestNDK2.so] Error 1 我调用jni的文件代码为: #include <string.h> #include "FeatureExtract.h" #include "Output.h" #include <jni.h> jstring Java_com_example_testndk2_MainActivity_stringTestNdk( JNIEnv* env, jobject thiz ) { COutput * pout; pout = new COutput(); CFeatureExtract *pFtr; pFtr=new CFeatureExtract(); return (env)->NewStringUTF("Hello from JNI and anbo !"); } mk文件也编写好了,应该没什么问题,之所以说没问题是因为,我在上面调用了其他cpp文件的 output.cpp和FeatureExtract.cpp等好几个cpp文件,当我把 pFtr=new CFeatureExtract(); 这行去掉的时候,会发现不再报错。下面是我的mk的代码: LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := libFeatureExtract LOCAL_SRC_FILES := OnlineFtr.cpp OnlineNorm.cpp FeatureExtract.cpp LOCAL_C_INCLUDES := $(LOCAL_PATH)/include include $(BUILD_STATIC_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE := libOutput LOCAL_SRC_FILES := LQDFR.cpp Classifier.cpp Output.cpp include $(BUILD_STATIC_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE := TestNDK2 LOCAL_SRC_FILES := TestNDK2.cpp LOCAL_STATIC_LIBRARIES := libFeatureExtract LOCAL_STATIC_LIBRARIES := libOutput include $(BUILD_SHARED_LIBRARY) 最后是我CFeatureExtract构造函数的代码: CFeatureExtract::CFeatureExtract() { nmdir = 0; nwid = zone*zstep; pNorm = new COnlineNorm; pFeatr = new COnlineFtr( nwid ); //edit by anbo trajnorm = NULL; new_ptnum =0; new_ptnum_total=0; strokeEnd=0; strokeBegin=0; countStroke=0; GaussModel_probability =0; } 下面是.h头文件的部分声明 class CFeatureExtract{ public: CFeatureExtract(); ~CFeatureExtract(); 非常想知道到底哪里错了啊!感谢! 问答

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览