linux 下eclipse調試程序,文章2 Linux安裝Eclipse閱讀及調試程序

由于安裝Eclipse需要Java環境,還需要配置環境,非常復雜,建議安裝系統時,選擇上Eclipse開發工具

但是安裝的Eclipse中沒有CDT。首先給Eclipse安裝一個CDT。

1.安裝CDT

Eclipse菜單欄help----Install New Software.從Available Software Sites中選擇

http://download.eclipse.org/tools/cdt/releases/helios的網址,然后select all。

我將所有選項都選擇了。

一步步往下走,最后重啟Eclipse即可。

2.Linux下修改Eclipse的默認語言。

安裝CDT后,Eclipse的默認語言為漢語,實在不習慣啊。我打算將其修改為英文。修改方式如下:

1)通過whereis eclipse找到eclipse的位置。

$whereis eclipse

output:

/usr/bin/eclipse /etc/eclipse.ini /usr/lib/eclipse /usr/share/eclipse

2)打開eclipse.ini修改其中內容

$vim??/etc/eclipse.ini

output:

添加一句話

-Duser.language=en

保存退出

3)重新啟動Eclipse,成功變為英文界面。

3.編寫第一個C/C++Project

1)新建項目 File--New---C Project

選擇Executable-----Empty Project ----Linux GCC

假設我的項目名為HelloWorld

2)新建源文件

左側Project Explorer 中,選中HelloWorld點擊右鍵 New---Source File

切記:命名時要加上后綴.c,不然會提示錯誤。

3)輸入源代碼

#include main() { printf("Hello world!\n"); }

切記:1)一定要保存,否則會提示錯誤。

2)如果是新建C++Project,后綴名為.cpp

4.導入已經存在的項目

1)概述:

在安裝CDT后,出現的C/C++ Project為 C Project 、C++ Project、 Makefile C Project。但是很多教程中都包括的是Standard Make C++ Project。瞬間讓我失望。終于還是找到了最可愛的官方文檔。 http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.cdt.doc.user%2Fconcepts%2Fcdt_c_build_over.htm

步驟1:必須創建一個簡單的項目,該項目能夠反映已存在源代碼樹中的所有元素

1.選擇File > New > Project.

2.對于該項目,選擇C/C++和C project。由于后文中要導入Nginx(完全由C編寫),因此選擇C Project。

3.在Project Name中,輸入項目名

4.確保Use default location 沒有被選中。因為我們要指定源代碼所在的位置,而不是我們的工作區,因此,不能使用use default location.

5.在Location處,點擊Browse,選擇源代碼和Makefile所在的文件夾。假設源代碼和Makefile所在的文件夾為Nginx-1.2.3。

6.從Project types列表中,展開Makefile Project,選擇Empty Project。

7.確保選擇上Toolchains。Toolchains選擇Linux GCC。

8.點擊Next

9.(可選)全選,點擊Next即可。

10.點擊Finish,關閉對話框。

完成上述步驟后,在Project Explorer view中就可以看到新的項目。

5.導入Nginx所需要做的工作

對于Nginx的源代碼,在完成上述步驟以后,會發現在console中會提示以下錯誤,該如何解決呢?

make all

make:*** 沒有規則可以創建目標“all”。停止

或者

make: *** no rule to make target 'all'.

1)修改build選項。主要是修改Build的取值。

在我的Eclipse版本中,修改方法如下:

1.在Project Explorer中選中Nginx-1.2.3項目,點擊右鍵選中Project Properties。在右側找到C/C++ Build。

2.C/C++ Build ----Behavior 將Build改為空即可。如下圖所示

d6fdd9eef41a635b5b4c95dca3b2bdca.png

3.配置運行參數,打開Run Configuration對話框

1)在菜單欄Run---Run Configuration 中設置。C/C++ Application中選擇objs/nginx(如果沒有,先make一次)。Arguments添加

-c /home/hpnl/nginx_source/nginx-1.2.3/conf/nginx.conf指定運行時配置文件。注意:所添加的conf文件是在nginx源代碼目錄中的。

2)修改該conf的內容(完整文件)加粗字體為改動部分。

#user??nobody;

worker_processes??1;

daemon??off;

#daemon?must?be?set?as?off

#error_log??logs/error.log;

#error_log??logs/error.log??notice;

#error_log??logs/error.log??info;

events?{

worker_connections??1024;

}

