Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. compiling more than 2 C files

compiling more than 2 C files

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
helpsysadminlinuxquestion
4 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Schehaider_Aymen
    wrote on last edited by
    #1

    Hi All, I m fighting against a problem that drove me crazy for long hours, I wanna create a simple prog like Client/Server under linux using C code. I wrote a Server.c and Client.c Files but when i type $gcc -c Server.c Client.c $gcc -o Blood *.o it told me that there is a double declarion of the function main So could some one tell me how could i test my prog on the same mchine ??? (local) Thank you !!!! i Need Help so plz !!!

    "The Ultimate Limit Is Only Your Imagination."

    M D 2 Replies Last reply
    0
    • S Schehaider_Aymen

      Hi All, I m fighting against a problem that drove me crazy for long hours, I wanna create a simple prog like Client/Server under linux using C code. I wrote a Server.c and Client.c Files but when i type $gcc -c Server.c Client.c $gcc -o Blood *.o it told me that there is a double declarion of the function main So could some one tell me how could i test my prog on the same mchine ??? (local) Thank you !!!! i Need Help so plz !!!

      "The Ultimate Limit Is Only Your Imagination."

      M Offline
      M Offline
      Moak
      wrote on last edited by
      #2

      Blood_HaZaRd wrote:

      $gcc -c Server.c Client.c $gcc -o Blood *.o it told me that there is a double declarion of the function main

      Did you try this? $gcc -c Server.c Client.c $gcc -o blood_server Server.o $gcc -o blood_client Client.o

      My webchat in Europe :java:

      S 1 Reply Last reply
      0
      • M Moak

        Blood_HaZaRd wrote:

        $gcc -c Server.c Client.c $gcc -o Blood *.o it told me that there is a double declarion of the function main

        Did you try this? $gcc -c Server.c Client.c $gcc -o blood_server Server.o $gcc -o blood_client Client.o

        My webchat in Europe :java:

        S Offline
        S Offline
        Schehaider_Aymen
        wrote on last edited by
        #3

        Ok i asked my professor and here what he told me to do: after compiling the 2 files: $gcc - client client.c $gcc - server server.c i ha to add a & when calling ther server: $./server & then i run the clien $./client that's all. i didn't try it yet but i hope that it'll works. Thank you All for your Help. I appreciate it Well. :rose:

        "The Ultimate Limit Is Only Your Imagination."

        1 Reply Last reply
        0
        • S Schehaider_Aymen

          Hi All, I m fighting against a problem that drove me crazy for long hours, I wanna create a simple prog like Client/Server under linux using C code. I wrote a Server.c and Client.c Files but when i type $gcc -c Server.c Client.c $gcc -o Blood *.o it told me that there is a double declarion of the function main So could some one tell me how could i test my prog on the same mchine ??? (local) Thank you !!!! i Need Help so plz !!!

          "The Ultimate Limit Is Only Your Imagination."

          D Offline
          D Offline
          DevMentor org
          wrote on last edited by
          #4

          you will need to compile each file separately. each file creates a different exe, one will create a client exe and the other a server exe. each file has a main method, when you compile files together it to create a single exe, so what you are doing is incorrect. in short you can't have multiple definitions of a function, in your case that would be 'main' try: gcc -o server server.c gcc -o client client.c hope this helps :-D

          --- Yours Truly, The One and Only! web: devmentor.org Design, Code, Test, Deploy

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups