CodeBlocks使用说明书

CodeBlocks使用说明书
CodeBlocks使用说明书

CodeBlocks

Manual

Version1.0

Thanks to the CodeBlocks team:

Anders F.Bj¨o rklund(afb),Biplab Kumar Modak(biplab),Bartomiej wiecki(byo),Paul A.Jimenez(ceniza),Koa Chong Gee(cyberkoa),Daniel Orb(daniel2000),Lieven de Cock (killerbot),Yiannis Mandravellos(mandrav),Mispunt(mispunt),Martin Halle(morten-mac?y),Pecan Heber(pecan),Ricardo Garcia(rickg22),Thomas Denk(thomasdenk), tiwag(tiwag)

1CodeBlocks Project Management

The instructions for chapter3on page47and chapter4on page56are o?cial documen-tations of the CodeBlocks Wiki site and available in english only.

The below illustration shows the design of the CodeBlocks user interface.

Figure1.1:IDE CodeBlocks

Management This window contains the interface’Projects’which will in the following text be referred to as the project view.This view show all the projects opened in CodeBlocks at a certain time.The’Symbols’tab of the Management window shows symbols,variables etc..

Editor In the above illustration,a source named hello.c is opened with syntax high-lighting in the editor.

Open?les list shows a list of all?les opened in the editor,in this example:hello.c. CodeSnippets can be displayed via the menu’View’→’CodeSnippets’.Here you can manage text modules,links to?les and links to urls.

CodeBlocks V1.0 1.1Project View Logs&others.This window is used for outputting search results,log messages of a compiler etc..

The status bar gives an overview of the following settings:

?Absolute path of an opened?le in the editor.

?The editor uses the default character encoding of your host operating system.This setting will be displayed with default.

?Row and column number of the current cursor position in the editor.

?The con?gured keyboard mode for inserting text(Insert or Overwrite).

?Current state of a?le.A modi?ed?le will be marked with Modi?ed otherwise this entry is empty.

?The permission of a?le.A?le with read only settings will display Read only in the status bar.In the window’Open?les list’these?les will be emphasised with a lock as icon overlay.

?If you start CodeBlocks with the command line option--personality= then the status bar will show the currently used pro?le,otherwise default will be shown.The settings of CodeBlocks are stored in the corresponding con?guration?le .conf.

CodeBlocks o?ers a very?exible and comprehensive project management.The following text will address only some of the features of the project management.

1.1Project View

In CodeBlocks,the sources and the settings for the build process are stored in a project ?le.cbp.C/C++sources and the corresponding header?les are the typical components of a project.The easiest way to create a new project is executing the command ’File’→’Project’and selecting a wizard.Then you can add?les to the project via the context menu’Add?les’in the Management window.CodeBlocks governs the project ?les in categories according to their?le extensions.These are the preset categories:

Sources includes source?les with the extensions*.c;*.cpp;.

ASM Sources includes source?les with the extensions*.s;*.S;*.ss;*.asm.

Headers includes,among others,?les with the extension*.h;.

Resources includes?les for layout descriptions for wxWidgets windows with the ex-tensions*.res;*.xrc;.These?le types are shown in the’Resources’tab of the Manangement window.

The settings for types and categories of?les can be adjusted via the context menu’Project tree’→’Edit?le types&categories’.Here you can also de?ne custom categories for?le extensions of your own.For example,if you wish to list linker scripts with the*.ld extension in a category called Linkerscript,you only have to create the new category.

CodeBlocks V1.0 1.2Notes for Projects

1.2Notes for Projects

In CodeBlocks,so-called notes can be stored for a project.These notes should contain short descriptions or hints for the corresponding project.By displaying this information during the opening of a project,other users are provided with a quick survey of the project.The display of notes can be switched on or o?in the Notes tab of the Properties of a project.

1.3Project Templates

CodeBlocks is supplied with a variety of project templates which are displayed when creating a new project.However,it is also possible to store custom templates for collect-ing your own speci?cations for compiler switches,the optimisation to be used,machine-speci?c switches etc.in templates.These templates will be stored in the Documents and Settings\\Application Data\codeblocks\UserTemplates directory.If the tem-plates are to be open to all users,they have to be copied to a corresponding directory of the CodeBlocks installation.These templates will then be displayed at the next startup of CodeBlocks under’New’→’Project’→’User templates’.

1.4Create Projects from Build Targets

In projects it is necessary to have di?erent variants of the project available.Variants are called Build Targets.They di?er with respect to their compiler options,debug information and/or choice of?les.A Build Target can also be outsourced to a separate project.To do so,click’Project’→’Properties’,select the variant from the tab’Build Targets’and click the’Create project from target’button(see Figure1.2on page4).

1.5Virtual Targets

Projects can be further structured in CodeBlocks by so-called Virtual Targets.A fre-quently used project structure consists of two Build Targets,one’Debug’Target which contains debug information and one’Release’Target without this information.By adding Virtual Targets via’Project’→’Properties’→’Build Targets’individual Build Targets can be combined.For example,a Virtual Target’All’can create the Targets Debug and Release simultaneously.Virtual Targets are shown in the symbol bar of the compiler under Build Targets.

CodeBlocks V1.0 1.6Pre-and Postbuild steps

Figure1.2:Build Targets

1.6Pre-and Postbuild steps

CodeBlocks makes it possible to perform additional operations before or after compiling a project.These operations are called Prebuilt or Postbuilt Steps.Typical Postbuilt Steps are:

?Creating an Intel Hexformat from a?nished object

?Manipulating objects by objcopy

?Generating dump?les by objdump

Example

Creating a Disassembly from an object under Windows.Piping to a?le requires calling cmd with the/c option.

cmd/c objdump-D name.elf>name.dis

Archiving a project can be another example for a Postbuilt Step.For this purpose,create a Build Target’Archive’and include the following instruction in the Postbuilt Step:

zip-j9$(PROJECT_NAME)_$(TODAY).zip src h obj$(PROJECT_NAME).cbp

With this command,the active project and its sources,header and objects will be packed as a zip?le.In doing so,the Built-in variables$(PROJECT_NAME)and$(TODAY),the project name and the current date will be extracted(see section3.2on page48).After the execution of the Target’Archive’,the packed?le will be stored in the project directory.

CodeBlocks V1.0 1.7Adding Scripts in Build Targets In the share/codeblocks/scripts directory you will?nd some examples for scripts. You can add a script via menu’Settings’→’Scripting’and register in a menu.If you execute e.g.the script make dist from the menu then all?les belonging to a project will be compressed in an archive.tar.gz.

1.7Adding Scripts in Build Targets

CodeBlocks o?ers the possibility of using menu actions in scripts.The script represents another degree of freedom for controlling the generation of your project.

1.8Workspace and Project Dependencies

In CodeBlocks,multiple projects can be open.By saving open projects via’File’→’Save workspace’you can collect them in a single workspace under.workspace.If you open.workspace during the next startup of von CodeBlocks,all projects will show up again.

Complex software systems consist of components which are managed in di?erent Code-Blocks projects.Furthermore,with the generation of such software systems,there are often dependencies between these projects.

Example

A project A contains fundamental functions which are made available to other projects in the form of a library.Now,if the sources of this project are modi?ed,then the library has to be rebuilt.To maintain consistency between a project

B which uses the functions and project A which implements the functions,project B has to depend on project A.The necessary information on the dependencies of projects is stored in the relevant workspace, so that each project can be created separately.The usage of dependencies makes it also possible to control the order in which the projects will be generated.The dependencies for projects can be set via the selecting the menu’Project’→’Properties’and then clicking the’Project’s dependencies’button.

1.9Including Assembler?les

In the Management window of the Project View,Assembler?les are shown in the ASM Sources category.The user can change the listing of?les in categories(see section1.1on page2).Right-clicking one of the listed Assembler?les will open a context menu.Select ’Properties’to open a new window.Now select the’Build’tab and activate the two?elds ’Compile?le’and’Link?le’.Then select the’Advanced’tab and execute the following steps:

1.Set’Compiler variable’to CC

2.Select the compiler under’For this compiler’

3.Select’Use custom command to build this?le’

4.In the window,enter:

$compiler$options$includes-c$file-o$object

The CodeBlocks variables are marked by$(see section3.4on page51).They are set automatically so that you only have to replace the Assembler optionby your own settings.

1.10Editor and Tools

1.10.1Default Code

The company’s Coding Rules require source?les to have a standard design.CodeBlocks makes it possible to include a prede?ned content at the beginning of a?le automatically when creating new C/C++sources and headers.This prede?ned content is called default code.This setting can be selected under’Stettings’→’Editor’Default Code.A new?le can be created via the menu’File’→’New’→’File’.

Example

/************************************************************************* *Project:

*Function:

************************************************************************* *$Author:mario$

*$Name:$

************************************************************************* *

*Copyright2007by company name

*

************************************************************************/

1.10.2Abbreviation

A lot of typing can be saved in CodeBlocks by de?ning abbreviation.This is done by selecting’Settings’→’Editor’and de?ning the abbreviations under the name, which can then be called by the keyboard shortcut Ctrl-J(see Figure1.3on page7).

Parametrisation is also possible by including variables$(NAME)in the abbreviations.

#ifndef$(Guard token)

#define$(Guard token)

#endif//$(Guard token)

When performing the abbreviationin the source text and performing Ctrl-J, the content of the variable is requested and included.

1.10.3Personalities

CodeBlocks settings are saved as application data in a?le called.conf in the codeblocks directory.This con?guration?le contains information such as the last opened

Figure1.3:De?ning abbreviations

projects,settings for the editor,display of symbol bars etc.By default,the’default’per-sonality is set so that the con?guration is stored in the?le default.conf.If CodeBlocks is called from the command line with the parameter--personality=myuser,the set-tings will be stored in the?le myuser.conf.If the pro?le does not exist already,it will automatically be created.This procedure makes it possible to create the corresponding pro?les for di?erent work steps.If you start CodeBlocks from the command line with the additional parameter--personality=ask,a selection box will be displayed for all the

available pro?les.

1.10.4Con?guration Files

The CodeBlocks settings are stored in the default.conf pro?le in the codeblocks direc-

tory of your Application Data.When using personalities(see subsection1.10.3on page6),

the con?guration details will be stored in the.conf?le.

The tool cb share conf,which can be found in the CodeBlocks installation directory,is

used for managing and storing these settings.

If you wish to de?ne standard settings for several users of a computer,the con?guration

?le default.conf has to be stored in the directory\Documents and Settings\Default

User\Application Data\codeblocks.During the?rst startup,CodeBlocks will copy the presettings from’Default User’to the application data of the current users.

To create a portable version of CodeBlocks on a USB stick,proceed as follows.Copy the CodeBlocks installation to a USB stick and store the con?guration?le default.conf in this directory.The con?guration will be used as a global setting.Please take care that the?le is writeable,otherwise changes of the con?guration cannot be stored.

1.10.5Navigate and Search

In CodeBlocks there are di?erent ways of quick navigation between?les and functions. Setting bookmarks is a typical procedure.Via the shortcut Ctrl-B a bookmark is set or deleted in the source?le.Via Alt-PgUp you can jump to the previous bookmark,and via Alt-PgDn you can jump to the next bookmark.

If you select the workspace or a project in the workspace in the project view you will be able to search for a?le in the project.Just select’Find?le’from the context menu,then type the name of the?le and the?le will be selected.If you hit return this?le will be opened in the editor(see Figure1.4on page8).

Figure1.4:Searching for?les

In CodeBlocks you can easily navigate between header/source?les like:

1.Set cursor at the location where a header?le is include and open this?le via the

context menu’open include?le’(see Figure1.5on page9)

2.Swap between header and source via the context menu’Swap header/source’

3.Select e.g.a de?ne in the editor and choose’Find declaration’from the context

menu to open the?le with its declaration.

CodeBlocks o?eres several ways of searching within a?le or directory.The dialogue box for searching is opened via’Search’→’Find’(Ctrl-F)or’Find in Files’(Ctrl-Shift-F). Alt-G and Ctrl-Alt-G are another useful functions.The dialogue which will open on using this shortcut,lets you select?les/functions and then jumps to the implementation of the selected function(see Figure1.6on page9)or opens the selected?le in the editor.You may use wildcards like?or?etc.for an incremental search in the dialog.

Figure1.5:Opening of a header?le

Figure1.6:Search for functions

In the editor,you can switch between the tabs with the open?les via Ctrl-Tab.Alterna-tively you can set’Use Smart Tab-switching scheme’in’Settings’→’Notebook appear-ance’,then Ctrl-Tab will bring up an Open Tabs window in which all the open?les will be listed which can then be selected by mouse-click(see Figure1.7on page10).You can use the shortcut Ctrl-Tab in the management window to switch between the di?erent tabs.

A common procedure when developing software is to struggle with a set of functions which are implemented in di?erent?les.The Browse Tracker plugin will help you solve this problem by showing you the order in which the?les were selected.You can then comfortably navigate the function calls(see section2.7on page32).

The display of line numbers in CodeBlocks can be activated via’Settings’→’General Settings’in the?eld’Show line numbers’.The shortcut Ctrl-G or the menu command ’Search’→’Goto line’will help you jump to the desired line.

Figure1.7:Settings of switching between tabs

1.10.6Symbol view

The CodeBlocks Management window o?ers a tree view for symbols of C/C++sources for navigating via functions or variables.As the scope of this view,you can set the current ?le or project,or the whole workspace.The following categories exist for the symbols:

Figure1.8:Symbol view

Global functions Lists the implementation of global functions.

Global typedefs Lists the use of typedef de?nitions.

Global variables Displays the symbols of global variables.

Preprocessor symbols Lists the pre-processor directives created by#de?ne. Structures and classes are displayed below the pre-processor symbols.If a category is selected by mouse-click,the found symbols will be displayed in the lower part of the window(see Figure1.8on page10).Double-clicking the symbol will open the?le in

which the symbol is de?ned or the function implemented,and jumps to the corresponding line.

1.10.7Including external help?les

The CodeBlocks development environment supports the inclusion of external help?les via the menu’Settings’→’Environment’.Include the manual of your choice in the chm format in’Help Files’select’this is the default help?le’(see Figure1.9on page11). The entry$(keyword)is a placeholder for a select item in your editor.Now you can select a function in an opened source?le in CodeBlocks by mouse-click,and the corresponding documentation will appear while pressing F1.

If you have included multiple help?les,you can select a term in the editor and choose a help?le from the context menu’Locate in’for CodeBlocks to search in.

Figure1.9:Settings for help?les

In CodeBlocks you can add even support for man pages.Just add a entry’man’and specify the path as follows.

man:/usr/share/man

CodeBlocks provides an’Embedded HTML Viewer’,which can be used to display simple html?le and?nd keywords within this?le.Just con?gure the path to the html?le,which should be parsed and enable the checkbox’Open this?le with embedded help viewer’via the menu’Settings’→’Environment’→’Help Files’.

Figure1.10:Embedded HTML Viewer

Including external tools is possible in CodeBlocks via’Tools’→’Con?gure Tools’→’Add’.Built-in variables(see section3.2on page48)can also be accessed for tool parameters. Furthermore there are several kinds of launching options for starting external applica-tions.Depending on the option,the externally started applications are stopped when CodeBlocks is quit.If the applications are to remain open after quitting CodeBlocks,the option’Launch tool visible detached’must be set.

1.11Tips for working with CodeBlocks

In this chapter we will present some useful settings in CodeBlocks.

1.11.1Con?guring environmental variables

The con?guration for an operating system is speci?ed by so-called environmental variables. The environmental variable PATH for example contains the path to an installed compiler. The operating system will process this environmental variable from beginning to end,i.e. the entries at the end will be searched last.If di?erent versions of a compiler or other applications are installed,the following situations can occur:

?An incorrect version of a software is called

?Installed software packages call each other

So it might be the case that di?erent versions of a compilers or other tools are manda-tory for di?erent projects.One possibility in such a case is to change the environmental variables in the system control for every project.However,this procedure is error-prone and not?exible.For this requirement,CodeBlocks o?ers an elegant solution.Di?erent con?gurations of environmental variables can be created which are used only internally in CodeBlocks.Additionally,you can switch between these con?gurations.The Figure1.11 on page13shows the dialogue which you can open via’Environment Varibales’under ’Settings’→’Environment’.A con?guration is created via the’Create’button.

Figure1.11:Environmental variables

Access and scope of the environmental variables created here,is limited to CodeBlocks. You can expand these environmental variables just like other CodeBlocks variables via $(NAME).

Example

You can write the used environment into a postbuild Step(see section1.6on page4)in a?le.env and archive it within your project.

cmd/c echo\%PATH\%>project.env

or under Linux

echo\$PATH>project.env

1.11.2Switching between projects

If several projects or?les are opened at the same time,the user needs a way to switch quickly between the projects or?les.CodeBlocks has a number of shortcuts for such situations.

Alt-F5Activates the previous project from the project view.

Alt-F6Activates the next project from the project view.

F11Switches within the editor between a source?le.cpp and the corresponding header?le.h

1.11.3Extended settings for compilers

During the build process of a project,the compiler messages are displayed in the Messages window in the Build Log tab.If you wish to receive detailed information,the display can be extended.For this purpose click’Settings’→’Compiler and Debugger’and select ’Other Settings’in the drop-down?eld.

Figure1.12:Setting detail information

Take care that the correct compiler is selected.The’Full command line’setting in the Compiler Logging?eld outputs the complete information in the Build Log.In addition, this output can be logged in a HTML?le.For this purpose select’Save build log to HTML ?le when?nished’.Furthermore,CodeBlocks o?ers a progress bar for the build process in the Build Log window which can be activated via the’Display build progress bar’setting.

1.11.4Zooming within the editor

CodeBlocks o?ers a very e?cient editor.This editor allows you to change the size in which the opened text is displayed.If you use a mouse with a wheel,you only need to press the Ctrl key and scroll via the mouse wheel to zoom in and out of the text.

1.11.5Block select mode in editor

CodeBlocks supports the block select mode within the editor.Hold the key’ALT’and select a region with the left mouse button and copy or paste your selection.This feature is helpful if you want to select some columns e.g.of an array and copy and paste the content.

1.11.6Code folding

CodeBlocks supports so called cold folding.With this feature you can fold e.g.functions within the CodeBlocks editor.A folding point is marked by minus symbol in the left margin of the editor view.In the margin the beginning and the end of a folding point is visible as vertical line.If you click the minus symbol with the left mouse button the code snippet will be folded or unfolded.Via the menu’Edit’→’Folding’you can select the folding.In the editor you see folded code as continous horizontal line.

CodeBlocks provides the folding feature also for preprocessor directives.To enable this feature select’Fold preprocessor commands’via the menu’Settings’→’Editor’in the folding entry.

Another possibility is to set user de?ned folding points.The start of folding point is entered as comment with a opening bracket and the end is market with a comment with a closing bracket.

//{

code with user defined folding

//}

1.11.7Auto complete

If you open a open a project in CodeBlocks the’Search directories’of your compiler and the project,the sources and headers of your project are parsed.In addition the keyowrds of the corresponding lexer?le are parsed.The parse information is used for the auto complete feature in CodeBlocks.Please check the settings for the editor if this feature is enabled.The auto completion is accessible with the shortcut Ctrl-Space.Via the menu ’Settings’→’Editor’→’Syntax highlighting’you can add user de?ned keywords to your lexer.

1.11.8Including libraries

In the build options of a project,you can add the used libraries via the’Add’button in the ’Link libraries’entry of the’Linker Settings’.In doing so,you can either use the absolute path to the library or just give the name without the lib pre?x and?le extension.

Example

For a library called\libs\lib.a,just write.The linker with the corresponding search paths will then include the libraries correctly.

1.11.9Object linking order

During compiling,objects name.o are created from the sources name.c/cpp.The linker then binds the individual objects into an application name.exe or for the embedded systems name.elf.In some cases,it might be desirable to prede?ne the order in which the objects will be linked.In CodeBlocks,this can be achieved by assigning priorities.In the context menu’Properties’,you can de?ne the priorities of a?le in the Build tab.A low priority will cause the?le to be linked earlier.

1.11.10Autosave

CodeBlocks o?ers ways of automatically storing projects and source?les,or of creating backup copies.This feature can be activated in the menu’Settings’→’Environment’→’Autosave’.In doing so,’Save to.save?le’should be speci?ed as the method for creating the backup copy.

1.11.11Settings for?le extensions

In CodeBlocks,you can choose between several ways of treating?le extensions.The settings dialogue can be opened via’Settings’→’Files extension handling’.You can either use the applications assigned by Windows for each?le extension(open it with the associated application),or change the setting for each extensions in such a way that either a user-de?ned program will start(launch an external program),or the?le will be opened in the CodeBlocks editor(open it inside Code::Blocks editor).

CodeBlocks V1.0 1.12CodeBlocks at the command line

1.12CodeBlocks at the command line

IDE CodeBlocks can be executed from the command line without a graphic interface.

In such a case,there are several switches available for controlling the build process of a project.Since CodeBlocks is thus scriptable,the creation of executables can be integrated into your own work processes.

codeblocks.exe/na/nd--no-splash-screen--built.cbp--target=’Release’Speci?es the project*.cbp?lename or workspace*.workspace?le-name.For instance,may be project.cbp.Place this argu-

ment at the end of the command line,just before the output redirection

if there is any.

/h,--help Shows a help message regarding the command line arguments.

/na,--no-check-associations

Don’t perform any?le association checks(Windows only).

/nd,--no-dde Don’t start a DDE server(Windows only).

/ns,--no-splash-screen

Hides the splash screen while the application is loading.

/d,--debug-log

Display the debug log of the application.

--prefix=

Sets the shared data directory pre?x.

/p,--personality=,--profile=

Sets the personality to use.You can use ask as the parameter to list

all available personalities.

--rebuild Clean and build the project or workspace.

--build Build the project or workspace.

--target=

Sets target for batch build.For example--target=’Release’.

--no-batch-window-close

Keeps the batch log window visible after the batch build is completed.

--batch-build-notify

Shows a message after the batch build is completed.

--safe-mode All plugins are disabled on startup.

>

Placed in the very last position of the command line,this may be used

to redirect standard output to log?le.This is not a codeblock option

as such,but just a standard DOS/*nix shell output redirection. 1.13Shortcuts

Even if an IDE such as CodeBlocks is mainly handled by mouse,keyboard shortcuts are nevertheless a very helpful way of speeding up and simplifying work processes.In the below table,we have collected some of the available keyboard shortcuts.

1.13.1Editor

Function Shortcut Key

Undo last action Ctrl-Z

Redo last action Ctrl-Shift-Z

Swap header/source F11

Comment highlighted code Ctrl-Shift-C

Uncomment highlighted code Ctrl-Shift-X

Auto-complete/Abbreviations Ctrl-Space/Ctrl-J

Toggle bookmark Ctrl-B

Goto previous bookmark Alt-PgUp

Goto next bookmark Alt-PgDown

This is a list of shortcuts provided by the CodeBlocks editor component.These shortcuts cannot be rebound.

Create or delete a bookmark Ctrl-F2

Go to next bookmark F2

Select to next bookmark Alt-F2

Find selection.Ctrl-F3

Find selection backwards.Ctrl-Shift-F3

Find matching preprocessor conditional,skipping nested ones.Ctrl-K

1.13.2Files

Function Shortcut Key

New?le or project Ctrl-N

Open existing?le or project Ctrl-O

Save current?le Ctrl-S

Save all?les Ctrl-Shift-S

Close current?le Ctrl-F4/Ctrl-W

Close all?les Ctrl-Shift-F4/Ctrl-Shift-W

1.13.3View

Function Shortcut Key Show/hide Messages pane F2

Show/hide Management pane Shift-F2 Activate prior(in Project tree)Alt-F5 Activate next(in Project tree)Alt-F6

1.13.4Search

Function Shortcut Key

Find Ctrl-F

Find next F3

Find previous Shift-F3

Find in?les Crtl-Shift-F

Replace Ctrl-R

Replace in?les Ctrl-Shift-R

Goto line Ctrl-G

Goto?le Alt-G

Goto function Ctrl-Alt-G

1.13.5Build

Function Shortcut Key

Build Ctrl-F9

Compile current?le Ctrl-Shift-F9

Run Ctrl-F10

Build and Run F9

Rebuild Ctrl-F11

CodeBlocks中文版使用手册

C o d e B l o c k s中文版使 用手册 文档编制序号:[KK8UY-LL9IO69-TTO6M3-MTOL89-FTT688]

CodeBlocks中文版使用手册 工欲善其事,必先利其器。一个好的工具能事半功倍。写程序时,特别是写C++程序,大部分人脑子里想到的第一个工具就是VisualStudio。不可否认,VS很好很强大,用户体验非常好。但VisualStudio也是有缺点的:它非常庞大;只支持VC,不支持其他的编译器;VS只能在windows下跑,在其他os上就无用武之地;VS是要钱的,而且费用不非(Express版本免费)。Code::Blocks是一个非常优秀的工具,如果您正在寻找VisualStudio之外的,开源、免费、轻便、支持多种编译器、跨平台的C/C++ IDE,那么Code::Blocks就是一个很好的选择。 1 CodeBlocks项目管理 下图是CodeBlocks运行时的用户界面: 管理(Management):管理窗口包含Project视图与Symbols视图。Project视图显示当前CodeBlocks打开的所有项目(译者注:类似与VS解决方案资源管理器);Symbols视图显示项目中的标识符:类,函数、变量等信息(译者注:类似与VS的类视图)。 代码编辑器:支持代码折叠,关键字高亮显示。上图main.cpp正在被编辑。 打开文件列表:显示当前在代码编辑器中打开的所有文件列表。 上图中打开的文件列表为:main.cpp, person.cpp, person.hpp

代码段(CodeSnippets):管理常用的代码段、常用文件链接(links to files)与URL。可以通过菜单 View->CodeSnippets 来显示该面板。 日志和其他:这个窗口用于输出日志信息,显示查询结果等等。 状态栏提供了以下这些信息: 编辑器中打开文件的绝对路径; 文件的编码类型; 光标所在的行与列; 当前的键盘模式(insert 或者 overwrite); 当前的文件状态。被修改过的(但尚未保存)文件将被标记为“modified”,否则这里为空; 文件操作的权限。如果文件是只读的,这里将会显示“Read only”,在 Open files list中,该文件会使用一个加琐的图标来显示; 个性化配置名称; CodeBlocks提示了非常灵活和强大的项目管理功能。下文将介绍项目管理的一些常用功能。 1.1 项目视图(Project View)

CodeBlocks教程

特别说明目录 封皮..............................................................................................................................0目录 (1) 前言 (2) 1.安装Code::Blocks (3) 1.1下载……………………………………………………………………………………….….…………. .3 1.2安装 (3) 2. Code::Blocks 的编程环境配置 (7) 2.1环境 (7) 2.2编辑器 (12) 2.3编译器和调试器 (13) 3.编写程序 (17) 3.1创建一个工程 (17) 3.2添加和删除文件 (20) 3.3编辑文件 (25) 3.4编译程序 (30) 3.5调试程序 (43) 3.6阅读别人编写的程序 (74) 4.附录 (79) 4.1Linux 下安装Code::Blocks (79) 4.2 Mac OS X 下安装Code::Blocks (80) 4.3 Code::Blocks 搭配高版本gcc 编译器 (80) 4.4安装配置boost (82) ...........................................................................87...................................................................................

前言 用高级计算机语言,例如C、C++,编写的程序,需要经过编译器编译,才能转化成机器能够执行的二进制代码。然而,把头脑中的思想转变成能够正常工作的计算机程序需要付出一定的努力和时间,因为为了让程序能够达到我们想要的结果,我们往往需要反复修改代码。本书的目的是帮助初学者学习组织程序编码逐步隔离并发现程序中的逻辑错误。通过本书,您可以学会怎么一步步的跟踪代码,找到问题出在什么地方,搞明白为何您的程序不能正常运行,这个过程称谓调试程序。手工跟踪能够有效的帮助初学者找到bug出在什么位置,消除bug,让程序正常运行。自动化的工具同样也能够帮助您跟踪程序,尤其当程序很复杂时效果更加明显,这种工具叫做调试器。调试器能够让运行中的程序根据您的需要暂停,查看程序怎么运作的。有些调试器是以命令行的形式工作的,较新的调试器有些具备好的图形界面,调试器能够方便的帮助您看到您定义的变量状态。基于图形界面的调试器是集成开发环境(IDE,即Integrated Development Environment)的一部分。本书的作用就是帮助您学习使用这种环境以便更好的掌握编程技巧。 一个调试器并不能解决您程序中出现的问题,它仅仅是一种帮助您编程的工具。您首先应该运用您手中的纸和笔分析程序,搞清到底怎么回事,一旦确定错误大致出在什么位置,便可以用调试器观察您的程序中特定变量的值。通过观察这些代码,可以了解到您的程序是怎么一步步执行的。 C/C++的IDE非常多,对于学习C/C++语言的朋友而言,用什么IDE可能并不重要,重要的是学习C/C++语言本身,不过,会用一款自己习惯的IDE进行程序的编写和调试确实很方便。 本书主要论述一款开源、免费、跨平台的集成开发环境Code::Blocks的安装、配置、以及程序的调试和编译等。Code::Blocks支持十几种常见的编译器,安装后占用较少的硬盘空间,个性化特性十分丰富,功能十分强大,而且易学易用。我们这里介绍的Code::Blocks集成了C/C++编辑器、编译器、和调试器于一体,使用它可以很方便的编辑、调试和编译C/C++应用程序。Code::Blocks具有很多实用的个性化特性,这里只会简单介绍少数几个常用的特性。 我们希望本书能够帮助您体验编程的乐趣的同时也能帮助您提高调试和编写程序的基本功。 如欲了解更多有关Code::Blocks的信息,请访问Code::Blocks的官方网站https://www.360docs.net/doc/c210972611.html,。

CoeBlocks详细使用手册

3.4.5。每个版本之间的使用可能会有细微的差别。Code::Blocks 手册Version 1.0 感谢CodeBlocks项目组: Anders F. Bjorklund (afb), Biplab Kumar Modak (biplab), Bartomiej wiecki (byo), PaulA. Jimenez (ceniza), Koa Chong Gee (cyberkoa), Daniel Orb (daniel2000), Lieven de Cock(killerbot), Yiannis Mandravellos (mandrav), Mispunt (mispunt), Martin Halle (morten-macy), Jens Lody (jens), Jerome Antoine (dje), Damien Moore (dmoore), Pecan Heber(pecan), Ricardo Garcia (rickg22), Thomas Denk (thomasdenk), tiwag (tiwag) Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation. 1 CodeBlocks项目管理 下图是CodeBlocks运行时的用户界面: 管理(Management):管理窗口包含Project视图与Symbols视图。Project视图显示当前CodeBlocks打开的所有项目(译者注:类似与VS解决方案资源管理器);Symbols视图显示项目中的标识符:类,函数、变量等信息(译者注:类似与VS的类视图)。 代码编辑器:支持代码折叠,关键字高亮显示。上图main.cpp正在被编辑。 打开文件列表:显示当前在代码编辑器中打开的所有文件列表。上图中打开的文件列表为:main.cpp, person.cpp, person.hpp 代码段(CodeSnippets):管理常用的代码段、常用文件链接(links to files)与URL。可以通过菜单View->CodeSnippets 来显示该面板。 日志和其他:这个窗口用于输出日志信息,显示查询结果等等。 状态栏提供了以下这些信息: 编辑器中打开文件的绝对路径; 文件的编码类型; 光标所在的行与列; 当前的键盘模式(insert 或者overwrite); 当前的文件状态。被修改过的(但尚未保存)文件将被标记为“modified”,否则这里为空; 文件操作的权限。如果文件是只读的,这里将会显示“Read only”,在Open files list中,该文件会使用一个加琐的图标来显示; 个性化配置名称; CodeBlocks提示了非常灵活和强大的项目管理功能。下文将介绍项目管理的一些常用功能。 1.1项目视图(Project View) 在CodeBlocks中,Project的源文件(如C/C++的源文件及其对应的头文件)和编译属性设置信息都保存在.cbp文件里。可以通过菜单[File–>Project]启动工程创建向导来创建新的Project,然后通过管理窗口的上下文菜单[Add files](译者注:上下文菜单,指当前窗口中选中目标项目,然后右键显示的菜单)向Project中添加文件。CodeBlocks会自动根据文件的后缀将它们放入不同的类别文件夹中(译者注:这个文件夹是虚拟的,实际并不存在)。下面是默认的分类: Sources:包含源文件,后缀为*.c、*.cpp; ASM Sources:包括汇编源文件,后缀一般为*.s、*.S、*.ss、*.asm; Headers:包括头文件,后缀一般为*.h、*.hpp;

codeblock超级经典教程

Code::Blocks 是一个开放源码的全功能的跨平台C/C++集成开发环境. Code::Blocks是开放源码软件。Code::Blocks由纯粹的C++语言开发完成,它使用了蓍名的图形界面库wxWidgets(2.6.2 unicode)版。对于追求完美的C++程序员,再也不必忍受Eclipse的缓慢,再也不必忍受https://www.360docs.net/doc/c210972611.html,的庞大和高昂的价格。 主要特点Code::Blocks提供了许多工程模板,这包括:控制台应用、DirectX应用、动态连接库、FLTK 应用、GLFW应用、Irrlicht工程、OGRE应用、OpenGL应用、QT应用、SDCC应用、SDL应用、SmartWin

codeblocks-10.05mingw-setup.exe27 May 201074.0 MB BerliOS windows操作系统提供两个版本一个不带编辑器与一个带编辑器(mingw) 一.运行安装程序 3.1 步中,下载得到一个执行的文件,双击后运行,请按照以下说明进行安装。 1选择“Full/完整”安装,以免重要插件没有被安装上。 (图1:选择完整安装) 2安装目标路径,不要带有空格,或者汉字 2这一点并不是Code::Blocks的限制,而是因为mingw32里的一些命令行工具,似乎对长目录或带空格的目录支持有点小问题,我估计汉字目录也会出问题,但没试过。一句话,就装在根目录下的X:\CodeBlocks 即可。比如我是安装在E:\CodeBlocks下。

(图2:安装在根目录下的CodeBlocks子目录) 实现中文界面 实现中文界面,包括两个步骤。最主要的是安装其中文简体语方包。然后是安装今日提示英中双语版文件。前一文件由本站提供改进,后一文件由本站在原英文版上自行提供。 如果您正在使用CodeBlocks,请确保先退出该程序。 3安装中文语言包 首先,请在X:\CodeBlocks\share\CodeBlocks\ 建立一个子文件夹:locale,注意locale 全为小写字母。我对简体汉字的语言包做了较大改进,不过仍然没改完,另外,一些插件在当前版本本来就无法汉化的,所以还有一部分内容是英语的。繁体部分我没有改动。 点击下载d2school版Code::Blocks语言包。 下载后,请解压到前述的locale目录下,则locale目录下,应出现zh_CN和zh_TW两个子目录。重新启动Code::Blocks,点击主菜单的“Settings”,选择“Enviornment”。出现的对话框中,左边选中“View”,右边打勾“Internationalization (needs restart)”,并在后面的复合框中选中“Chinese (Simplified)”。确认退出本对话框。 (图4:设置简体语言包) 本项需要重启Code::Blocks方能起作用,所以请先退出Code::Blocks。

超级详细codeblocks的使用

说明:笔者打算用两篇日志来完成对Code::Blocks手册前二章的编译,分别是:使用篇、插件篇。本文是第一篇:Code::Blocks使用篇。原手册第三章介绍Code::Blocks变量、脚本的使用,第四章介绍如何从源码编译Code::Blocks,这两章内容不是很多,笔者认为对大部分用户帮助不是不大,暂不打算翻译。笔者使用的Code::Block版本是nightly builds,svn6088(可以在这个地址下载:https://www.360docs.net/doc/c210972611.html,/index.php/topic,11875.0.html )。使用的编译器是GCC3.4.5。每个版本之间的使用可能会有细微的差别。因为水平有限,难免出错,欢迎指正! Code::Blocks 手册Version 1.0 感谢CodeBlocks项目组: Anders F. Bjorklund (afb), Biplab Kumar Modak (biplab), Bartomiej wiecki (byo), PaulA. Jimenez (ceniza), Koa Chong Gee (cyberkoa), Daniel Orb (daniel2000), Lieven de Cock(killerbot), Yiannis Mandravellos (mandrav), Mispunt (mispunt), Martin Halle (morten-macy), Jens Lody (jens), Jerome Antoine (dje), Damien Moore (dmoore), Pecan Heber(pecan), Ricardo Garcia (rickg22), Thomas Denk (thomasdenk), tiwag (tiwag) Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation. 1 CodeBlocks项目管理 下图是CodeBlocks运行时的用户界面:

CodeBlocks详细使用手册(免费)

笔者打算用两篇日志来完成对Code::Blocks手册前二章的编译,分别是:使用篇、插件篇。本文是第一篇:Code::Blocks使用篇。原手册第三章介绍Code::Blocks变量、脚本的使用,第四章介绍如何从源码编译Code::Blocks,这两章内容不是很多,笔者认为对大部分用户帮助不是不大,暂不打算翻译。笔者使用的Code::Block版本是nightly builds,svn6088(可以在这个地址下载:https://www.360docs.net/doc/c210972611.html,/index.php/topic,11875.0.html )。使用的编译器是GCC3.4.5。每个版本之间的使用可能会有细微的差别。 Code::Blocks 手册Version 1.0 感谢CodeBlocks项目组: Anders F. Bjorklund (afb), Biplab Kumar Modak (biplab), Bartomiej wiecki (byo), PaulA. Jimenez (ceniza), Koa Chong Gee (cyberkoa), Daniel Orb (daniel2000), Lieven de Cock(killerbot), Yiannis Mandravellos (mandrav), Mispunt (mispunt), Martin Halle (morten-macy), Jens Lody (jens), Jerome Antoine (dje), Damien Moore (dmoore), Pecan Heber(pecan), Ricardo Garcia (rickg22), Thomas Denk (thomasdenk), tiwag (tiwag) Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation. 1 CodeBlocks项目管理 下图是CodeBlocks运行时的用户界面:

CodeBlocks使用方法

CodeBlocks使用方法 1、下载CodeBlocks.rar,并把它解压到当前系统分区中的某一根目录下,比如F:\,注意:不要解压到含有中文或空格的目录中(尤其是不能解压到桌面)! 2、进入“F:\codeblocks”目录,并双击“codeblocks.exe”可执行文件,启动它。 3、现在我们学习如何通过向导创建一个控制台应用,并且直接编译、运行它。 步骤1:Code::Blocks主菜单“文件”→“新建”→“项目…”弹出如下对话框中,开始“Console Application”。 (图1开始“Console Application”向导) 步骤2:如果出现向导的“欢迎界面”,直接点击下一步。 步骤3:出现用于选择语言的对话框,选择“C++”,下一步。 步骤4:出现选择文件夹的对话框,在“项目标题”中输入“HelloWorld”。两单词连写,不包括双引号。本步操作结果将会在“我的文档”中“CodeBlocks Projects”目录下,新建一个名称为“HelloWorld”的目录。 步骤5:出现编译器选项对话框。在“编译器”中选择“GNU GCC Compiler”。其下则默认“Debug”与“Release”两个编译目标都是默认选中的,不必改变,通常我们都需要调试和发行两个版本,就算是一个Hello Word的简单程序。按下“完成”。 步骤6:必要时按下“Shift+F2”,出现“Management”侧边栏,如下图:

(图8项目管理器) 步骤7:双击上图所示的main.cpp,将打开该文件。暂时我们还并不需要修改它。步骤8:主菜单“构建”→“构建”。或者,用热键Ctrl+F9,完成编译。 步骤9:再按Ctrl+F10,运行。(9、10步也可以通过工具栏实现,请读者自行熟悉)。下面是运行结果图: 步骤10:其中“Hello world!”是我们程序的输出。下面的内容是Code::Blocks 为了方便我们调试而增加的内容(本来该程序运行后,就直接退出),包括显示了程序运行用时,以及提示“按任意键退出”。 4、我们需要一款好的IDE,希望它不仅有助于我们学习C++,也应该是我们今后编写C++应用程序时的上好工具。目前我推荐使用Code::Blocks,它除了具备IDE典型的集编辑、编译、调试在一身的功能之外,还具备以下特点。 (1)开源 开源不仅仅意味着免费,它还意味着更好的学习途径。 (2)跨平台 包括Windows、Linux、Mac OS等。 (3)跨编译器 包括gcc/g++、Visual C++、Borland C++、Intel C++等超过20多款编译器。同时它也支持多种语言的编译,包括D语言等(当然,Code::Blocks主要支持C++语言)。 (4)插件式框架 Code::Blocks采用开放体系,有着良好的功能扩展能力。 (5)采用C++写成 无须安装额外的,往往是庞大的运行环境。再者,一款C++的IDE采用C++写成,这是最自然不过的事了。 (6)升级频繁与维护良好 差不多每个月都有升级包,有时甚至数天就有新的升级包可供下载。另外其官方论坛也相对活跃,除了提出BUG以外,来自世界各地热心维护者往往第一时间提供不同操作系统上的安装包。 (7)内嵌可视化GUI设计 IDE的图形界面,采用wxWidgets,同时也支持使用wxWidgets进行可视化图形界面设计。

在CodeBlocks中建立多文件项目的方法

在CodeBlocks10.05中建立C语言多文件项目的方法 1.点击文件(F)-新建-项目…菜单命令,进入如下界面: 图1新建项目对话框 2.选择Console application(控制台应用程序),然后单击“出发”按钮,进入Console application向导: 图2控制台应用程序向导之一图3控制台应用程序向导之二 3.单击“下一步”,选择使用语言为:C,进入“下一步”,输入“项目标题”及“项目所在的父文件夹”等信息;

图4控制台应用程序向导之三图5控制台应用程序向导之四4.单击“下一步”,设置编译配置如下: 图6控制台应用程序向导之五 5.单击“完成”,进入编辑界面。 图7编辑界面

6.修改编辑main.c文件即可。也可用“新建-文件”菜单新建多个C/C++source文件添加到这个项目中。 图8新建C语言源程序向导 可用下面三个文件测试: /*main.c*/ #include #include extern int a; int m=30; void funA(void); void funB(void); int main(void) { funA(); funB(); printf("Hello!Running main()Now!\n"); printf("a=%d m=%d in main()\n",a,m); return0; }

/*f1.c*/ void funB(void) { int b=20; printf("Hello!Running funB()Now!\n"); printf("b=%d in funB()\n",b); return; } /*f2.c*/ #include extern int m; int a=50; void funA(void) { printf("Hello!Running funA()Now!\n"); printf("a=%d m=%d in funA()\n",a,m); return; } 7.编译构建与单文件类似,不再重述。

codeblock使用方法

C++集成设计环境——Code::Blocks 安 装 1.版本说明 先简要说明一下Code::Blocks的版本号。 Code::Blocks采用两种方法的版本命名,这一点大家需要了解,以免搞胡涂了。 对于正式版,Code::Blocks采用“年份.月份”的方法。Code::Blocks至本文发表时,只出过一个正式版,是2008年2月出来的,所以这个正式版的版本号为:8.02。 对于非正式版,Code::Blocks采用其源代码管理工具svn的代码版本号。它是一个整数。 2.安装主要步骤 当前,要成功完成安装Code::Blocks,需要以下几个步骤: ?安装Code::Blocks第一个正式版本 ver 8.02。 ?安装Code::Blocks的最新升级包。 ?安装Code::Blocks的简体中文语言包。 ?完成Code::Blocks的基本配置。 刚一看似乎很复杂,其实不然。 另外,本文仅讲解如何在windows下安装。 3.安装正式发行版 Code::Blocks 的第一个正式发行版 8.02 (2008年2月发行) 是必须的。升级包必须在发行版安装后,才能安装。 3.1 下载正式版安装程序。 为了方便各位,大家可以直接用以下链接进行下载,可以使用相关下载专用软件以加快下载。 http://download.berlios.de/codeblocks/codeblocks-8.02mingw-setup.exe 或者http://download2.berlios.de/codeblocks/codeblocks-8.02mingw-setup.exe

3.2 卸载mingw32原有安装 根据实际情况,本步您可能并不需要执行。 Code::Blocks支持多种编译器,但我们主要讲Windows下的mingw32 g++编译器。因此需要安装mingw32。前面下载的安装程序已经自带有完整的mingw32环境。mingw32是g++环境在windows下的一个实现。为了避免版本与路径冲突,最好不要在一台机器上安装两个mingw32。所以本步要求检查一下。如果您以前有用过Dev C++之类也采用mingw32的IDE,那您最好先卸载了它们。如果您不懂什么叫mingw32,那估计你的机器就是没能安装过吧。那这一步跳过。 3.3 运行安装程序 3.1 步中,下载得到一个执行的文件,双击后运行,请按照以下说明进行安装。 3.3.1 选择“Full/完整”安装,以免重要插件没有被安装上。 (图1:选择完整安装) 3.3.2 安装目标路径,不要带有空格,或者汉字 这一点并不是Code::Blocks的限制,而是因为mingw32里的一些命令行工具,似乎对长目录或带空格的目录支持有点小问题,我估计汉字目录也会出问题,但没试过。一句话,就装在根目录下的 X:\CodeBlocks即可。比如我是安装在E:\CodeBlocks下。 (图2:安装在根目录下的CodeBlocks子目录) 4.安装升级包 Code::blocks的网站看不去不怎么更新,其实程序的主要都在它的论坛中的nightly builds子论坛中更新。 4.1 下载最新升级包

CodeBlocks详细使用手册

Code::Blocks使用手册 Code::Blocks手册前二章的编译,分别是: 使用篇、插件篇。 本文是第一篇:Code::Blocks使用篇。 原手册第三章介绍Code::Blocks变量、脚本的使用, 第四章介绍如何从源码编译Code::Blocks,这两章内容不是很多, 笔者认为对大部分用户帮助不是不大,暂不打算翻译。 笔者使用的Code::Block版本是nightly builds,svn6088 使用的编译器是GCC3.4.5。每个版本之间的使用可能会有细微的差别。 Code::Blocks 手册Version 1.0 感谢CodeBlocks项目组: Anders F. Bjorklund (afb), Biplab Kumar Modak (biplab), Bartomiej wiecki (byo), PaulA. Jimenez (ceniza), Koa Chong Gee (cyberkoa), Daniel Orb (daniel2000), Lieven de Cock(killerbot), Yiannis Mandravellos (mandrav), Mispunt (mispunt), Martin Halle (morten-macy), Jens Lody (jens), Jerome Antoine (dje), Damien Moore (dmoore), Pecan Heber(pecan), Ricardo Garcia (rickg22), Thomas Denk (thomasdenk), tiwag (tiwag) Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation. 1 CodeBlocks项目管理 下图是CodeBlocks运行时的用户界面:

使用Codeblocks创建OpenGL工程

Using OpenGL & GLUT in Code::Blocks Download Code::Blocks https://www.360docs.net/doc/c210972611.html,/~goetz/codeblocks/ Download the GLUT bin file (first download link) from: https://www.360docs.net/doc/c210972611.html,/~nate/glut.html ?After you download and open the GLUT bin zip file, you will need to: ?Copy glut32.dll to c:\windows\system, ?Copy glut32.lib to c:\program files\mingw\lib, and ?Copy glut.h to c:\program files\mingw\include\GL. ?These are default locations, your paths may be different. But basically, you place the .lib and .h files in the location of your compiler (in this case mingw). The .dll file goes in the windows system directory. Now you are ready to start Code::Blocks and make a new project. Open up Code::Blocks. Start a new Project by going to File, New, Project.

codeblock用法

来源:https://www.360docs.net/doc/c210972611.html,/JGood/archive/2010/01/25/5252119.aspx 原手册下载:https://www.360docs.net/doc/c210972611.html,/docs/manual_en.pdf 译者:JGood(https://www.360docs.net/doc/c210972611.html,/Jgood ) 译者言:工欲善其事,必先利其器。一个好的工具能事半功倍。写程序时,特别是写C++程序,大部分人脑子里想到的第一个工具就是VisualStudio。不可否认,VS很好很强大,用户体验非常好。但VisualStu dio也是有缺点的:它非常庞大;只支持VC,不支持其他的编译器;VS只能在windows下跑,在其他os 上就无用武之地;VS是要钱的,而且费用不非(Express版本免费)。Code::Blocks是一个非常优秀的工具,如果您正在寻找VisualStudio之外的,开源、免费、轻便、支持多种编译器、跨平台的C/C++ IDE,那么Code::Blocks就是一个很好的选择。 说明:笔者打算用两篇日志来完成对Code::Blocks手册前二章的编译,分别是:使用篇、插件篇。本文是第一篇:Code::Blocks使用篇。原手册第三章介绍Code::Blocks变量、脚本的使用,第四章介绍如何从源码编译Code::Blocks,这两章内容不是很多,笔者认为对大部分用户帮助不是不大,暂不打算翻译。笔者使用的Code::Block版本是nightly builds,svn6088(可以在这个地址下载:http://forums.codeblo https://www.360docs.net/doc/c210972611.html,/index.php/topic,11875.0.html)。使用的编译器是GCC3.4.5。每个版本之间的使用可能会有细微的差别。因为水平有限,难免出错,欢迎指正!

codeblock使用手册

1 CodeBlocks项目管理 下图是CodeBlocks运行时的用户界面: ?管理(Management):管理窗口包含Project视图与Symbols视图。Project 视图显示当前CodeBlocks打开的所有项目(译者注:类似与VS解决方案资源管理器);Symbols视图显示项目中的标识符:类,函数、变量等信息(译者注:类似与VS的类视图)。 ?代码编辑器:支持代码折叠,关键字高亮显示。上图main.cpp正在被编辑。 ?打开文件列表:显示当前在代码编辑器中打开的所有文件列表。上图中打开的文件列表为:main.cpp, person.cpp, person.hpp ?代码段(CodeSnippets):管理常用的代码段、常用文件链接(links to files)与URL。可以通过菜单View->CodeSnippets 来显示该面板。 ?日志和其他:这个窗口用于输出日志信息,显示查询结果等等。 ?状态栏提供了以下这些信息: ?编辑器中打开文件的绝对路径; ?文件的编码类型;

?光标所在的行与列; ?当前的键盘模式(insert 或者overwrite); ?当前的文件状态。被修改过的(但尚未保存)文件将被标记为“modified”,否则这里为空; ?文件操作的权限。如果文件是只读的,这里将会显示“Read only”,在Open files list中,该文件会使用一个加琐的图标来显示; ?个性化配置名称; CodeBlocks提示了非常灵活和强大的项目管理功能。下文将介绍项目管理的一些常用功能。 1.1 项目视图(Project View) 在CodeBlocks中,Project的源文件(如C/C++的源文件及其对应的头文件)和编译属性设置信息都保存在.cbp文件里。可以通过菜单[File–>Project]启动工程创建向导来创建新的Project,然后通过管理窗口的上下文菜单[Add files](译者注:上下文菜单,指当前窗口中选中目标项目,然后右键显示的菜单)向Project 中添加文件。CodeBlocks会自动根据文件的后缀将它们放入不同的类别文件夹中(译者注:这个文件夹是虚拟的,实际并不存在)。下面是默认的分类: ?Sources:包含源文件,后缀为*.c、*.cpp; ?ASM Sources:包括汇编源文件,后缀一般为*.s、*.S、*.ss、*.asm; ?Headers:包括头文件,后缀一般为*.h、*.hpp;

CodeBlocks用法总汇

说明: 1)以下需要设置的地方均在Settings->Editor...弹出的对话框中。 2)不少命令都可针对当前行或选中的代码块,下文简称当前行或选中块。 ==日常编辑== ?按住Ctrl滚滚轮,代码的字体会随你心意变大变小,对保护视力特别有好处。 ?在编辑区按住右键可拖动代码,省去拉(尤其是横向)滚动条之麻烦;相关设置:Mouse Drag Scrolling。 ? Ctrl+D可复制当前行或选中块。 ? Ctrl+Shift+C注释掉当前行或选中块,Ctrl+Shift+X则解除注释。 ? Tab缩进当前行或选中块,Shift+Tab减少缩进。 ?可拖动选中块使其移动到新位置,按住Ctrl则为复制到新位置。 ?按下Atl,再拖动鼠标,可以实现部分选择(即只选中一个区域内的字符,而不会包含它们所在行的其他字符)。 ?需要更大编辑空间时,F2和Shift+F2分别可以显隐下方Logs & others栏和左方的Management栏。 ==自动完成与缩写== 1)优化代码自动完成功能:在Code-completion and symbol browser中,?将Automatically launch when typed # letter中的4改成2,这样打两个字母就会有提示了。 ?将Keyword sets to additionally include中1到9都勾上(可在Syntax highlighting 的keywords...中设置,其中1是C++关键字,3是Doxygen关键字;我曾将wxWidgets的类名都加入7并设置相应的字体(粗黑体),看代码时特别爽)?将Delay for auto-kick-in when typing [.::->]拉到 200ms,这样快点出来提示?选中Case-sensitive match,防止一些无关的东西干扰,如果你想它帮你纠正大小写,那就去掉勾 ?在Keyboard short-cuts中将Edit->Code complete的快捷键由Ctrl+Space改为 Alt+/,因为前者与中文输入法切换冲突,该快捷键为已经输入的(不是正在输入的)词提供自动完成。 2)看Abbreviation一栏,里面定义了许多缩写(还可以自定义),只要输入这些缩写,并

codeblocks+编程使用手册

CODEBLOCKS快速上手教程 你是不是在想某一天IAR不再让XX的时候我该怎么办呢? KEIL也不行! (本人已不用KEIL很久了,现在用SDCC) 你不是认为开源.LINUX都是牛人玩的?是不是也想成为牛人!而不是用开源的东西仅仅是因为他不要钱? 是不是想哪一天也能为开源奉献点力量? 而这一切的开头都得你起码得会用这些软件吧! 一次和朋友聊天的时候朋友给我推荐了CODEBLOCKS! 于是下载下来!天啦,英文! 不会,丢一边,这一放就是一年 不过当时记得里面有个AVR的! 一年后,也就是前几天,买了块AVR学习板的PCB,是初版,上面BUG好多!还好本人焊接还可以,不成问题! 然后开始对开发软件选型! 一打听太多了 BASIC(不喜欢没理由! XX掉) IAR(用不起!虽然目前不是专门搞这个的,随便用用没问题,但如果这么想那么以后永远都只是随便搞搞) Codevision(听说还可以!不过没用过,) GCC FOR AVR(也就是WINAVR GCC可是大名鼎鼎呀,以后也想玩玩LINUX,那就是他了) 于是安装了AVR STUDIO 并安装了WINAVR 发现写代码的时候没提示,不爽! 于是代码还是用我一直喜欢的C_FREE来写 但是再换回到AVR STUDIO里编译的时候要等一秒AVR STUDIO才会提示文件已被更新 看来这样子不行,太没效率了! 这时候想起了一年前见过的CODEBLOCKS! 试试先 于是在电脑找了半天没找着,只要搜索了一下才发现,忽然发现这已是一年前的版本 于是在其发布网站下载了一个新版! 好了,我们先下载并安装好这次需要的!下载地址: CodeBlocks:https://www.360docs.net/doc/c210972611.html,/ WINAVR:https://www.360docs.net/doc/c210972611.html,/ 安装好! 首先要新建一个工程!

codeblocks安装和使用(精编文档).doc

【最新整理,下载后即可编辑】 以下是我个人使用CodeBlocks的小结,希望对大伙有所帮助。 这是C::B的一个安装和首次使用的一些配制过程: 先看效果图(好看了很多?倒不是,只不过因为我是在win7下……).

一、下载安装包: 如果您有安装以前版本,并不需要卸载。 Windows安装下载页面:https://www.360docs.net/doc/c210972611.html,/downloads/26 请点击图中所示的链接: 点击进入下载页面 这个链接带有新版的MinGW gcc编译环境,但并不是(mingw)官方版本,而是TDM gcc 4.4.1 版本。如果您想另行安排,比如您只想用VC的编译器,可以下载上图中另一个链接。

二、 安装过程: (1) 选择定制安装:Full (2) 选择全部安装: 不然,可能 类似 CppCheck 的插件,就会找不到... (3) 修改安装路径: 这不是Code::Blocks 的错,而是 mingw gcc 的链接器 ln.exe 有个BUG ,不能链接位于带空格或汉字路径下的文件。 接下来的步骤和其它软件的安装就差不多了。 三、 为编译器配制编译环境: (1)、运行Code::Blocks ,第一次运行会弹出选择编译器,请选中gcc 编译器(一般情况下是第一项)。 定制安装 全部选中

(2)、在进入主菜单后,选择Settings->compiler and debugger… 1)、在弹出的对话框中最顶区域(第一项)选择GUN gcc compiler(通常是默认的) 2)、在第二项中找到Tookchain executables选项(如图所示): 01、编译器路径是编译器安装时的安装路径。 02、选择相应的编译器: 输入编译器所在路径 选择相应的编译器 03、在同一界面下,左边切换到最后一项“Debugger setting” 在第一项输入框中输入handle SIGTRA pnoprint

Codeblocks使用教程

CodeBlocks使用教程 Make by ECJTU_ACM,2012-12-17 一、简介 (1) 二、下载 (2) 三、安装 (4) 四、第一次启动 (7) 五、新建CPP文件 (9) 六、代码风格 (12) 一、简介 https://www.360docs.net/doc/c210972611.html,/ ACM的现场比赛环境是Linux Ubuntu(全英文环境),可以使用的集成开发环境(IDE)是CodeBlocks。 强烈不推荐用VC6.0,除非你是要用MFC之类的,不过VS2012必须比VC强吧,我对微软的东西不大熟,VS对ACM而言也不是很标准。 Dev C++是初学者用的,用过一段时间后要换成CodeBlocks,对自己养成良好的编程习惯有很好的帮助,不管以后是搞ACM还是其他,计算机相关专业的学生在编写代码方面应该学习渐渐靠近标准才是。 IDE用英文原版的好,逐渐熟悉英文也是必要的,不管以后是否搞ACM。 以下是百度百科的介绍: Code::Blocks 是一个开放源码的全功能的跨平台C/C++集成开发环境。Code::Blocks是开放源码软件。Code::Blocks由纯粹的C++语言开发完成,它使用了蓍名的图形界面库wxWidgets(2.6.2 unicode)版。对于追求完美的C++程序员,再也不必忍受Eclipse的缓慢,再也不必忍受https://www.360docs.net/doc/c210972611.html,的庞大和高昂的价格。

二、下载 可以下载二进制码包(binary release),也即我们在Windows下的.exe文件安装包。点击: 出现新的页面: 大部分的同学应该是使用Windows系统,所以点第一个。 页面跳到下面的位置:

相关主题
相关文档
最新文档