Configuration of NetBeans under C + +

Source: Internet
Author: User
Tags netbeans

Catalogue

Catalogue 1

1 NetBeans development environment Building 2

2 NetBeans project management 2

2.1 uses IDE automatically generate Makefile 2

3 NetBeans Engineering configuration 2

3.1 compiling tool chain 3

3.1.1 Adding configuration Items 3

3.1.2 Setting the cross-compilation tool 3

3.2 header files, link libraries, precompiled macros 4

3.2.1 Header file path 4

3.2.2 Link Library 5

3.2.3 Pre-compiled macros 6

3.2.4 Specify the path and name of the output file 6

3.3 Other practical settings 6

3.3.1 Choosing a programming language standard 6

3.3.2 Adding commands to execute before and after compilation 6

3.3.3 Modifying font size 7

3.3.4 Record compilation number 7

3.3.5 Automatic Formatting Alignment 8

4 compiling the build link library 9

5 remote Debugging Ten

5.1 Gdbserver Debug Tool installation 10

5.2 NetBeans Remote Debugging Settings 11

Appendix One

Common shortcut keys One

1 NetBeans development environment Building

Official website:https://netbeans.org/

Select the version you want (C + +, Linux) to download and run the *.sh file directly, then follow the graphical interface to prompt for the next step.

2 NetBeans project management 2.1 uses IDE automatically generate Makefile

Create the embedded engineering main configuration cross-compilation toolchain, this article to create C Language Engineering for example.

(1) New Project

New C Speech project:file->new project->c/c++-C-Applicatin->next

Enter the project name and click Finish.

3 NetBeans Engineering configuration

It is often necessary to set up information such as compilation tools, user header files, link libraries, and so on.

3.1 compiling tool chain 3.1.1Add a configuration item

In embedded programming, it is often necessary to run through the host compiler before cross-compiling to the target board. It is best to use two configuration items, one for host Linux and the other for embedded linux . Here's how:

properties-> build->manage configuurations->new Enter the name point OK .

3.1.2set up the cross-compilation tool

3.2 header files, link libraries, precompiled macros

The header files and link libraries that are built into the tool chain are automatically configured when the tool chain is added, but the custom header files and the link libraries used in the program need to be configured.

3.2.1header file Path

3.2.2link library

To add a link library name configuration: Enter the link library name (remove lib and . *), such as libmsc.so input msc . All compile-time need to link non-standard library to add, such as: line libraries pthread.

3.2.3Pre-compiled macros

properties-> build-> C compiler->preprocessor Definitions

3.2.4specify the path and name of the output file

Properties-> build-> Linker->output

3.3 Other practical settings 3.3.1choosing a standard for a programming language

C + + Setup method: properties-> build-> C + + compiler->c++ standard Select C + + click OK.

3.3.2add commands to execute before and after compilation

This feature is very useful for individuals, and by adding commands, it is possible to copy the output files to a specified directory after compiling, and to perform functions such as static code checking tools.

Configuration method:(note: Before the command to add two tab, so that the keyword color to run)

in the The Files view opens the Makefile file directly.

After the. Build-pre: Add the command executed before compiling.

After the. Build-post: Add a command to execute after compiling.

3.3.3Modify Font Size

Methods:tools–> Options->fonts & Colors

3.3.4Record compilation number

properties-> build->c C->cross GCC linker->miscellaneous->link Flags

in the Additional options fill in the content:

-xlinker--defsym-xlinker build_version=$$ (cat $ (build_number_file))

Build_version is the variable name, and Build_number_file is the record variable worth the file name.

the command executed before compiling (causes the The value in the Build_number_file file plus 1):

@if test "${conf}" = "Debugarm"; Then \

RM ${cnd_builddir}/${conf}/${cnd_platform_${conf}}/rtklite.o; \

if! Test-f $ (build_number_file); Then echo 0 > $ (build_number_file); else \

Echo $$ (($$ (cat $ (build_number_file) + 1)) > $ (build_number_file); \

FH =

Fi;\

if test "${conf}" = "Debug"; Then \

RM ${cnd_builddir}/${conf}/${cnd_platform_${conf}}/rtklite.o; \

if! Test-f $ (build_number_file); Then echo 0 > $ (build_number_file); else \

Echo $$ (($$ (cat $ (build_number_file) + 1)) > $ (build_number_file); \

FI \

Fi;\

To invoke a variable in a program:

extern int build_version;

printf ("%d", (int) (&build_version));

3.3.5Automatic Formatting Alignment

Select Code Press the shortcut key: alt+shift+f

Custom rules:

tools–> options–> editor–> formatting–> manage–>new new configuration item.

Braces Placement->function Declaration->next Line (to modify the opening brace of a function)

4 compiling the build link library

It is recommended that you create a new configuration item to compile the link library separately.

The link library must not have the main function, so the main function of the file can not be compiled together, just need to use the source files compiled.

1. exclude files that you do not need to compile

in the Projects the source files in the view , select the file that does not need to compile, right- click properties->general->exclued from Build make a tick.

2. Set compilation

Properties->build->configuration Type Select dynamic Library(dynamically linked library), or you can select Static library (statically linked libraries). If you choose, you can compile the project directly.

5 remote Debugging

remote debugging is on the host control debug target board running program, there are two main serial port and network connection mode, this article is introduced through the network ( TCP) In a way that is remotely debugged. debugging requires the use of gdb tools, so cross-compiling gets the Gdbserver tool running on the target board and gdb running on the corresponding host Client.

5.1 GdbserverDebugging Tool Installation

:http://www.gnu.org/software/gdb/download/

making the gdbserver of the target board

$CD gdb/gdbserver/ (enter gdb-7.10/gdb/gdbserver/)

$./configure--target=arm-arago-linux-gnueabi--host=arm-arago-linux-gnueabi

$make

After compiling, the Gdbserver file is output in the current directory , and the gdbserver copy to the target board is run.

The output of the following information indicates the completion of the GDB tool:

$./gdbserver

Usage:gdbserver [OPTIONS] COMM PROG [ARGS ...]

Gdbserver [OPTIONS]--attach COMM PID

Gdbserver [OPTIONS]--multi COMM

...............................

5.2 NetbeansRemote Debugging Settings

Find gdbservion in the Plugins of the NetBeans website to download the plugin.

1.Netbeans Install plugin:

Tools->plugins->downloaded->add Plugins(select plugin)->install

2. Running Remote Debugging

run Gdbserver on the target board first

$./gdbserver 192.168.5.1:1234 demo run gdbserver,demo for debug Application

Process test created; PID = 1032 Output The following message indicates a successful run

Listening on port 1234

After the connection is successful:

[Email protected]/root]#./gdbserver 192.168.5.1:1234 Demo

Process demo created; PID = 1032

Listening on port 1234

Remote Debugging from Host 192.168.5.100

Appendix Common shortcut keys

To View and customize shortcut keys: Tools->options->keymap

format (auto-align): Alt+shift+f
Comment / uncomment:ctrl+/
To Display the Search dialog box: Ctrl+h
Undo :Ctrl + Z
Save: Ctrl+s
Save All: Ctrl+shift+s

jumps to the specified line: Ctrl + G

Collapse All code blocks : ctrl-shift+ on the numeric keypad -
Expand All code blocks : ctrl-shift+ + on the numeric keypad

Configuration of NetBeans under C + +

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.