In Linux programming, enter the command in the terminal and press enter to create the program.

Source: Internet
Author: User

Do you want to know the truth about the Linux Programming System? Do you want to know what is inherent in the Linux programming system? I am the only one who will give you a full introduction to the Linux programming system today, after reading the "GCC usage and Development" section in "Linux System Application and Development tutorial", it is not a short time for you to get started with Linux programming, but there are still few things that really understand Linux programming, now let's play with Linux programming.

The official version of Fedora 7.0 installed two days before Linux programming. After the system is started, a new empty file helloworld is created. c. The simplest program code used by beginners. Although I have been learning C for more than two years, ^_^)

 
 
  1. #include<stdio.h> 
  2. void main()  
  3. {printf("Hello World!"n");} 

After saving the program in Linux, enter the command "gcc helloworld. c-o helloworld ", press enter immediately, and think that your first Linux programming program will be born. Oh, My god, Which of the following is an error message, the main function does not return int type, but the above Code is feasible in VC. No way, change

 
 
  1. #include<stdio.h> 
  2. int main()  
  3. {  
  4. printf("Hello World!"n");  
  5. return 0;  

Run the command again to generate the command. There is no prompt this time. The command is successful. Haha ~~~ Run your first Linux programming program and check the result. Enter "helloworld" in the terminal.

Clearly the program is in the current directory. After reading a book, I finally found that the command "./helloworld" needs to be written in this way. Press enter and finally print "Hello World !" . Although I have been writing programs for nearly three years, I have printed "Hello World!" on Linux programming !" Still in trouble, this is the reason for not doing it.

Next, write an interesting form program, use GTK + in the book, and change the helloworld. c code

 
 
  1. #include<gtk/gtk.h> 
  2. void on_btn_clicked(GtkWidget *widget, gpointer data)  
  3. {  
  4. g_print("Hello World!"n");  
  5. }  
  6. void on_delete(GtkWidget *widget, GdkEvent *event, gpointer data)  
  7. {  
  8. g_print("Window Closed."n");  
  9. gtk_main_quit();  
  10. }  
  11. int main(int argc, char *argv[])  
  12. {  
  13. GtkWidget *window;  
  14. GtkWidget *button;  
  15. gtk_set_locale();  
  16. gtk_init(&argc, &argv);  
  17. window = gtk_window_new(GTK_WINDOW_TOPLEVEL);  
  18. gtk_container_set_border_width(GTK_CONTAINER(window), 10);  
  19. g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(on_delete), NULL);  
  20. button = gtk_button_new_with_label("Hello World");  
  21. g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(on_btn_clicked), NULL);  
  22. gtk_container_add(GTK_CONTAINER(window), button);  
  23. gtk_widget_show_all(window);  
  24. gtk_main();  
  25. return 0;  
  26. }  
  27.  

It's all such a long function name, and there are so many underscores. After reading it, I finally typed two wrong words, which was prompted during compilation. After coding, follow the command "gcc helloworld. c-o helloworld 'pkg-config gtk +-2.0 -- cflags -- libs'" in the book '".

After you press enter, the system prompts "pkg-config gtk +-2.0 -- cflags -- libs, the book says that you can enter "pkg-config gtk +-2.0 -- cflags -- libs" to check its output results. Enter a carriage return and a bunch of characters. I don't know what to use. Try the above compilation command again, or the same error. Why?

Is there an incorrect typographical command in the book? Open Firefox right away, Baidu. I can see that the commands used by others are a little different from those I typed, that is, the single quotes. I typed regular single quotes in English, how strange is it when someone else uses a "single quotation mark" on the right? The book also uses a pair of reverse single quotes.

In Linux programming, I can't find any input with single quotation marks, so I can Copy it from someone else and change it to "gcc helloworld. c-o helloworld 'pkg-config gtk +-2.0 -- cflags -- libs' ", copy the command to the terminal, press enter, wait for a while, and there will be no final result at all, success!

~~~ What is the reverse single quotes? I tried the keyboard and couldn't find any reverse single quotes. Forget it. Run the first Linux programming form program and enter ". /helloworld ", press enter, haha, the form is coming out, there is only one ugly button, a very small form, almost cannot find where it appears, it is more strange to maximize, because that button is also getting bigger, haha ~~~

This is the first Linux programming failure! Restart Windows 2003 and write this article ...... Oh, by the way, the single quotation mark in reverse direction was shown to me at this time. It was a very rare symbol and also on a very few buttons, that is, the one under the Esc key in the upper left corner of the keyboard, this is called reverse single quotes. Haha ~~~~)

  1. A comprehensive introduction to GNU/Linux Programming Concepts
  2. Introduction to the Linux Makefile Environment
  3. Fedora Linux partition planning is still handy
  4. Linux File dns settings vi usage tips
  5. Modify host name and IP settings in Linux

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.