導航:首頁 > 程序命令 > ubuntu的make命令找不到

ubuntu的make命令找不到

發布時間:2022-12-09 14:09:07

㈠ Ubuntu bochs源碼安裝時出現: make: *** 沒有指明目標並且找不到 makefile。 停止。

用ubuntu中的ubuntu軟體安裝中心安裝的bochs不帶調試功能,所以我們要用源碼安裝bochs.

從http://sourceforge.net/projects/bochs/files/ 下載bochs-2.4.5.tar.gz

然後

tar vxzf bochs-2.4.5.tar.gz
cd bochs-2.4.5
./configure --enable-debugger --enable-disasm
make
sudo make install

結果出錯,解決的辦法是:

問題1:
checking for C compiler default output file name… configure: error: C compiler cannot create executables
解決辦法:
[thornbird@thornbird bochs-2.4]$ sudo apt-get install libc6-dev
問題2:
...
checking how to run the C++ preprocessor... /lib/cpp
configure: error: C++ preprocessor "/lib/cpp" fails sanity check
See `config.log' for more details.
解決方法:
[thornbird@thornbird bochs-2.4]$ sudo apt-get install build-essential

問題3:
[thornbird@thornbird bochs-2.4]$ make
make: *** 沒有指明目標並且找不到 makefile.停止。
解決方法:
[thornbird@thornbird bochs-2.4]$ sudo apt-get install build-essential

問題4:
...
checking for wxWidgets library version...
checking for default gui on this platform... x11
ERROR: X windows gui was selected, but X windows libraries were not found.

解決方法: 配置的時候加上"--with-nogui "
或者改成:[thornbird@thornbird bochs-2.4]$sudo apt-get install xorg-dev (建議)

問題5:

Package gtk+-2.0 was not found in the pkg-config search path.Perhaps you should add the directory containing `gtk+-2.0.pc'to the PKG_CONFIG_PATH environment variableNo package 'gtk+-2.0' foundERROR: pkg-config was not found, or unable to access the gtk+-2.0 package.Install pkg-config and the gtk+ development package,or disable the gui debugger, or the wxWidgets display library (whichever is being used).

解決方法:

[thornbird@thornbird bochs-2.4]$sudo apt-get install libgtk2.0-dev

問題6:

install: 無法獲取"./bochsdbg" 的文件狀態(stat): 沒有該文件或目錄

解決辦法:需要在make後,將bochs拷貝一份,命名為bochsdbg

[thornbird@thornbird bochs-2.4]$ cp bochs bochsdbg

㈡ ubuntu linux裡面 make 命令不能用 怎麼決

從問題補充來看,你的g++沒有安裝,你安裝一下g++即可,安裝g++的方法如下:
1、按Ctrl+Alt+T快捷鍵打開終端。
2、輸入:sudo apt-get install g++ 命令,然後回車。
3、輸入root用戶密碼(輸入的時候不會顯示,輸入完成後回車就行了)。
4、等待安裝完成。
通過以上步驟基本就能安裝好g++了。

㈢ 我裝的linux 系統中沒有make命令,沒有很多命令,比如init 、reboot、shutdown等等,怎麼辦能安裝rpm,

這些命令應該是最基本的命令,不應該沒有安裝的
可能是你的許可權不夠,或者是你的$PATH不正確導致的
首先你是用root用戶執行的嗎?
然後看下echo $PATH,你的路徑中是否包含了/bin;/sbin;/usr/bin;/usr/sbin目錄呢?

㈣ make命令找不到makefile 怎麼解決

我勒個去,ls你太無恥了吧,那是我原來發的帖,也是我的作業,你居然給我硬生生的復制過來也不註明一下?拜託你註明一下OK?而且你明明就是答非所問。

如果沒記錯的話,ubuntu是需要裝一個patch才能用make命令的,而redhat(fedora)都是集成了的。

㈤ Ubuntu下面Makefile的使用方法

運行可執行文件hello

./hello

移除文件 rm hello

編譯文件得到可執行文件的同時,保留產生的中間文件

g++ -save-temps hello_world.cpp -o hello

單個文件編譯過程:
實際的編譯過程:預處理,對應臨時文件hello_world.ii

g++ -E hello_world.cpp -o preprocessed.ii

cat preprocessed.ii

預處理的工作主要包含去掉注釋,然後將我們include的庫tack上,以上過程使我們自己主動調用預處理器的過程

cat hello_world.ii

則展示了我們在第5)中編譯時保留的中間文件,兩者是一樣的

