編譯環節出現問題
1. Quartus II編譯時出現錯誤
第一條是沒有找到所需要的初始化文件或者已經編譯生成的hex文件,如果有其他編譯軟體的話,請在編譯時,生成hex文件前打鉤
第二條也許是always的敏感變數出現問題,沒有給出程序一時無法解決
一共兩條錯誤,後面的是warning,可以不予理睬
2. 編譯caffe出現問題
在程序開發的過程中,調試是一個不可缺少的重要環節。「三分編程七分調試」,說明程序調試的工作量要比編程大得多。C程序的錯誤可以分為兩種:語法錯誤和邏輯錯誤
(1)語法錯誤,這是C語言初學者出現最多的錯誤,比如,分號「;」是每個C語句的結束的標志,在C語句後忘記寫「;」就是語法錯誤,發生語法錯誤的程序,編譯通不過,用戶可以軟體的提示信息來修改。
(2)邏輯錯誤 就是用戶編寫的程序已經沒有語法錯誤,可以運行,但得不到所期望的結果(或正確的結果),也就是說由於程序設計者原因程序並沒有按照程序設計者的思路來運行。比如一個最簡單例子是:我的目的是求兩個數的和的,應該寫成 z=x+y; 由於某種原因卻寫成了 z=x-y; 這就是邏輯錯誤。
發生邏輯錯誤的程序編譯軟體是發現不了,要用戶跟蹤程序的運行過程才能發現程序中邏輯錯誤,這是最不容易修改的。比如軟體的BUG就是邏輯錯誤,發行補丁程序就是修改邏輯錯誤(用戶最常見就是Windows操作系統經常發布補丁程序)
3. linux 編譯內核幾個常見問題解決方法
第一次把自己編譯的驅動模塊載入進開發板,就出現問題,還好沒花費多長時間,下面列舉出現的問題及解決方案
1:出現insmod: error inserting 'hello.ko': -1 Invalid mole format
法一(網上的):是因為內核模塊生成的環境與運行的環境不一致,用linux-2.6.27內核源代碼生成的模塊,可能就不能在linux-2.6.32.2內核的linux環境下載入,需要在linux-2.6.27內核的linux環境下載入。
a.執行 uname -r //查看內核版本
b.一般出錯信息被記錄在文件/var/log/messages中,執行下面命令看錯誤信息
# cat /var/log/messages |tail
若出現類似下面:
Jun 4 22:07:54 localhost kernel:hello: version magic '2.6.35.6-45.fc14.i686.PAE
' should be '2.6.35.13-92.fc14.i686.PAE'
則把 Makefile里的KDIR :=/lib/moles/2.6.35.6-45.fc14.i686.PAE/build1 改為
KDIR :=/lib/moles/2.6.35.13-92.fc14.i686.PAE/build1 //改成自己內核源碼路徑
(這里的build1是一個文件鏈接,鏈接到/usr/src/kernels/2.6.35.6-45.fc14.i686.PAE和13-92的)
然並卵,我的fedora 14 /usr/src/kernels下並沒有2.6.35.13-92.fc14.i686.PAE,只有2.6.35.13-92.fc14.i686,雖然不知道兩者有什麼區別,但改成2.6.35.13-92.fc14.i686還是不行,照樣這個問題,還好後來在看教學視頻的到啟發
法二:改的還是那個位置
KDIR :=/opt/FriendlyARM/linux-2.6.32.2 //把這里改成你編譯生成kernel的那個路徑
all:
$ (MAKE) -C $ (KDIR) M = $ (PWD) moles ARCH=arm CROSS_COMPILE=arm-linux- //加這句
2. [70685.298483] hello: mole license 'unspecified' taints kernel.
[70685.298673] Disabling lock debugging e to kernel taint
方法:在模塊程序中加入: MODULE_LICENSE("GPL");
3. rmmod: chdir(2.6.32.2-FriendlyARM): No such file or directory 錯誤解決
方法:lsmod 可查看模塊信息
即無法刪除對應的模塊。
就是必須在/lib/moles下建立錯誤提示的對應的目錄((2.6.32.2)即可。
必須創建/lib/moles/2.6.32.2這樣一個空目錄,否則不能卸載ko模塊.
# rmmod nls_cp936
rmmod: chdir(/lib/moles): No such file or directory
但是這樣倒是可以卸載nls_cp936,不過會一直有這樣一個提示:
rmmod: mole 'nls_cp936' not found
初步發現,原來這是編譯kernel時使用make moles_install生成的一個目錄,
但是經測試得知,rmmod: mole 'nls_cp936' not found來自於busybox,並不是來自kernel
1).創建/lib/moles/2.6.32.2空目錄
2).使用如下源碼生成rmmod命令,就可以沒有任何提示的卸載ko模塊了[luther.gliethttp]
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
int main(int argc, char *argv[])
{
const char *modname = argv[1];
int ret = -1;
int maxtry = 10;
while (maxtry-- > 0) {
ret = delete_mole(modname, O_NONBLOCK | O_EXCL);//系統調用sys_delete_mole
if (ret < 0 && errno == EAGAIN)
usleep(500000);
else
break;
}
if (ret != 0)
printf("Unable to unload driver mole \"%s\": %s\n",
modname, strerror(errno));
}
3).把生成的命令復制到文件系統
# arm-linux-gcc -static -o rmmod rmmod.c
# arm-linux-strip -s rmmod
# cp rmmod /nfs/
cp /nfs/rmmod /sbin
代碼如下:
proc.c
[html] view plain
<span style="font-size:18px;">#include <linux/mole.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/proc_fs.h> /* Necessary because we use the proc fs */
#define procfs_name "proctest"
MODULE_LICENSE("GPL");
struct proc_dir_entry *Our_Proc_File;
int procfile_read(char *buffer,char **buffer_location,off_t offset, int buffer_length, int *eof, void *data)
{ int ret;
ret = sprintf(buffer, "HelloWorld!\n");
return ret;
}
int proc_init()
{ Our_Proc_File = create_proc_entry(procfs_name, 0644, NULL);
if (Our_Proc_File == NULL) {
remove_proc_entry(procfs_name, NULL);
printk(KERN_ALERT "Error: Could not initialize /proc/%s\n",procfs_name);
return -ENOMEM; }
Our_Proc_File->read_proc = procfile_read;//
// Our_Proc_File->owner = THIS_MODULE;
Our_Proc_File->mode = S_IFREG | S_IRUGO;
Our_Proc_File->uid = 0;
Our_Proc_File->gid = 0;
Our_Proc_File->size = 37;
printk("/proc/%s created\n", procfs_name);
return 0;
}
void proc_exit()
{ remove_proc_entry(procfs_name, NULL);
printk(KERN_INFO "/proc/%s removed\n", procfs_name);
}
mole_init(proc_init);
mole_exit(proc_exit);</span></span></span></span></span>
[html] view plain
<span style="font-size:18px;">
ifneq ($(KERNELRELEASE),)
obj-m :=proc.o
else
KDIR :=/opt/FriendlyARM/linux-2.6.32.2
#KDIR :=/lib/moles/2.6.35.13-92.fc14.i686.PAE/build1
PWD :=$(shell pwd)
all:
$(MAKE) -C $(KDIR) M=$(PWD) moles ARCH=arm CROSS_COMPILE=arm-linux-
clean:
rm -f *.ko *.o *.mod.o *.mod.c *.symvers
endif</span></span></span></span></span>
make後生成proc.ko,再在開發板上insmod proc.ko即可
執行 dmesg 就可以看到 產生的內核信息啦
4. 編譯內核時出現這種問題是什麼情況
、若編譯內核時總是出現同一個錯誤,如下:
在make moles_install時最後幾行彈出錯誤:
if [ -r System.map -a -x /sbin/depmod ]; then /sbin/depmod -ae -F System.map 2.6.12.2; fi
/bin/sh: line 1: 3357 已殺死 /sbin/depmod -ae -F System.map 2.6 .12.2
make: *** [_modinst_post] 錯誤 137
如果繼續make install,重啟,是進不去剛剛編譯安裝的那個內核的,顯示內核錯誤。
分析:如果 System.map可讀 並且 /sbin/depmod可執行;那麼就執行/sbin/depmod -ae -F System.map 2.6.20;結束
depmod(depend mole)
功能說明:分析可載入模塊的相依性。
語 法:depmod [-adeisvV][-m <文件>][--help][模塊名稱]
補充說明:depmod可檢測模塊的相依性,供modprobe在安裝模塊時使用。
參 數:
-a或--all 分析所有可用的模塊。
-d或debug 執行排錯模式。
-e 輸出無法參照的符號。
-i 不檢查符號表的版本。
-m<文件>或system-map<文件> 使用指定的符號表文件。
5. 關於C語言在編譯時常出現的錯誤有哪些
1、fatal error C1010: unexpected end of file while looking for precompiled header directive。
尋找預編譯頭文件路徑時遇到了不該遇到的文件尾。(一般是沒有#include "stdafx.h")
2、fatal error C1083: Cannot open include file: 'R…….h': No such file or directory
不能打開包含文件「R…….h」:沒有這樣的文件或目錄。
3、error C2011: 'C……': 'class' type redefinition
類「C……」重定義。
4、error C2018: unknown character '0xa3'
不認識的字元'0xa3'。(一般是漢字或中文標點符號)
5、error C2057: expected constant expression
希望是常量表達式。(一般出現在switch語句的case分支中)
6、error C2065: 'IDD_MYDIALOG' : undeclared identifier
「IDD_MYDIALOG」:未聲明過的標識符。
7、error C2082: redefinition of formal parameter 'bReset'
函數參數「bReset」在函數體中重定義。
8、error C2143: syntax error: missing ':' before '{'
句法錯誤:「{」前缺少「;」。
9、error C2146: syntax error : missing ';' before identifier 'dc'
句法錯誤:在「dc」前丟了「;」。
10、error C2196: case value '69' already used
值69已經用過。(一般出現在switch語句的case分支中)
11、error C2509: 'OnTimer' : member function not declared in 'CHelloView'
成員函數「OnTimer」沒有在「CHelloView」中聲明。
12、error C2511: 'reset': overloaded member function 'void (int)' not found in 'B'
重載的函數「void reset(int)」在類「B」中找不到。
13、error C2555: 'B::f1': overriding virtual function differs from 'A::f1' only by return type or calling convention
類B對類A中同名函數f1的重載僅根據返回值或調用約定上的區別。
14、error C2660: 'SetTimer' : function does not take 2 parameters
「SetTimer」函數不傳遞2個參數。
15、warning C4035: 'f……': no return value
「f……」的return語句沒有返回值。
16、warning C4553: '= =' : operator has no effect; did you intend '='?
沒有效果的運算符「= =」;是否改為「=」?
17、warning C4700: local variable 'bReset' used without having been initialized
局部變數「bReset」沒有初始化就使用。
18、error C4716: 'CMyApp::InitInstance' : must return a value
「CMyApp::InitInstance」函數必須返回一個值。
19、LINK : fatal error LNK1168: cannot open Debug/P1.exe for writing
連接錯誤:不能打開P1.exe文件,以改寫內容。(一般是P1.Exe還在運行,未關閉)
20、error LNK2001: unresolved external symbol "public: virtual _ _thiscall C……::~C……(void)"
連接時發現沒有實現的外部符號(變數、函數等)。
function call missing argument list 調用函數的時候沒有給參數。
member function definition looks like a ctor, but name does not match enclosing class 成員函數聲明了但沒有使用
unexpected end of file while looking for precompiled header directive 在尋找預編譯頭文件時文件意外結束,編譯不正常終止可能造成這種情況