QT编译遇到的初级问题整理 gnu-libstdc++\4.9\include\cstdlib:72: error: stdlib.h: No such file or directory

问题使用QT编译Android项目时总是提示头文件编译错误,类似下面

G:\androidsdk\android-ndk-r10d\sources\cxx-stl\gnu-libstdc++\4.9\include\cstdlib:72: error: stdlib.h: No such file or directory

 #include <stdlib.h>

 

G:\androidsdk\android-ndk64-r10-windows-x86_64\android-ndk-r10\sources\cxx-stl\gnu-libstdc++\4.9\include/cwchar:44:19: fatal error: wchar.h: No such file or directory

 #include <wchar.h>

                   ^

compilation terminated.

makefile:1080: recipe for target 'xxx.obj' failed

 

解决方案:                   ^

 

来自一个国外网友的解决方案:

https://forum.qt.io/topic/43803/solved-qt-android-cstdlib-error-stdlib-h-no-such-file-or-directory

以下是解决答案:

Solved.

解决方案:It appeared I had a 64-bit NDK installed even though I thought I had downloaded a 32-bit NDK.

I blew away all NDK remnants and downloaded new 32-bit r10 NDK and now my Android x86 emulator is launching my Qt hello world app.

android-ndk32-r10-darwin-x86.tar.bz2

意思是要统一使用32位的NDKQT Creator.

解决方案:我的解决方案也是这样,我的机器是64位,我NDK安装了64位,但是QTCreator32位,这样就会有问题,把NDK重新下载一个32位的就OK

 

 

问题2.  -1: error: No rule to make target 

'G:\androidsdk\android-ndk-r10d\sources\cxx-stl\gnu-libstdc++\4.9\include\utility', needed by 'main.obj'.  Stop.

解决方案:删除就得编译配置目录,重新生成就ok了,这个问题是因为问题1的临时文件存在导致的编译错误,解决了问题1,删除工程编译文件重新编译就ok了。

 

 

问题3编译错误

Error: Target id 'android--1' is not valid. Use 'android.bat list targets' to get the target ids

Error while building/deploying project  XXX(kit: Android for armeabi-v7a (GCC 4.9, Qt 5.4.1))

When executing step "Build Android APK"

 

-output D:/qt5/qml/qtquickbook/build-touchEvent-Android_for_armeabi_v7a_GCC_4_8_Qt_5_4_1-Release/android-build --deployment bundled --android-platform android--1 --jdk "D:/Program Files/Java/jdk1.7.0_45" --ant D:/qt5/apache-ant-1.9.4/bin/ant.bat

Error: Target id 'android--1' is not valid. Use 'android.bat list targets' to get the target ids.

Generating Android Package

  Input file: D:/qt5/qml/qtquickbook/build-touchEvent-Android_for_armeabi_v7a_GCC_4_8_Qt_5_4_1-Release/android-libtouchEvent.so-deployment-settings.json

  Output directory: D:/qt5/qml/qtquickbook/build-touchEvent-Android_for_armeabi_v7a_GCC_4_8_Qt_5_4_1-Release/android-build/

  Application binary: D:/qt5/qml/qtquickbook/build-touchEvent-Android_for_armeabi_v7a_GCC_4_8_Qt_5_4_1-Release/libtouchEvent.so

  Android build platform: android--1

  Install to device: No

Buildfile: build.xml does not exist!

Build failed

Warning: Android platform 'android--1' does not exist in SDK.

Building the android package failed!

  -- For more information, run this command with --verbose.

 

When executing step "Build Android APK"

Error while building/deploying project cube (kit: Android for armeabi-v7a (GCC 4.9, Qt 5.4.1))

When executing step "Deploy to Android device"

 

解决方案:需要设置Build Android APK 里面的 Android Build SDK-Android -XX(选中目标版本)

 

 

           ^

问题4.编译静态库时需要出错, 提示nternal Error: Could not find .pro file.

 Internal Error: Could not find .pro file.

 

20:37:40: Internal Error: Could not find .pro file.

Error while building/deploying project XXX(kit: Android for armeabi-v7a (GCC 4.9, Qt 5.4.1))

When executing step "Build Android APK"

 

解决方案:

unable to build lib

Right, I can reproduce that. Creator's android support is focussed around building applications and packaging them into apks. So building only a library (static or not, doesn't matter), is somewhat out of scope for us. To build a library for a application, we expect the user to create a subdirs project with both a library and a application project.

You can work around this problem, by disabling the unnecessary "make install" and "Build apk" steps on the Project's mode under the build settings.


解决方案:

禁用 Build Android APK 选项,就是下图中的蓝色圆饼+斜杠符号的禁用按钮。

 

 

 

 

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值