No such file or directory問題 [論壇 - 新手村]


正在瀏覽:   1 名遊客


 到底部   前一個主題   下一個主題  [無發表權] 請登錄或者註冊



No such file or directory問題
會員一級
註冊日期:
2017/5/21 23:12
所屬群組:
已註冊使用者
等級: 1
HP : 0 / 5
MP : 1 / 96
EXP: 21
離線
我在編譯uboot中的net/net.c檔案時,使用指令gcc -c net.c,可是出現fatal error:common.h:No such file or directory。
能請問各位高手,通常遇到這種情況有什麼解決辦法,或是有甚麼資料可以參考的嗎?
感謝~

2018/9/19 16:56
應用擴展 工具箱
回覆: No such file or directory問題
會員三級
註冊日期:
2016/4/18 12:29
所屬群組:
已註冊使用者
等級: 9
HP : 0 / 221
MP : 39 / 4617
EXP: 84
離線
檔案跟權限都有嗎?

2018/9/19 17:08
應用擴展 工具箱
回覆: No such file or directory問題
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 37
HP : 0 / 901
MP : 671 / 29339
EXP: 6
離線
異世界的人 寫到:
我在編譯uboot中的net/net.c檔案時,使用指令gcc -c net.c,可是出現fatal error:common.h:No such file or directory
能請問各位高手,通常遇到這種情況有什麼解決辦法,或是有甚麼資料可以參考的嗎?
感謝~


簡單寫了幾個範例放在「GitHub」上,來闡述你遇到問題的相關概念。

先聲明我只會基本的概念,一些深入的議題,我也還不會, Orz...

我猜測,您要編譯成功,除了下面提到的概念,應該還會牽涉到其他的議題。

================================================================================

## demo_000

先來看「demo_000

先產生一個檔案「main.c」,內容如下


int main(int argc, char *argv[])
{
	return 0;
}



接下來執行下面指令,進行編譯


$ gcc -o demo main.c



編譯成功,就會產生一個執行檔「demo」(也就是「-o demo」的效果)。

這時候,就可以執行下面指令,執行「demo」。


$ ./demo



================================================================================

## demo_001

接下來換看範例「demo_001

將「main.c」改成內容如下


#include <stdio.h>
#include "common.h"

int main(int argc, char *argv[])
{
	printf("%s\n", MSG);
	return 0;
}



接下來一樣執行下面指令,進行編譯


$ gcc -o demo main.c



這時候就會顯示一些提示訊息如下


main.c:3:10: fatal error: common.h: No such file or directory
#include "common.h"
^~~~~~~~~~
compilation terminated.


================================================================================

## demo_002

接下來換看範例「demo_002」,

而「main.c」的內容一樣,

只是加入了一個檔案「common.h」。

接下來一樣執行下面指令,進行編譯


$ gcc -o demo main.c



這時候就會編譯成功,產生一個執行檔「demo」。

於是就可以執行下面指令,執行「demo」。


$ ./demo



顯示


Hi!



================================================================================

## demo_003

接下來換看範例「demo_003」,

而「main.c」的內容一樣,

先產生一個資料夾「inc」,將剛剛的「common.h」移到「inc」這個資料夾,也就是放在「inc/common.h」。

接下來一樣執行下面指令,進行編譯


$ gcc -o demo main.c



這時候就會顯示一些提示訊息如下


main.c:3:10: fatal error: common.h: No such file or directory
#include "common.h"
^~~~~~~~~~
compilation terminated.


================================================================================

## demo_004

接下來換看範例「demo_004」,

而「main.c」的內容一樣,

而「common.h」一樣放在inc」這個資料夾。

接下來改執行下面指令,進行編譯,也就是加了「-Iinc」。


$ gcc -o demo main.c -Iinc



這時候就會編譯成功,產生一個執行檔「demo」。

於是就可以執行下面指令,執行「demo」。


$ ./demo



顯示


Hi!



================================================================================

$ man gcc

================================================================================

我通常用關鍵字「餃子 open source」查詢,

可以找到「用Open Source工具開發軟體」。

