導航:首頁 > 源碼編譯 > linux編譯時報錯303

linux編譯時報錯303

發布時間:2022-12-23 22:38:04

linux下C++編譯報錯

//改完後的程序如下,假如文件名為test.cpp
//編譯時用這個語句 g++ -o test test.cpp
//在我自己的Linux環境試過好用
//另外,樓主可以用man getuid來看幫助
#include <iostream>
#include <unistd.h>
#include <sys/types.h>
using namespace std;

int main() {

cout << getuid() << endl;

return 0;
}
=================
你是什麼linux版本??g++啥版本的?
====================
按我的方法報什麼錯??能把錯再發一下不?
另外,你系統上裝開發包了吧?
最簡單的hello world能編譯正確運行嗎?

❷ 跪求linux大神 ---編譯時報錯

libopen-pal.so.4 估計是你的 LD_LIBRARY_PATH沒有設置,也就是鏈接路徑裡面沒有你這個文件所在的文件夾

export LD_LIBRARY_PATH = $ LD_LIBRARY_PATH:/usr/lib/XXX
來設值

❸ linux下編譯程序源碼,執行make命令時報錯如圖,有沒有什麼頭緒或者建議,謝謝大神了

linux下所有軟體源碼包的安裝方式一般都會在readme中有詳細的官方說明,對於gerbv如下圖所示

上述大部分內容對linux下所有軟體包的安裝都適用。

❹ linux 安裝了gcc後編譯軟體報錯

少組件,運行命令
如果是ubuntu的系統,直接運行sudo apt-get install build-essential libc6-dev
如果是fedora,yum install g++* gcc*
不過你gcc到裝上沒啊
要先弄個redhat9.0能用的yum源,具體你可以搜一下,然後終端輸入命令,(root用戶下)
yum install g++* gcc*

❺ linux下c語言操作MYSQL編譯報錯

#include<mysql/mysql.h>
#include<stdio.h>
#include<stdlib.h>

#define HOST "localhost"
#define USERNAME "用戶名"
#define PASSWORD "密碼"
#define DATABASE "指定的資料庫"
#define SQL_QUERY "SELECT*FROM表名"

intmain(void)
{
MYSQLmysql;
MYSQL_ROWrow;
MYSQL_RES*result;
unsignedintnum_fields;
unsignedinti;

mysql_init(&mysql);
if(!mysql_real_connect(&mysql,HOST,USERNAME,PASSWORD,DATABASE,0,NULL,0))
{
printf("Connectionfailed,%s ",mysql_error(&mysql));
}
mysql_query(&mysql,"setnamesutf8");
if(!mysql_query(&mysql,SQL_QUERY))
{
result=mysql_store_result(&mysql);
if(!result)
{
perror("resulterror.");
exit(1);
}
num_fields=mysql_num_fields(result);
while(row=mysql_fetch_row(result))
{
for(i=0;i<num_fields;i++)
{
printf("%s ",row[i]);
}
printf(" ");
}
mysql_free_result(result);
}
mysql_close(&mysql);
return0;
}

編譯命令:

gcc -o mysql_test mysql_test.c -lmysqlclient

運行命令:

./mysql_test

❻ lpc2103 報錯aeabi_uidiv

解決思路:
1、這個錯誤提示說明是一個未定義引用的錯誤,根據__aeabi_uidivmod,和__aeabi_uidiv猜想應該是除法實現的問題(為什麼就能得出是除法實現的問題?根據英文名嗎?可是我查了下,沒有這個英文。)。
2、這里用到了lib1funcs.S這個除法庫文件,於是在裡面搜索__aeabi_uidiv和__aeabi_uidivmod,找不到這兩個關鍵字的定義。
說明應該是4.3.2版本的編譯工具需要找這兩個關鍵字的定義,但是找不到。
3、猜測應該是這個lib1funcs.S是比較老版本的庫文件,可是這個較新版本的去哪找呢,除法運算在u-boot和Linux內核里肯定實現了,就到這兩個裡面去找這個文件。
4、4.3.2編譯通過的兩個項目版本分別是u-boot-2012.04.01以及linux-3.4.2,就到這兩個項目中找,你會發現u-boot裡面沒有這個文件,u-boot肯定實現了,但是不是用這個來實現的,我們到linux內核里找:
find /work/projects/linux-3.4.2 -name "lib1funcs.S"
搜索結果:

./arch/arm/lib/lib1funcs.S
./arch/arm/boot/compressed/lib1funcs.S
登錄後復制
5、/work/system/linux-3.4.2/arch/arm/lib/lib1funcs.S,這個文件應該就是我們找的庫文件。
把他到項目里,然後make。
編譯結果:

arm-linux-gcc -c -o lib1funcs.o lib1funcs.S
lib1funcs.S:36:27: error: linux/linkage.h: No such file or directory
lib1funcs.S:37:27: error: asm/assembler.h: No such file or directory
lib1funcs.S:38:24: error: asm/unwind.h: No such file or directory
Makefile:11: recipe for target 'lib1funcs.o' failed
make: *** [lib1funcs.o] Error 1
登錄後復制
提示我們找不到這些頭文件,對比以前的lib1funcs.S不需要這些頭文件。
所以我們把頭文件注釋掉:

35 /*
36 #include <linux/linkage.h>
37 #include <asm/assembler.h>
38 #include <asm/unwind.h>
39 */
登錄後復制
6、再次編譯,出現如下錯誤:

arm-linux-gcc -c -o lib1funcs.o lib1funcs.S
lib1funcs.S: Assembler messages:
lib1funcs.S:181: Error: bad instruction `entry(__udivsi3)'
lib1funcs.S:182: Error: bad instruction `entry(__aeabi_uidiv)'
lib1funcs.S:183: Error: bad instruction `unwind(.fnstart)'
lib1funcs.S:207: Error: bad instruction `unwind(.fnend)'
lib1funcs.S:208: Error: bad instruction `endproc(__udivsi3)'
lib1funcs.S:209: Error: bad instruction `endproc(__aeabi_uidiv)'
lib1funcs.S:211: Error: bad instruction `entry(__umodsi3)'
lib1funcs.S:212: Error: bad instruction `unwind(.fnstart)'
lib1funcs.S:226: Error: bad instruction `unwind(.fnend)'
lib1funcs.S:227: Error: bad instruction `endproc(__umodsi3)'
lib1funcs.S:229: Error: bad instruction `entry(__divsi3)'
lib1funcs.S:230: Error: bad instruction `entry(__aeabi_idiv)'
lib1funcs.S:231: Error: bad instruction `unwind(.fnstart)'
lib1funcs.S:268: Error: bad instruction `unwind(.fnend)'
lib1funcs.S:269: Error: bad instruction `endproc(__divsi3)'
lib1funcs.S:270: Error: bad instruction `endproc(__aeabi_idiv)'
lib1funcs.S:272: Error: bad instruction `entry(__modsi3)'
lib1funcs.S:273: Error: bad instruction `unwind(.fnstart)'
lib1funcs.S:293: Error: bad instruction `unwind(.fnend)'
lib1funcs.S:294: Error: bad instruction `endproc(__modsi3)'
lib1funcs.S:356: Error: bad instruction `unwind(.fnstart)'
lib1funcs.S:357: Error: bad instruction `unwind(.pad #4)'
lib1funcs.S:358: Error: bad instruction `unwind(.save {lr})'
lib1funcs.S:363: Error: bad instruction `unwind(.fnend)'
lib1funcs.S:364: Error: bad instruction `endproc(Ldiv0)'
Makefile:11: recipe for target 'lib1funcs.o' failed
make: *** [lib1funcs.o] Error 1
登錄後復制

應該是去掉頭文件引起的編譯器對定義不理解。
對比老版本的lib1funcs開頭有一些宏定義我們先加上:

#define ALIGN .align 4,0x90
#define __LINUX_ARM_ARCH__ 1

#define ENTRY(name) \
.globl name; \
ALIGN; \
name:
登錄後復制
其中有entry的宏定義,我們可以猜想這些都是在頭文件里的宏定義,其實你去linux內核里找這個頭文件#include <linux/linkage.h>在這里就可以找到entry的宏定義。

7、再次編譯,出現錯誤:

[email protected]:/work/test$ make
arm-linux-gcc -c -o lib1funcs.o lib1funcs.S
lib1funcs.S: Assembler messages:
lib1funcs.S:192: Error: bad instruction `unwind(.fnstart)'
lib1funcs.S:216: Error: bad instruction `unwind(.fnend)'
lib1funcs.S:217: Error: bad instruction `endproc(__udivsi3)'
lib1funcs.S:218: Error: bad instruction `endproc(__aeabi_uidiv)'
lib1funcs.S:221: Error: bad instruction `unwind(.fnstart)'
lib1funcs.S:235: Error: bad instruction `unwind(.fnend)'
lib1funcs.S:236: Error: bad instruction `endproc(__umodsi3)'
lib1funcs.S:240: Error: bad instruction `unwind(.fnstart)'
lib1funcs.S:277: Error: bad instruction `unwind(.fnend)'
lib1funcs.S:278: Error: bad instruction `endproc(__divsi3)'
lib1funcs.S:279: Error: bad instruction `endproc(__aeabi_idiv)'
lib1funcs.S:282: Error: bad instruction `unwind(.fnstart)'
lib1funcs.S:302: Error: bad instruction `unwind(.fnend)'
lib1funcs.S:303: Error: bad instruction `endproc(__modsi3)'
lib1funcs.S:365: Error: bad instruction `unwind(.fnstart)'
lib1funcs.S:366: Error: bad instruction `unwind(.pad #4)'
lib1funcs.S:367: Error: bad instruction `unwind(.save {lr})'
lib1funcs.S:372: Error: bad instruction `unwind(.fnend)'
lib1funcs.S:373: Error: bad instruction `endproc(Ldiv0)'
Makefile:11: recipe for target 'lib1funcs.o' failed
make: *** [lib1funcs.o] Error 1
登錄後復制

unwind() 和unwind()的宏定義老版本里沒有,怎麼辦呢?
全部注釋掉:

#UNWIND(.fnend)
#ENDPROC(__modsi3)
登錄後復制
8、再次編譯,出現錯誤:

[email protected]:/work/test$ make
arm-linux-gcc -c -o lib1funcs.o lib1funcs.S
#arm-linux-ld -Ttext 0 -Tdata 0x30000000 start.o led.o uart.o init.o main.o -o sdram.elf
arm-linux-ld -T sdram.lds start.o led.o uart.o init.o main.o exception.o interrupt.o timer.o nor_flash.o my_printf.o string_utils.o lib1funcs.o -o sdram.elf
my_printf.o: In function `out_num':
my_printf.c:(.text+0x120): undefined reference to `__aeabi_uidivmod'
lib。

LPC2103
LP

❼ 當編譯 2.6.32.2 linux內核時,出現這樣的報錯

這提示的是內核網路驅動源程序中的語法錯誤,如果你沒對下載的linux源碼包做任何修改,那麼按理說是不應該有語法錯誤的。出現這樣的情況,我認為可能是你所安裝的編譯器gcc版本不合適,可以查一下編譯2.6.32.2的內核對應的gcc版本,重新安裝一下再試試。

❽ Linux 0.11內核編譯錯誤記錄

現象1: 提示gas gld 比識別
措施: gnu編譯器發展到後來,越來越流行,更多使用別名為 as ld gcc等.

現象2: 提示位元組對齊需要是 2的倍數
措施: 具體解決方法: 利用命令 sed -i 's/align 2/align 4/g' filename 替換align 2 為 align 4(align 3 替換為 align 8)
sed -i 's/align 2/align 4/g' boot/head.s
sed -i 's/align 3/align 8/g' boot/head.s

現象3: -fcombine-regs -mstring-insns選項不識別
措施: 此兩個選項已經過時,直接去掉即可

現象4: warning 特別多
措施: 將-Wall 替換為 -w

現象5: __stack_chk_fail 未定義
措施: 去網上搜了一下,在Makefile中的$(CFLAGS)後面加上-fno-stack-protector,即不需要棧保護

現象6: main.c 中_syscall0重復定義
措施: main.c static inline _syscall0(int, fork) 去掉static即可

現象7: 提示內嵌匯編不符合語法限制
措施: 類似的問題在後面編譯中出現好多,C內嵌匯編的格式 asm (匯編語句:輸入寄存器:輸出寄存器:可能被修改的寄存器),最新的GCC規定 輸入或輸出寄存器不能出現在可能被修改的寄存器中,目前看到網上的方法是把所有類似問題的可能被修改的寄存器全部刪掉 解決方案:find -type f -exec sed -i 's/:"w{2}"(,"w{2}") )/:) /g' {} ; 其中's/:"w{2}"(,"w{2}") /:/g'

現象8: 在 control.c 中清楚定義了 static unsigned char attr = 0x70 ,而在鏈接 control.o 時,卻爆出 attr未定義。
措施: nm -C control.o 查看其符號,發現attr確實處於未定義狀態。故單獨編譯一個小程序定義靜態變數,查看其 .o 文件中,發現靜態變數定義正常。故考慮為編譯選項差異導致,最終發現因為 -O 編譯優化選項導致,目前處理方式是去掉該選項。

現象9: build.c:(.text+0xde): undefined reference to `MAJOR'
措施: 通過分析編譯列印信息,發現編譯時沒有加入頭文件路徑 -Iinclude

現象10: fs/fs.o: In function check_disk_change':(.text+0x1b2f): undefined reference to invalidate_buffers'
措施: 查找發現此函數定義在buffer.c 中,且為內聯函數, 故嘗試將其更改為普通函數, 然後編譯通過.

現象11: 編譯 build.c 時報錯:/usr/include/i386-linux -gnu/bits/stdio2.h:57:8: error: unknown type name 『__gnuc_va_list』
措施: 分析發現時此系列錯誤均由 -Iinclude 選項導致, 而該選項在 想像9 中加入, 故考慮去掉該選項, 直接在build.c 中加入 MAJOR 宏定義.

❾ linux內核編譯問題

根據你的警告是提示,找不到這些驅動模塊,應該是沒有編譯驅動模塊或者沒有安裝驅動模塊造成的。
1、要確保你的內核包是完整的,而且是centos配套版本(因為各大發行版都會針對自己的情況對內核進行配置和改動,直接用kernel.org的原版內核可能會有些故障)
2、編譯前要 先make clean一下,把以前編譯剩下的東西清掉,重頭再來。

3、編譯時順序執行如下命令
make bzImage 生成內核映像
make moles 生成驅動模塊
make moles_install 安裝驅動模塊
make install 安裝內核

閱讀全文

與linux編譯時報錯303相關的資料

熱點內容
gz壓縮文件夾 瀏覽:175
字母h從右往左跑的c語言編程 瀏覽:127
安卓手機如何擁有蘋果手機橫條 瀏覽:765
業余編程語言哪個好學 瀏覽:137
按照文件夾分個壓縮 瀏覽:104
航空工業出版社單片機原理及應用 瀏覽:758
如何在電信app上綁定親情號 瀏覽:376
安卓的怎麼用原相機拍月亮 瀏覽:805
配音秀為什麼顯示伺服器去配音了 瀏覽:755
c盤清理壓縮舊文件 瀏覽:325
app怎麼交付 瀏覽:343
圖蟲app怎麼才能轉到金幣 瀏覽:175
如何做徵文app 瀏覽:446
用什麼app管理斐訊 瀏覽:169
安卓如何下載寶可夢劍盾 瀏覽:166
編譯器開發屬於哪個方向 瀏覽:940
megawin單片機 瀏覽:687
以色列加密貨幣監督 瀏覽:909
程序員前端現在怎麼樣 瀏覽:499
伺服器和介面地址ping不通 瀏覽:557