實際的編譯過程:這是真正的編譯過程compilation step,對應臨時文件hello_world.s(assembly code)

我們自己把.ii文件進行assembly code得到.s的方法。

g++ -S preprocessed.ii -o complied.s

.s文件是高級語言和機器語言之間的中間環節

實際的編譯過程:Assembly,將.s對應的assembly code轉換成.o對應的機器語言的過程,也叫machine-readable code或者object code

讓編譯器將.s文件assembly起來

g++ -c complied.s -o assembled.o

實際的編譯過程:最後一步Linking,產生最終的可執行文件。

"Undefined reference" errors are pretty much always linking errors, and you will probably have them. Remember this.

我們通過連接一堆.o文件,得到.exe文件的過程,命令:

g++ assembled.o -o hello_manual

多個文件編譯過程:
舉例,如果我們有定義一個class,然後我們的文件中包含dog.hpp,dog.cpp和main.cpp三個文件,然後我們只使用以下兩個命令:

g++ -c main.cpp -o main.o

g++ main.o dog_program

的話就會出錯,告訴我們undefined reference of dog::bark()

因為對於不同的.cpp文件,都要生成一個object file,也就是.o文件。所以如果我們用以下命令:

g++ -c main.cpp -o main.o

g++ -c dog.cpp

g++ dog.o main.o -o dog_program

的話,就不會出錯。

我們如果修改main.cpp中的內容的話,我們只需要重新用最後一個連接命令。但是,如果我們修改了dog class本身的內容的話,例如添加一個函數,我們就需要重新產生object file of dog.cpp,然後重新連接。

關於Make的介紹
用自己常用的記事本創建一個Makefile,並注意大小寫。在program對應的目錄下面。

gedit Makefile

Makefile裡面語句的書寫規則是

Target: tgt_dependency1 tgt_dependency2 ……
Command

所以dog.o和main.o對應的語句分別是:

dog.o: dog.hpp dog.cpp
g++ -c dog.cpp

main.o: main.cpp
g++ -c main.cpp

在Makefile中Tab是很重要的,所以不要忘記在command對應的第二行加Tab

Makefile的編譯順序

如果Makefile中有如下語句

animal_assembly : moose goose cat
command

moose : antlers hooves fur
command

goose : beak wings webbed_feet interest_in_bread
command

cat : whiskers evil_personality
command

我們可以看到animal_assembly的dependency是 moose goose cat。如果文件夾中存在moose goose cat的話,make命令只需要執行第一句就可以了。如果文件夾中缺少moose goose cat中的一個或者幾個,make命令執行的時候,需要先找到moose goose cat的生成方法,然後執行對應的命令,最後執行animal_assembly生成的命令。

moose : antlers hooves fur
command

animal_assembly : moose goose cat
command

goose : beak wings webbed_feet interest_in_bread
command

cat : whiskers evil_personality
command

如果Makefille是以上形式的話,我們只運行make的話,Makefile會只執行第一句,因為第一句的dependency都存在了,所以只把moose生成的命令執行完就好了。如果我們要生成animal_assembly,就要運行命令make animal_assembly。所以,我們需要把最重要的命令,我們最重要生成的object file對應的命令放在第一行。

所以我們的dog_program的完整的Makefile文件應該是:

dog_program: dog.o main.o
g++ dog.o main.o -o dog_program

dog.o: dog.hpp dog.cpp
g++ -c dog.cpp

main.o: main.cpp
g++ -c main.cpp

在Makefile的最後寫clean語句。

clean:
rm dog_program *.o

然後我們在命令窗口運行make clean的話,就會刪除文件夾中生成的可執行文件,和所有過程中產生的副產品。

對於Makefile中的dependency list,我們需要將每個object file的dependency list都寫好。因為make不負責檢查文件中的具體的語句,只負責執行Makefile中的語句。

dog_program:
g++ dog.o main.o -o dog_program

dog.o: dog.hpp dog.cpp
g++ -c dog.cpp

main.o: main.cpp
g++ -c main.cpp

如果像上面所示去掉dog_program的dependency list的話,運行make就會出錯,因為main是依賴於dog.cpp的。

如果文件中本身就存在dog.o和main.o的話,運行make不會出錯,因為make就是先check dog.o main.o是否存在,存在的話就直接運行。

所以,我們如果修改了main.cpp或者dog.cpp的話,我們需要重新生成dog.o和main.o。因為make是不管這個問題的。