http?{

include???????mime.types;

default_type??application/octet-stream;

#log_format??main??'$remote_addr?-?$remote_user?[$time_local]?"$request"?'

#??????????????????'$status?$body_bytes_sent?"$http_referer"?'

#??????????????????'"$http_user_agent"?"$http_x_forwarded_for"';

#access_log??logs/access.log??main;

sendfile????????on;

#tcp_nopush?????on;

#keepalive_timeout??0;

keepalive_timeout??65;

#gzip??on;

server?{

listen???????80;

server_name??localhost;

#charset?koi8-r;

#access_log??logs/host.access.log??main;

location?/?{

root???html;

index??index.html?index.htm;

}

location?/hello{

hello_world;

}

#error_page??404??????????????/404.html;

#?redirect?server?error?pages?to?the?static?page?/50x.html

#

error_page???500?502?503?504??/50x.html;

location?=?/50x.html?{

root???html;

}

#?proxy?the?PHP?scripts?to?Apache?listening?on?127.0.0.1:80

#

#location?~?\.php$?{

#????proxy_pass???http://127.0.0.1;

#}

#?pass?the?PHP?scripts?to?FastCGI?server?listening?on?127.0.0.1:9000

#

#location?~?\.php$?{

#????root???????????html;

#????fastcgi_pass???127.0.0.1:9000;

#????fastcgi_index??index.php;

#????fastcgi_param??SCRIPT_FILENAME??/scripts$fastcgi_script_name;

#????include????????fastcgi_params;

#}

#?deny?access?to?.htaccess?files,?if?Apache's?document?root

#?concurs?with?nginx's?one

#

#location?~?/\.ht?{

#????deny??all;

#}

}

#?another?virtual?host?using?mix?of?IP-,?name-,?and?port-based?configuration

#

#server?{

#????listen???????8000;

#????listen???????somename:8080;

#????server_name??somename??alias??another.alias;

#????location?/?{

#????????root???html;

#????????index??index.html?index.htm;

#????}

#}

#?HTTPS?server

#

#server?{

#????listen???????443;

#????server_name??localhost;

#????ssl??????????????????on;

#????ssl_certificate??????cert.pem;

#????ssl_certificate_key??cert.key;

#????ssl_session_timeout??5m;

#????ssl_protocols??SSLv2?SSLv3?TLSv1;

#????ssl_ciphers??HIGH:!aNULL:!MD5;

#????ssl_prefer_server_ciphers???on;

#????location?/?{

#????????root???html;

#????????index??index.html?index.htm;

#????}

#}

}

此時就可以正常運行Nginx和進行調試了

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/278953.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/278953.shtml
英文地址,請注明出處:http://en.pswp.cn/news/278953.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Redis學習筆記~分布式的Pub/Sub模式

