天天看點

C語言常見編譯錯誤與執行錯誤

hello: line 1: syntax error: unexpected word (expecting “)”)

編寫fasync_jni應用程式放在Tiny210開發闆上跑會出現如下錯誤:

C語言常見編譯錯誤與執行錯誤

然後編寫一個最簡單的hello world程式放在Tiny210開發闆上跑也會出現類似這樣的錯誤:hello: line 1: syntax error: unexpected word (expecting “)”)

解決辦法:加上-static選項,arm-linux-gcc hello.c –static –o hello

貌似将庫檔案編譯到應用程式裡面之後就能執行。

另外放在哪個目錄去執行也比較重要,最好放在根目錄去執行。

/udisk # ./uevents /system/bin/sh: ./uevents: not found

問題解法同上,編譯的時候加上–static

error: unknown type name ‘uint32_t’

如果在自己的頭檔案中有用到uint32_t,要在這些頭檔案中包含stdint.h

cannot open shared object file: No such file or directory

具體錯誤如下:

./rts5401_ft2: error while loading shared libraries: librtcr.so.1: cannot open shared object file: No such file or directory

也就是運作缺少動态連結庫,在網上查了主要有3種方法:

1、用ln的方法将需要的so檔案連結到/usr/lib或者/lib這兩個預設的目錄下邊

ln -s /where/you/install/lib/*.so /usr/lib

sudo ldconfig

2、修改LD_LIBRARY_PATH

export LD_LIBRARY_PATH=/where/you/install/lib:$LD_LIBRARY_PATH

sudo ldconfig

3、修改/etc/ld.so.conf

vim /etc/ld.so.conf

add [where you install lib]

sudo ldconfig

我采用第3種方法

在/etc/ld.so.conf.d目錄下添加檔案librtcr.conf,檔案librtcr.conf檔案中記錄librtcr連結庫檔案的路徑,添加完了之後使用sudo ldconfig來重新将庫檔案的路徑加到系統路徑下面。

make: * No rule to make target ` ‘, needed by xxx. Stop

基本上都是屬于找不到所依賴的檔案所導緻的,是以應該去檢測確定所依賴的檔案是否真實存在。

很可能,很常見的一個現象就是,此處的,誤寫了多餘的空格,導緻被視為依賴檔案,導緻找不到,導緻報此錯誤。

解決辦法就很簡單,去掉多餘的空格即可。

field has incomplete type

function declaration isn’t a prototype