gcc generate .o file instead of executable

18,114

Remove the -c option from the commandline (which generates the object file instead of executable).

From man gcc:

-c
Compile or assemble the source files, but do not link. The linking stage simply is not done. The ultimate output is in the form of an object file for each source file.

Examples:

To generate an object file (`.o' file):

gcc -c test.c 

To generate an executable:

gcc test.c -o test

(if you omit the -o test, it'd generate a.out as executable by convention).

Share:
18,114
jcubic
Author by

jcubic

My name is Jakub T. Jankiewicz, I'm coding mostly in JavaScript. I love Lisp Macros, jQuery library, ReactJS, CSS3, HTML5, SVG, GNU/Linux, GNU Emacs and Inkscape. Working with JavaScript and R for Roche/Genentech via Astek Poland. my english blog - In Code We Trust my polish blog - Głównie JavaScript (ang. Mostly JavaScript) Usefull Links Other links Yet another links Few of my JavaScript Open Source projects: jQuery Terminal: JavaScript library for Web based Terminal Emulator LIPS - Powerful Scheme based lisp interpreter written in JavaScript sysend.js: Library for sending messages between Windows and Tabs Gaiman Programming Language and Text based Game engine GIT Web Terminal Posts: EchoJS News, EchoJS News (2), HackerNews

Updated on June 09, 2022

Comments

  • jcubic
    jcubic almost 2 years

    I'm trying to debug claws-mail notification plugin, I have code like this:

    #include "notification_indicator.h"
    #include "notification_prefs.h"
    #include "notification_core.h"
    
    #include "folder.h"
    #include "common/utils.h"
    
    #include <messaging-menu.h>
    #include <unity.h>
    
    #define CLAWS_DESKTOP_FILE "claws-mail.desktop"
    
    #include <stdio.h>
    
    void main(void)
    {
      GList *cur_mb;
      gint total_message_count;
    
    
      total_message_count = 0;
      /* check accounts for new/unread counts */
      for(cur_mb = folder_get_list(); cur_mb; cur_mb = cur_mb->next) {
        Folder *folder = cur_mb->data;
        NotificationMsgCount count;
    
        if(!folder->name) {
          printf("Notification plugin: Warning: Ignoring unnamed mailbox in indicator applet\n");
          continue;
        }
        gchar *id = folder->name;
        notification_core_get_msg_count_of_foldername(folder->name, &count);
        printf("%s: %d\n", folder->name, count.unread_msgs);
      }
    }
    

    and I'm compiling it with this command:

    gcc  -I/home/kuba/Pobrane/claws-mail-3.13.2/src/
         -I/usr/include/gtk-2.0/
         -I/usr/include/cairo/
         -I/usr/include/pango-1.0
         -I/usr/lib/i386-linux-gnu/gtk-2.0/include/
         -I/usr/include/gdk-pixbuf-2.0/
         -I/usr/include/atk-1.0/
         -I/home/kuba/Pobrane/claws-mail-3.13.2/src/common
         -I/home/kuba/Pobrane/claws-mail-3.13.2/src/gtk
         -I/usr/include/messaging-menu/
         -I/usr/include/unity/unity/
         -I/usr/include/dee-1.0/
         -I/usr/include/libdbusmenu-glib-0.4/
         -c `pkg-config --cflags glib-2.0` test.c
    

    but gcc create object file test.o instead of a.out how can I create executable file? I'm running this on Xubuntu.