* http://www.study-area.org/cyril/opentools/opentools/gcc.html
* http://www.study-area.org/cyril/opentools/opentools/x864.html
* http://www.study-area.org/cyril/opentools/opentools/x869.html

================================================================================

* https://developer.gnome.org/glib/stable/glib-compiling.html
* https://developer.gnome.org/gtk3/stable/gtk-compiling.html
* https://developer.gnome.org/gio/stable/ch03.html

================================================================================

* http://hackfoldr.org/dykc/
* https://www.youtube.com/channel/UCIm-u7l65hp5jboSJrB7U5w/videos
* https://github.com/tinyclub/open-c-book

================================================================================

* http://linux.vbird.org/linux_basic/0520source_code_and_tarball.php

================================================================================

## 相關討論

* #13 回覆: 如何安裝 StarUML-v2.8.0-64-bit.deb ?

================================================================================

以上提供參考

報告完畢


2018/9/19 20:31
應用擴展 工具箱
回覆: No such file or directory問題
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 37
HP : 0 / 901
MP : 671 / 29339
EXP: 6
離線
以下測試的環境是「Ubuntu 18.04」。


其實我對這個不懂,以下是只是我剛剛胡亂測試的一些紀錄,提供您一個探索的起點。

剛使用「u-boot」當關鍵字查詢,

查到「Wikipedia / Das U-Boot」。

接著可以找到「http://git.denx.de/u-boot.git/」這個頁面。

裡面就可以找到「http://git.denx.de/u-boot.git」這個網址。


所以可以執行下面指令


$ git clone http://git.denx.de/u-boot.git



執行完成後,會有一個資料夾「u-boot」。

執行下面指令,切換到「u-boot」這個資料夾。


$ cd u-boot



然後可以找到一個檔案「doc/README.x86」。

執行下面指令,觀看「doc/README.x86」。


$ less doc/README.x86



會看到其中一個範例,有下面兩行指令


$ make coreboot_defconfig
$ make all



所以先執行


$ make coreboot_defconfig



顯示


#
# configuration written to .config
#



也就是會產生「.config」這個檔案

接著執行


$ make all



就會編譯完成。

接下來我就沒再測試了,對這個工具其實不懂,其他的就需要您深入去探索了,以上提供您一個探索的起點。

================================================================================

發現在「GitHub」上也有「Repository」,

網址是「https://github.com/u-boot/u-boot」。

所以也可以執行下面指令


$ git clone https://github.com/u-boot/u-boot.git



================================================================================

在套件庫也有相關的套件,不過版本可能比較舊。


$ apt-cache search u-boot



顯示


u-boot-tools - companion tools for Das U-Boot bootloader
cbootimage - Tools to dump and generate boot config table on Tegra devices
u-boot-menu - u-boot menu update
vboot-utils - Chrome OS verified u-boot utilities
vmdebootstrap - Bootstrap Debian into a (virtual machine) disk image



執行下面指令,觀看「Binary Package: u-boot-tools」的相關資訊。


$ apt-cache show u-boot-tools



執行


$ apt-cache showsrc u-boot-tools



可以執行下面指令,下載「Source Package: u-boot


$ apt-cache source u-boot-tools



更多的套件探索案例,請參考「[索引] 套件操作實務」。

================================================================================

以上額外發現補充,報告完畢


2018/9/20 0:17
應用擴展 工具箱
回覆: No such file or directory問題
會員一級
註冊日期:
2017/5/21 23:12
所屬群組:
已註冊使用者
等級: 1
HP : 0 / 5
MP : 1 / 96
EXP: 21
離線
回覆net2016前輩:是的,檔案跟權限都有喔,謝謝~

回覆samwhelp前輩:謝謝您提供的資料,讓我先一步步嘗試看看~

2018/9/20 10:54
應用擴展 工具箱


 [無發表權] 請登錄或者註冊


可以查看帖子.
不可發帖.
不可回覆.
不可編輯自己的帖子.
不可刪除自己的帖子.
不可發起投票調查.
不可在投票調查中投票.
不可上傳附件.
不可不經審核直接發帖.