第一篇:APUE編譯錯誤小結(jié)(寫寫幫整理)
linux下《UNIX環(huán)境高級編程》(apue2)源碼編譯出錯的處理方法相信很多跟我一樣想要學(xué)習(xí)unix編程的朋友在興沖沖拿到《unix環(huán)境高級編程》后,準備拿源碼練練手時,執(zhí)行第一個myls就出現(xiàn)一大堆的錯誤,這未免時個不小的打擊。今天把解決方法寫下來,第一自己有個記錄,第二也幫助那些被同樣問題困擾的朋友盡快的進入linux美麗的世界。(只限linux系統(tǒng))
首先需要make一次源代碼
編輯源碼解壓生成的apue.2e文件夾下的Make.defines.linux 修改WKDIR=/home/var/apue.2e為你的apue.2e目錄,比如我的apue源碼解壓在/home/lc,那我就改為:
WKDIR=/home/lc/apue.2e 然后進入apue.2e/std 目錄,編輯linux.mk。修改里面所有的nawk為awk。最后返回apue.2e目錄,執(zhí)行make命令: 在我的機器上編譯時,提示ARG_MAX未定義,可以這么修改。在apue.2e/include/apue.h中添加一行:
#define ARG_MAX 4096 打開apue.2e/threadtl/getenv1.c 和apue.2e/threadctl/getenv3.c,添加一行: #include “apue.h” 這樣就可以編譯通過了,復(fù)制apue.2e/include/apue.h到/usr/include下,apue.2e/lib/libapue.a 到/usr/lib/和 /usr/lib64下。
以下是編譯源碼時的錯誤提示跟解決方法(假定你的工作目錄跟我的一樣,為/usr/local/apue.2e)錯誤提示1:
myls.c:1:19: apue.h: No such file or directory myls.c: In function `main': myls.c:13: error: `NULL' undeclared(first use in this function)myls.c:13: error:(Each undeclared identifier is reported only once myls.c:13: error: for each function it appears in.)解決辦法:
拷貝apue.h到系統(tǒng)默認頭文件目錄中
$cp /usr/local/apue.2e/include/apue.h /usr/include 錯誤提示2:
/tmp/ccBBopm0.o(.text+0x2b): In function `main': : undefined reference to `err_quit' /tmp/ccBBopm0.o(.text+0x5f): In function `main': : undefined reference to `err_sys' collect2: ld returned 1 exit status 解決辦法:
err_quit跟err_sys是作者自己定義的錯誤處理函數(shù),需要單獨定義頭文件 在/usr/include 下新建一個名為myerr.h的文件
拷貝下邊的內(nèi)容到myerr.h(其實此頭文件在原書的附錄B中)#include “apue.h” #include
va_list ap;
va_start(ap, fmt);
err_doit(1, errno, fmt, ap);
va_end(ap);} /* * Fatal error related to a system call.* Print a message and terminate.*/ void err_sys(const char *fmt,...){
va_list ap;
va_start(ap, fmt);
err_doit(1, errno, fmt, ap);
va_end(ap);
exit(1);} /* * Fatal error unrelated to a system call.* Error code passed as explict parameter.* Print a message and terminate.*/ void err_exit(int error, const char *fmt,...){
va_list ap;
va_start(ap, fmt);
err_doit(1, error, fmt, ap);
va_end(ap);
exit(1);} /* * Fatal error related to a system call.* Print a message, dump core, and terminate.*/ void err_dump(const char *fmt,...){
va_list ap;
va_start(ap, fmt);
err_doit(1, errno, fmt, ap);
va_end(ap);
abort();/* dump core and terminate */
exit(1);/* shouldn't get here */ } /* * Nonfatal error unrelated to a system call.* Print a message and return.*/ void err_msg(const char *fmt,...){
va_list ap;
va_start(ap, fmt);
err_doit(0, 0, fmt, ap);
va_end(ap);} /* * Fatal error unrelated to a system call.* Print a message and terminate.*/ void err_quit(const char *fmt,...){
va_list ap;
va_start(ap, fmt);
err_doit(0, 0, fmt, ap);
va_end(ap);
exit(1);} /* * Print a message and return to caller.* Caller specifies “errnoflag”.*/ static void err_doit(int errnoflag, int error, const char *fmt, va_list ap){
char buf[MAXLINE];vsnprintf(buf, MAXLINE, fmt, ap);if(errnoflag)
snprintf(buf+strlen(buf), MAXLINE-strlen(buf), “: %s”,strerror(error));strcat(buf, “ ”);fflush(stdout);/* in case stdout and stderr are the same */ fputs(buf, stderr);fflush(NULL);/* flushes all stdio output streams */ } 然后在你需要使用這幾種錯誤處理函數(shù)的程序源代碼里加入: #include “myerr.h”
至此,APUE就可以順利編譯啦
第二篇:Android4.0編譯錯誤記錄
1.make: ***
[out/host/linux-x86/obj/STATIC_LIBRARIES/libMesa_intermediates/src/glsl/linker.o] Error 1 解決方法: vim external/mesa3d/src/glsl/linker.cpp
添加:
#include
2.make: ***
[out/host/linux-x86/obj/EXECUTABLES/test-librsloader_intermediates/test-librsloader] Error 1 解決辦法:
vim external/llvm/llvm-host-build.mk
添加:
LOCAL_LDLIBS :=-lpthread-ldl
3.make: ***
[out/host/linux-x86/obj/STATIC_LIBRARIES/libgtest_host_intermediates/gtest-all.o] Error 1 解決方法:
vim external/gtest/include/gtest/internal/gtest-param-util.h
添加:
#include
4.
第三篇:BUSYBOX編譯錯誤及解決方法總結(jié)
編譯busybox的組合:
busybox-1.0.0 arm-linux-gcc-2.95.3(AT91rm9200開發(fā)板)
經(jīng)典參考:
http://busybox.net/downloads/ 下載busybox http://husaberg.toby-churchill.com/balloon/releases/v0.7/roots/ 文件系統(tǒng)制作
移植基本過程:
1.到http://busybox.net/downloads/busybox-1.7.3.tar.bz2下載busybox;2.解壓busybox1.7.3 tar jxvf busybox-1.7.3.tar.bz2 3.make defconfig 4.make menuconfig
在[build options]中選擇[Build busybox as a static binary] 主要是C庫的連接方式,安裝目錄等。5.make 6.創(chuàng)建rootfs目錄 7.make install
編譯過程可能出現(xiàn)以下錯誤,解決方法如下:
可能會出現(xiàn)的錯誤:
1.出現(xiàn)如下錯誤
CC miscutils/taskset.o miscutils/taskset.c:17: error: parse error before '*' token miscutils/taskset.c:18: warning: function declaration isn't a prototype miscutils/taskset.c: In function `__from_cpuset':
miscutils/taskset.c:22: error: `CPU_SETSIZE' undeclared(first use in this function)
miscutils/taskset.c:22: error:(Each undeclared identifier is reported only once miscutils/taskset.c:22: error: for each function it appears in.)miscutils/taskset.c:26: warning: implicit declaration of function `CPU_ISSET' miscutils/taskset.c:26: error: `mask' undeclared(first use in this function)miscutils/taskset.c: In function `taskset_main': miscutils/taskset.c:47: error: `cpu_set_t' undeclared(first use in this function)
miscutils/taskset.c:47: error: parse error before “mask” miscutils/taskset.c:68: warning: implicit declaration of function `CPU_ZERO' miscutils/taskset.c:68: error: `new_mask' undeclared(first use in this function)
miscutils/taskset.c:69: error: `CPU_SETSIZE' undeclared(first use in this function)miscutils/taskset.c:71: warning: implicit declaration of function `CPU_SET'
miscutils/taskset.c:78: error: `mask' undeclared(first use in this function)
make[1]: *** [miscutils/taskset.o] Error 1
make: *** [miscutils] Error 2
make menuconfig 找到[Miscellaneous Utilities],去掉[task set]
2.如下錯誤:
time.c libbb/time.c:20: error: “CLOCK_MONOTONIC” undeclared(first use in this function)make menuconfig
去掉Busybox Settings->Busybox Library Tuning->[]Use clock_gettie(CLOCK_MONOTONIC)syscall
3.出現(xiàn)如下錯誤:
In file included from /usr/local/arm/2.95.3/lib/gcc-lib/arm-linux/2.95.3/../../../../arm-linux/sys-include/linux/fs.h:12,from /usr/local/arm/2.95.3/lib/gcc-lib/arm-linux/2.95.3/../../../../arm-linux/sys-include/linux/capability.h:17,from /usr/local/arm/2.95.3/lib/gcc-lib/arm-linux/2.95.3/../../../../arm-linux/sys-include/linux/binfmts.h:5,from /usr/local/arm/2.95.3/lib/gcc-lib/arm-linux/2.95.3/../../../../arm-linux/sys-include/linux/sched.h:9,from /usr/local/arm/2.95.3/lib/gcc-lib/arm-linux/2.95.3/../../../../arm-linux/sys-include/net/inetpeer.h:14,from /usr/local/arm/2.95.3/lib/gcc-lib/arm-linux/2.95.3/../../../../arm-linux/sys-include/net/route.h:28,from /busybox-1.01/networking/route.c:42: /usr/local/arm/2.95.3/lib/gcc-lib/arm-linux/2.95.3/../../../../arm-linux/sys-include/linux/wait.h:4: warning: `WNOHANG' redefined /usr/local/arm/2.95.3/lib/gcc-lib/arm-linux/2.95.3/../../../../arm-linux/include/bits/waitflags.h:26: warning: this is the location of the previous definition /usr/local/arm/2.95.3/lib/gcc-lib/arm-linux/2.95.3/../../../../arm-linux/sys-include/linux/wait.h:5: warning: `WUNTRACED' redefined /usr/local/arm/2.95.3/lib/gcc-lib/arm-linux/2.95.3/../../../../arm-linux/include/bits/waitflags.h:27: warning: this is the location of the previous definition In file included from /usr/local/arm/2.95.3/lib/gcc-lib/arm-linux/2.95.3/../../../../arm-linux/sys-include/linux/sched.h:77,from /usr/local/arm/2.95.3/lib/gcc-lib/arm-linux/2.95.3/../../../../arm-linux/sys-include/net/inetpeer.h:14,from /usr/local/arm/2.95.3/lib/gcc-lib/arm-linux/2.95.3/../../../../arm-linux/sys-include/net/route.h:28,from /busybox-1.01/networking/route.c:42: /usr/local/arm/2.95.3/lib/gcc-lib/arm-linux/2.95.3/../../../../arm-linux/sys-include/linux/time.h:108: warning: `FD_SET' redefined /usr/local/arm/2.95.3/lib/gcc-lib/arm-linux/2.95.3/../../../../arm-linux/include/sys/select.h:83: warning: this is the location of the previous definition /usr/local/arm/2.95.3/lib/gcc-lib/arm-linux/2.95.3/../../../../arm-linux/sys-include/linux/time.h:109: warning: `FD_CLR' redefined /usr/local/arm/2.95.3/lib/gcc-lib/arm-linux/2.95.3/../../../../arm-linux/include/sys/select.h:84: warning: this is the location of the previous definition /usr/local/arm/2.95.3/lib/gcc-lib/arm-linux/2.95.3/../../../../arm-linux/sys-include/linux/time.h:110: warning: `FD_ISSET' redefined /usr/local/arm/2.95.3/lib/gcc-lib/arm-linux/2.95.3/../../../../arm-linux/include/sys/select.h:85: warning: this is the location of the previous definition /usr/local/arm/2.95.3/lib/gcc-lib/arm-linux/2.95.3/../../../../arm-linux/sys-include/linux/time.h:111: warning: `FD_ZERO' redefined /usr/local/arm/2.95.3/lib/gcc-lib/arm-linux/2.95.3/../../../../arm-linux/include/sys/select.h:86: warning: this is the location of the previous definition In file included from /busybox-1.01/networking/route.c:42: /usr/local/arm/2.95.3/lib/gcc-lib/arm-linux/2.95.3/../../../../arm-linux/sys-include/net/route.h:34: warning: #warning This file is not supposed to be used outside of kernel.…… ……
In file included from /usr/local/arm/2.95.3/lib/gcc-lib/arm-linux/2.95.3/../../../../arm-linux/include/netdb.h:38,from /busybox-1.01/include/libbb.h:36,from /busybox-1.01/include/busybox.h:54,from /busybox-1.01/networking/route.c:44: /usr/local/arm/2.95.3/lib/gcc-lib/arm-linux/2.95.3/../../../../arm-linux/include/bits/siginfo.h:34: redefinition of `union sigval' /usr/local/arm/2.95.3/lib/gcc-lib/arm-linux/2.95.3/../../../../arm-linux/include/bits/siginfo.h:37: warning: redefinition of `sigval_t' /usr/local/arm/2.95.3/lib/gcc-lib/arm-linux/2.95.3/../../../../arm-linux/sys-include/asm/siginfo.h:11: warning: `sigval_t' previously declared here /usr/local/arm/2.95.3/lib/gcc-lib/arm-linux/2.95.3/../../../../arm-linux/include/bits/siginfo.h:274: redefinition of `struct sigevent' /usr/local/arm/2.95.3/lib/gcc-lib/arm-linux/2.95.3/../../../../arm-linux/include/bits/siginfo.h:289: warning: redefinition of `sigevent_t' /usr/local/arm/2.95.3/lib/gcc-lib/arm-linux/2.95.3/../../../../arm-linux/sys-include/asm/siginfo.h:211: warning: `sigevent_t' previously declared here /usr/local/arm/2.95.3/lib/gcc-lib/arm-linux/2.95.3/../../../../arm-linux/include/bits/siginfo.h:298: parse error before `0' In file included from /busybox-1.01/include/busybox.h:54,from /busybox-1.01/networking/route.c:44: /busybox-1.01/include/libbb.h:112: warning: declaration of `flags' shadows global declaration /busybox-1.01/include/libbb.h:113: warning: declaration of `flags' shadows global declaration /busybox-1.01/include/libbb.h:135: warning: declaration of `flags' shadows global declaration /busybox-1.01/include/libbb.h:251: warning: declaration of `flags' shadows global declaration /busybox-1.01/include/libbb.h:256: redefinition of `struct sysinfo' /busybox-1.01/include/libbb.h:272: warning: declaration of `info' shadows global declaration /busybox-1.01/include/libbb.h:309: warning: declaration of `flags' shadows global declaration /busybox-1.01/include/libbb.h:440: warning: declaration of `flags' shadows global declaration /busybox-1.01/networking/route.c:475: warning: declaration of `flags' shadows global declaration /busybox-1.01/networking/route.c: In function `set_flags': /busybox-1.01/networking/route.c:476: warning: declaration of `flags' shadows global declaration /busybox-1.01/networking/route.c: In function `displayroutes': /busybox-1.01/networking/route.c:490: warning: declaration of `flags' shadows global declaration make: *** [/busybox-1.01/networking/route.o] Error 1 去掉Busybox Settings->NetWork device-->[]route
4.如下錯誤:
usr/src/armlinux/busybox-1.0.0/libbb/loop.c:32:linux/version.h:No such file or directory /usr/src/armlinux/busybox-1.0.0/libbb/loop.c:35 arse error /usr/src/armlinux/busybox-1.0.0/libbb/loop.c:37 arse error 將內(nèi)核源碼下的include/linux目錄下的versition.h文件
放到 busybox-1.0.0/include/linux下
.....
第四篇:編譯原理各章小結(jié)
1.編譯程序是一個翻譯程序,將高級語言的源程序翻譯成低級語言的程序。
2.整個編譯過程可以劃分為五個階段以及編譯各階段的任務(wù);另外還有兩個處理過程。
3.不會有很多人會從事設(shè)計和編寫編譯程序的工作的,但編譯技術(shù)會應(yīng)用在很多領(lǐng)域。
1.已知文法G,判斷VN=?,VT=?,判斷某個符號串是否為該文法描述的句子。
2.已知文法G,寫出它定義的語言描述;
3.已知文法G,給出其句子的各種形式的推導(dǎo),會畫出語法樹;
4.文法二義性的判斷——利用語法樹:在文法G中去尋找某一個句子,能夠給它畫出兩個不同的語法樹。
1.詞法分析的任務(wù)。
2.單詞的概念與單詞的分類以及輸出方式。
3.弄懂一些重要的概念:
正規(guī)文法G、正規(guī)式r和確定有限自動機DFA和不確定有限自動機NFA。
4.會畫出FA對應(yīng)的狀態(tài)轉(zhuǎn)換圖。
5.弄懂詞法分析器的自動生成原理:
1.語法分析的任務(wù);
2.確定的自頂向下語法分析方法的基本思想,存在的問題是:左遞歸和回溯;
3.分析方法:預(yù)測分析法。
1.自底向上語法分析方法的基本思想;
2.短語、直接短語和句柄底定義,以及如何利用語法樹來尋找某個句型的所有的短語、直接短語和句柄;
3.自底向上語法分析方法:
①算符優(yōu)先分析法:基本原理,識別句柄的方法,最左素短語。
②LR分析法:活前綴,LR(0)項目,LR(0)分析法,SLR(1)分析法。
語義分析與中間代碼生成的任務(wù)。
弄清屬性文法的概念。
弄清語法制導(dǎo)翻譯的概念。
掌握常用的中間代碼形式:逆波蘭式和四元式。
掌握一般語法成分,如賦值語句,條件語句,循環(huán)語句和簡單說明語句等結(jié)構(gòu)的翻譯。
數(shù)據(jù)空間的內(nèi)容;
數(shù)據(jù)空間的三種分配策略;
臨時變量的存儲分配。
優(yōu)化的分類;
常用的代碼優(yōu)化技術(shù);
局部優(yōu)化。
1.目標代碼的形式 ;
2.目標機的指令系統(tǒng);
3.代碼生成算法。
第五篇:IAR 6 20編譯錯誤
IAR 6.20編譯錯誤清單
1、①錯誤描述:Tool Internal Error:
Internal Error: [CoreUtil/General]: Access violation(0xc0000005)at 007588A5(reading from address 0x0)
Internal Error: [CoreUtil/General]: Access violation(0xc0000005)at 007588A5(reading from address 0x0)
Error while running C/C++ Compiler
②錯誤原因:High配置設(shè)置為Size,應(yīng)該為Low2、①錯誤描述:Fatal Error[Pe1696]: cannot open source file “inc/hw_types.h” E:StellarisWareM3_9D92boardsdk-lm3s9b96boot_demo2boot_demo2.c 25②錯誤原因:C/C++ Complier(Assember)->Preprocessor->Additional include directories: $PROJ_DIR$.$PROJ_DIR$..$PROJ_DIR$......3、①錯誤描述:Fatal Error[Pe1696]: cannot open source file
“l(fā)wip/opt.h”
E:StellarisWareM3_9D92utilslwiplib.h 4
4②錯誤原因:C/C++ Complier-(Assember)>Preprocessor->Additional include directories:
$PROJ_DIR$......third_partylwip-1.3.2apps
$PROJ_DIR$......third_partybget
$PROJ_DIR$......third_partylwip-1.3.2portsstellarisinclude
$PROJ_DIR$......third_partylwip-1.3.2srcinclude
$PROJ_DIR$......third_partylwip-1.3.2srcincludeipv4
$PROJ_DIR$......third_partylwip-1.3.2srcincludelwip
$PROJ_DIR$......third_party4、①錯誤描述:Fatal Error[Pe035]: #error directive: Unrecognized COMPILER!E:StellarisWareM3_9D92boardsdk-lm3s9b96driversset_pinout.h 59
Error while running C/C++ Compiler
②錯誤原因:C/C++ Complier-(Assember)>Preprocessor->Defined symbols: ewarm5、①錯誤描述:Error[Pe020]: identifier “ROM_pvAESTable” is undefined E:StellarisWareM3_9D92third_partyaesaes.c 319
②錯誤原因:
6、①錯誤描述:Error[Li005]: no definition for “main” [referenced from cmain.o(rt7M_tl.a)]Error while running Linker
②錯誤原因:定義函數(shù):int main(void){ return(0);}
7、①錯誤描述:Error[Li005]: no definition for “main” [referenced from cmain.o(rt7M_tl.a)]Error while running Linker
②錯誤原因:如果是庫是庫函數(shù),在:General Options->Output->Output file:選擇: Library項
4、①錯誤描述:Fatal Error[Pe1696]: cannot open source file “uip.h” E:StellarisWareM3_9D92third_partyuip-1.0appsdhcpcdhcpc.c 37
②錯誤原因:
5、①錯誤描述:
②錯誤原因:
$PROJ_DIR$......third_partylwip-1.3.2apps
$PROJ_DIR$......third_partybget
$PROJ_DIR$......third_partylwip-1.3.2portsstellarisinclude
$PROJ_DIR$......third_partylwip-1.3.2srcinclude
$PROJ_DIR$......third_partylwip-1.3.2srcincludeipv
4$PROJ_DIR$......third_party
$PROJ_DIR$......third_partyuip-1.0
$PROJ_DIR$......third_partyuip-1.0uip
$PROJ_DIR$......third_partyuip-1.0apps
$PROJ_DIR$......third_partyspeex-1.2rc1include
$PROJ_DIR$......third_partyspeex-1.2rc1includespeex
$PROJ_DIR$......third_partyspeex-1.2rc1stellaris6、①錯誤描述:Fatal Error[Pe035]: #error directive: You now need to define either FIXED_POINT or FLOATING_POINT E:StellarisWareM3_9D92third_partyspeex-1.2rc1libspeexarch.h 65②錯誤原因:
7、①錯誤描述:Fatal Error[Pe035]: #error directive: “Unrecognized/undefined driver for DISK0!”
E:StellarisWareM3_9D92third_partyfatfsportdual-disk-driver.c 6
2Error while running C/C++ Compiler
②錯誤原因:
UART_BUFFERED
DISK0_DK_LM3S9B96
DISK1_USB_MSC
INCLUDE_BGET_STATS8、①錯誤描述:Error[Pe020]: identifier “ROM_pvAESTable” is undefined E:SWM3_9D92(6.20)third_partyaesaes.c 359
Error while running C/C++ Compiler
②錯誤原因:
10、①錯誤描述:Fatal Error[Pe035]: #error directive: You now need to define either FIXED_POINT or FLOATING_POINT E:SWM3_9D92(6.20)third_partyspeex-1.2rc1libspeexarch.h 6
5Error while running C/C++ Compiler
②錯誤原因:
11、①錯誤描述:
Error[Li005]: no definition for “ROM_SysCtlClockSet” [referenced from E:SWM3_9D92(6.20)boardsdk-lm3s9b96safertos_demoDebugObjsafertos_demo.o] Error[Li005]: no definition for “ROM_FlashUserGet” [referenced from E:SWM3_9D92(6.20)boardsdk-lm3s9b96safertos_demoDebugObjlwip_task.o]
Error[Li005]: no definition for “ROM_IntPrioritySet” [referenced from E:SWM3_9D92(6.20)boardsdk-lm3s9b96safertos_demoDebugObjlwip_task.o]
Error[Li005]: no definition for “ROM_GPIOPinTypeGPIOOutput” [referenced from E:SWM3_9D92(6.20)boardsdk-lm3s9b96safertos_demoDebugObjled_task.o]
Error[Li005]: no definition for “ROM_GPIOPinWrite” [referenced from E:SWM3_9D92(6.20)boardsdk-lm3s9b96safertos_demoDebugObjled_task.o]
Error[Lp011]: section placement failed: unable to allocate space for sections/blocks with a total estimated minimum size of 0x11e54 bytes
in
<[0x20000000-0x2000ffff]>(total uncommitted space 0x10000).Error while running Linker
②錯誤原因:
12、①錯誤描述:
Error[Lp011]: section placement failed: unable to allocate space for sections/blocks with a total estimated minimum size of 0x11e54 bytes in <[0x20000000-0x2000ffff]>(total uncommitted space 0x10000).Error while running Linker