2012-08-04 30 views
0

我得到這個問題是我在後臺運行countryServer,然後我殺了它。我試圖重新編譯一個新的版本,這就是我得到C++,使用g ++編譯工作正常,如果新文件還有問題

[email protected]:/home/baoky/shell_assignment/shell_assn2# g++ -o countryServer CountryServer.cpp 
[email protected]:/home/baoky/shell_assignment/shell_assn2# ./countryServer & 
[1] 3097 
[email protected]:/home/baoky/shell_assignment/shell_assn2# 
Running server program 'css' ...... 

Country Directory server started 

[email protected]:/home/baoky/shell_assignment/shell_assn2# ps 
    PID TTY   TIME CMD 
2993 pts/3 00:00:00 su 
3001 pts/3 00:00:00 bash 
3097 pts/3 00:00:00 countryServer 
3098 pts/3 00:00:00 ps 
[email protected]:/home/baoky/shell_assignment/shell_assn2# kill 3097 
[1]+ Terminated    ./countryServer 
[email protected]:/home/baoky/shell_assignment/shell_assn2# g++ -o countryServer CountryServer.cpp 
/usr/bin/ld: cannot open output file countryServer: No such device or address 
collect2: ld returned 1 exit status 

[email protected]:/home/baoky/shell_assignment/shell_assn2# ls -l 
total 60 
-rw-r--r-- 1 baoky baoky 19545 Aug 2 10:33 Countries.txt 
-rwxr-xr-x 1 root root 14756 Aug 4 03:17 countryClient 
-rw-r--r-- 1 baoky baoky 3514 Aug 4 03:19 CountryClient.cpp 
-rw-r--r-- 1 baoky baoky 4740 Aug 4 2012 CountryData.c 
-rw-r--r-- 1 baoky baoky 2022 Aug 2 10:33 CountryData.h 
srwxr-xr-x 1 root root  0 Aug 4 03:29 countryServer 
-rw-r--r-- 1 baoky baoky 7762 Aug 4 03:18 CountryServer.cpp 

我得到的回報我這個 在/ usr/bin中/ LD錯誤:無法打開輸出文件countryServer:沒有這樣的設備或地址 collect2:LD返回1退出狀態

我可以修復它,如果我做室射頻countryServer

但如何解決它,所以它可以覆蓋舊countryServer(後我殺的過程,並重新編譯)

回答

2

* c * ountryServer.cpp和* C * ountryServer.cpp是Linux/Unix系統上的不同文件。

+0

對不起更新的版本。 – 2012-08-04 10:32:10

1

文件路徑在Linux中區分大小寫。

countryServer.cpp和CountryServer.cpp不是相同的路徑。

4

您的countryServer程序似乎是在當前目錄中創建一個名爲countryServer的套接字文件,並在該過程中覆蓋自身。

編譯代碼之前刪除該套接字文件,或更好:更改您的代碼,以便它不覆蓋自己的可執行文件。

+0

我該怎麼做:) – 2012-08-04 10:35:05

+0

我不知道我理解你的問題。更改代碼以便它使用另一個套接字文件名稱。或者如果套接字文件名是固定的,請更改您的可執行文件名 – Mat 2012-08-04 10:36:53