我刚刚在UBUNTU 14 SO中安装了CodeBlocks IDE并创建了一个新项目。在尝试编译我的程序时,即使没有语法错误,终端中的消息也是03-16 16:14:14.600 25668-25668/com.example.mytestapp I/MainActivity: onCreateOptionsMenu()
03-16 16:40:40.770 25668-25668/com.example.mytestapp E/MainActivity: onPause()
java.lang.RuntimeException
at com.example.mytestapp.MainActivity.onPause(MainActivity.java:97)
at android.app.Activity.performPause(Activity.java:6225)
at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1321)
at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3510)
at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3483)
at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:3453)
at android.app.ActivityThread.access$1400(ActivityThread.java:163)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1386)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5595)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
03-16 16:40:40.810 25668-25668/com.example.mytestapp I/MainActivity: onResume()
03-16 17:10:41.560 25668-25668/com.example.mytestapp E/MainActivity: onPause()
java.lang.RuntimeException
at com.example.mytestapp.MainActivity.onPause(MainActivity.java:97)
at android.app.Activity.performPause(Activity.java:6225)
at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1321)
at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3510)
at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3483)
at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:3453)
at android.app.ActivityThread.access$1400(ActivityThread.java:163)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1386)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5595)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
03-16 17:10:41.590 25668-25668/com.example.mytestapp I/MainActivity: onResume()
03-16 17:40:42.360 25668-25668/com.example.mytestapp E/MainActivity: onPause()
java.lang.RuntimeException
at com.example.mytestapp.MainActivity.onPause(MainActivity.java:97)
at android.app.Activity.performPause(Activity.java:6225)
at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1321)
at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3510)
at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3483)
at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:3453)
at android.app.ActivityThread.access$1400(ActivityThread.java:163)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1386)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5595)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
03-16 17:40:42.390 25668-25668/com.example.mytestapp I/MainActivity: onResume()
我使用CodeBlocks上的运行按钮来编译它。是否有可能以这种方式编译程序,或者我应该在终端中编写一些代码来编译它?我该怎么编译呢?
答案 0 :(得分:0)
首先尝试使用gcc通过终端进行编译,如果它是基本程序则更简单。 打开终端ctrl + alt + t 运行
gcc myfile.c -o NameOfOutput
gcc -o NameOfOutput myfile.c
然后运行程序:
./ NameOfOutput
让我们通过终端
测试这个程序#include <stdio.h>
int main (void){
printf("Hello Terminal\n");
return 0;
}
注意cd命令允许您从目录移动到所需的目录。 编辑: 我个人会使用netbeans,因为从我对unix系统的观点来看它更加简单。请注意,这里需要java for netbeans是通过终端安装Java的命令
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer