LinuxC ++: Linux general technology-Linux programming and kernel information. For more information, see the following section. Problem:
In linux, does C ++ use a standard C ++ library?
In linux, the standard C ++ library is used.
Appendix: The C ++ compiler used in Suse linux is g ++ (gcc)
The C ++ compiler used by IBM_AIX Unix is cc.
The C ++ compiler used by Sun Unix is CC.
Is C ++ an API written in C language called by the system in linux?
The API written in C language is useless !~! The database has been changed. C ++ is compatible with C, and the database is no exception.
Is there a basic library similar to MFC in linux?
This class library does not exist in linux!
If 1 and 2 are positive and 3 are negative in the above three questions, I personally think VC and MFC do not need to be read! If linux/unix does not use middleware (similar to the MFC stuff) or some APIs, such as SQLAPI, it is generally pure C/C ++ programming.
Start:
1. compile C-"Hello world !"
# Include
Void main ()
{
Printf ("Hello, world! \ N ");
}
The disk is saved as hello. c.
Enter g ++ hello. c-o hello (case sensitive) in the command line)
Run./hello
Hello world!
2. compile C ++-"Hello world !"
# Include
Using namespace std;
Int main ()
{
Cout <"Hello world !" <Endl;
Return 0;
}
Compile the C ++ program with g ++
G ++ hello. cpp-o hello
3. Compilation class
There are three files: Hello. h, Hello. cpp, and MyFirst. cpp. The content is as follows:
File: // Hello. h
# Ifndef HelloH
# Define HelloH
Class Hello
{
Hello ();
Void Display ();
}
File: // Hello. cpp
# Include "Hello. h"
# Include
Hello: Hello ()
{
}
Hello: Display ()
{
Cout <"Hello world !" <Endl;
}
File: // MyFirst. cpp
# Include
# Include "Hello. cpp"
Int main ()
{
Hello theHello;
TheHello-> Display ();
Return 0;
}
Compile: g ++ MyFirst. cpp-o MyFirst
4. Multi-file compilation links
Gcc has the-c parameter and can only compile without Link
Therefore, the above program can be compiled in the following order
G ++-c hello. cpp-o hello. o
G ++-c MyFirst. cpp-o MyFirst. o
G ++ MyFirst. o hello. o-o MyFirst
Of course, there are simpler methods: g ++ hello. cpp MyFirst. cpp-o MyFirst. cpp
A project usually has hundreds of source programs, so the connection will be exhausted,
You can write the above compilation process as a text file
Makefile in Linux
# File description
MyFirst: MyFirst. o hello. o
G ++ MyFirst. o hello. o-o MyFirst
Hello. o: hello. cpp
G ++-c hello. cpp-o hello. o
MyFirst. o: MyFirst. cpp
G ++-c MyFirst. cpp-o MyFirst. o
Save disk as MyFirst
In command mode: make MyFirst
2. debugging
Gdb./file name
The following are the commands that may be used in debugging (you can enter only the first character, for example, break is abbreviated as B ).
Indicates
List <show source code>
Break row number <set breakpoint>
Run <running program>
Continue <continue running from the breakpoint>
Print variable <view the variable value during debugging>
Del row number <Delete breakpoint>
Step <one-step execution, which can be tracked inside the function>
Next <one-step execution, not tracked inside the function>
Quit <exit>
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.