redis的客戶端有很多,這次用它的pub/sub發布與訂閱我選擇了StackExchange.Redis,發布與訂閱大家應該很清楚了,首先一個訂閱者,訂閱一個服務,服務執行一些處理程序(可能是寫個日志,插入個數據&am…

django自定義用戶表

django自帶了用戶表。 -- auto-generated definition create table auth_user (id int auto_incrementprimary key,password varchar(128) not null,last_login datetime(6) null,is_superuser tinyint(1) not null,username varchar(150) not null,fir…

easyui關機圖標_如何在Windows 10中創建關機圖標

easyui關機圖標It’s true that shutting down your Windows 10 PC the old-fashioned way only takes three clicks. But why spend the extra energy when you can do it in two? All you have to do is create a shutdown icon, and you’ll save yourself some time. 的確…

Struts2+JFreeChart

下面以邊帖圖片和代碼的方式來講解Struts2與JFreeChart的整合。搭建環境:首先帖一張工程的目錄結構以及所需的jar包。注意:如果你不打算自己寫ChartResult的話只需要引入struts2-jfreechart-plugin-2.0.6.jar(這個在struts-2.0.6-all.zip可以找到了): …

STM32的FLASH ID加密

#define FLASH_ID_OFFSET 30000 //任意定義一個數 //把地址直接減去或者加上一個數是不要程序中直接出現這個地址 volatile u32 Flash_ID_addr[3]{ 0x1FFFF7E8 - FLASH_ID_OFFSET, 0x1FFFF7EC FLASH_ID_OFFSET, 0x1FFFF7F0 - FLASH_ID_OFFSET }; /**讀取STM32 FLASH ID*…

linux c視頻如何加水印,如何在Kdenlive的視頻上進行水印 | MOS86

如果你這些東西被稱為水印。他們So,你如何在Linux中創建水印?嗯,你這可能是Linux上最強大的開源視頻編輯器。Installation如果您尚未安裝Kdenlive,您應該可以在包裹管理器中找到它。在Ubuntu中,您還可以使用命令:sudo …

mac觸控板手勢無法使用_如何在iPad上使用觸控板手勢

mac觸控板手勢無法使用Apple蘋果Apple’s new floating Magic Keyboard case for the iPad Pro looks fantastic, but you don’t need to spend $299 to use a trackpad. Simply connect a Magic Trackpad or a third-party multi-touch trackpad to get access to all of iPa…

02.并發編程(2)Thread類源碼分析

概述 在說線程之前先說下進程,進程和線程都是一個時間段的描述,是CPU工作時間段的描述。 進程,是并發執行的程序在執行過程中分配和管理資源的基本單位,是一個動態概念,竟爭計算機系統資源的基本單位。每一個進程都有一…

安裝SQLserver2008

雙擊點擊setup,以管理員身份運行; 點擊安裝-》全新SQLServer獨立安裝或向現有安裝添加功能 選擇下一步,然后點擊具有高級服務的express版本,點擊下一步; 點擊選擇我接受許可條款,然后繼續點擊下一步&#x…

如何在沒有Word的情況下打開Microsoft Word文檔

Microsoft Word is part of Microsoft Office and requires an up-front purchase or a Microsoft 365 subscription. If you’re using a computer without Word installed, there are other ways to view that DOCX or DOC file. Microsoft Word是Microsoft Office的一部分&a…

redhat9Linux解壓gz,linux (redhat9)下subversion 的安裝

搞了一個subversion 花費了我兩天的時間,其間雖然有干其他的事情,但是來來回回的裝,搞的我是一點脾氣都沒有了,俗話說不經歷風雨真的見不到彩虹。就是這個意思. 原本本的下來一.準備好安裝包打算使用apache來瀏覽subversion &…

數組去重的4種方法(Which one is the fastest???嘻嘻嘻....)

<!DOCTYPE html> <html lang"en"> <head> <meta charset"UTF-8"> <title>Document</title> </head> <body> <input type"button" value"數組去重1" οnclick"show()"&g…

flask中的模型

1.什么是模型   模型&#xff0c;是根據數據庫中表的結構而創建出來的class。每一張表對應到編程語言中&#xff0c;就是一個class表中的每一個列對應到編程語言中就class中的一個屬性。 2.ORM的三大特征   1.數據表(table)到編程類(class)的映射     數據庫中的每一張…

windows復制文件路徑_如何在Windows 10上復制文件的完整路徑

windows復制文件路徑Sometimes, it’s handy to copy the full path of a file or folder in Windows 10 to the clipboard. That way, you can paste the path into an open or upload dialog quickly without having to browse for it the file. Luckily, there’s an easy w…

用c語言復制字符串的元音字母,急求:編寫程序,將一個字符串中的元音字母復制到另一個字符串,然后輸出。...

#include#includevoid str(char a[100],char b[100]){int i0, j0;while(a[i]!\0)//\0代表ASCLL碼0的字符&#xff0c;即是一個空操作符也就是是結束符;{if(a[i]a||a[i]e||a[i]i||a[i]o||a[i]u){b[j]a[i];j;}i;}}int main(){char a[100];char b[100];gets(a);str(a,b);puts(b);r…

05 替換空格

題目描述&#xff1a; 請實現一個函數&#xff0c;將一個字符串中的每個空格替換成“%20”。例如&#xff0c;當字符串為We Are Happy.則經過替換之后的字符串為We%20Are%20Happy。 解題思路有&#xff1a; #判斷字符串是否為空&#xff0c;判斷length是否大于0。 #記錄空格的數…

超鏈接禁用_在Microsoft Word 2003和2007中禁用自動超鏈接

超鏈接禁用If you can’t stand the automatic hyperlinking in Microsoft Word, you might be hard-pressed to find the right place to disable it in Office 2007, since all the settings are hidden so well compared to previous versions. 如果您無法在Microsoft Word中…

c語言如何創建虛擬串口,模擬串口的C語言源程序代碼

本程序是模擬串口硬件機制寫的&#xff0c;使用時可設一定時中斷&#xff0c;時間間隔為1/4波特率&#xff0c;每中斷一次調用一次接收函數&#xff0c; 每中斷4次調用一次發送函數,不過.對單片機來說時鐘并須要快.要知道9600的波特率的每個BIT的時間間隔是104us.而單片機中斷一…

webjars管理靜態資源

webjars用途簡單解釋 : 利用Servlet3協議規范中,包含在JAR文件/META-INF/resources/路徑下的資源可以直接被web訪問到這一原理&#xff0c;將前端靜態資源打成jar包方便管理 靜態資源打jar包 新建maven工程&#xff0c; 將需要打包的靜態資源放入src/main/resources中 2. ma…

Windows Intellij環境下Gradle的 “Could not determine Java version from ‘9.0.1’”的解決方式...

當我導入Gradle項目初試Java spring的時候&#xff0c;遇到下面報錯: Gradle complete project refresh failed Error:Could not determine java version from 9.0.1. 參考這篇 http://www.ddiinnxx.com/solving-not-determine-java-version-9-0-1-gradle-intellij-macosx/ 進行…