make這個命令的功能就是執行Makefile中我們要求執行的語句,對結果沒有任何的預期,也不會檢查命令有沒有問題。所以,我們必須遵守Makefile書寫中的一些規則。

all : fill_file_with_nonsense
echo "I have mostly created a lot of junk today!"

fill_file_with_nonsense : create_file
echo "Hello, there is nothing important here" > silly_file

create_file :
touch silly_file touch是Unix中的典型命令,用於生成空的文件

move_file :
mv silly_file silly_file_new_name

delete_file :
rm _file

open_file :
gedit another_silly_file

clean :
touch junk1 junk2 junk3 junk4 junk5

really_clean :
rm junk*

如果想體驗的更加清楚,就可以運行這個文件中的內容,然後就知道make完全不會管結果是什麼,只是沒有腦子的執行命令。

解釋上面的內容:

Makefile的書寫規則。all: 放在第一句,把所以我們要生成executable依賴的Targets列出來,這樣我們需要的所有的文件都可以生成。我們看到all對應的dependency是file_file_with_nonsense,就去找file_file_with_nonsense的生成語句,發現它的dependency是create_file,然後去找create_file的生成語句,就到touch silly_file,touch是Unix中的典型命令,用於生成空的文件。create_file的語句執行完之後,回到file_file_with_nonsense,執行echo "Hello, there is nothing important here" > silly_file,就把"Hello, there is nothing important here" 寫入silly_file中,file_file_with_nonsense的語句也執行完之後,我們就返回到all,然後在命令行輸出"I have mostly created a lot of junk today!"。

因為其他的target,不在all的dependency list中,也不在all的dependency的dependency當中,所以只能通過make target的形式來調用對應的命令。

Marvelous macros(宏)
一個宏的示例,宏就是Makefile中的variables,用來定義我們需要的操作,一些變數之類的

CXX = clang++

FLAGS = -O

hello : hello_world.cpp
$(CXX) $(FLAGS) $? -o $@

clean :
rm hello

CXX,這是一個預定義的宏,default value是g++。這里把CXX定義成clang++了。

FLAGS,這里定義的是-O。FLAGS也不一定非得定義成-o,也可以是some moose have large antlers,但是這樣定義的話,就會導致調用的時候出錯。

對於上面的文件,我們在命令行輸入make的時候,實際運行的是clang++ -O hello_world.cpp -o hello。

如果我們把CXX=clang++這一行刪掉的話,在命令行輸入make,實際運行的就是g++ -O hello_world.cpp -o hello。

定義好macro宏,我們使用的時候,就要用$(MACRO)這樣的形式,這是makefile語言的一種語法。我們注意到MACRO全部用的大寫,雖然不是明確規定的,但是通常情況下用大寫。

$?和$@是makefile language裡面特別的預定義的宏。$?是指的"names of the dependencies(newer than the target)",$@是指的"name of the target"。

Complier and liner flags in CS 225

CXX = clang++ LD = clang++

CXXFLAGS = -std=c++1y -stdlib=libc++ -c -g -O0 -Wall -Wextra -Werror -pedantic

LDFLAGS = -std=c++1y -stdlib=libc++ -lpng -lc++abi

㈥ ubuntu里沒有make命令嗎

make只是用來幫助配置編譯參數、調用編譯命令的,需要安裝gcc編譯器才能編譯。
網路不好的話還是安裝dvd版本,不用通過網路下東西。

閱讀全文

與ubuntu的make命令找不到相關的資料

熱點內容
雲存儲伺服器可靠嗎 瀏覽:967
2核1g的雲伺服器能帶動游戲嘛 瀏覽:898
逆命20解壓碼 瀏覽:142
徐州辦犬證需要下載什麼app 瀏覽:1002
百保盾是什麼樣的app 瀏覽:699
文件和文件夾的命名規格 瀏覽:796
java命令行運行java 瀏覽:664
搜索pdf內容 瀏覽:497
程序員裝機必備的軟體 瀏覽:12
php微信第三方登錄demo 瀏覽:538
上海php工具開發源碼交付 瀏覽:793
哪裡有求購黃頁的源碼 瀏覽:194
商城礦機源碼礦場系統 瀏覽:198
單片機的led燈熄滅程序 瀏覽:224
洛陽python培訓 瀏覽:704
小鍵盤命令 瀏覽:194
單片機c語言返回主程序 瀏覽:816
dockerpythonweb 瀏覽:970
程序員演算法有多強 瀏覽:717
pythonworkbook模塊 瀏覽:245