using 2 source code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tpybear
    New Member
    • Jul 2006
    • 3

    using 2 source code

    Hi, may i know how do you include 2 source code together? I'm want to use the function in that code to be used in the main function in the other source code. thanks. :D
  • Ashish_CPP
    New Member
    • Jul 2006
    • 35

    #2
    Hi,
    U can use .dll file for this. create .dll file with the function u want and call that fuction from which ever function u want. Using .dll will also save ur code size from being bulky.

    regards,

    Ashish.

    Comment

    • tpybear
      New Member
      • Jul 2006
      • 3

      #3
      erm, is there a simpler way? I just started programming.

      Comment

      • Ashish_CPP
        New Member
        • Jul 2006
        • 35

        #4
        Originally posted by tpybear
        erm, is there a simpler way? I just started programming.

        Hi,
        There is a simpler way also. U can create .lib file (static library file), this u can create in the same way as u create a project just by selecting static library option instead of project. Here instead of .exe, a .lib file will be created. This .lib can be included in any other project and the function written in .lib can be called from the project in which u have included it. Hope this will be possible for u.

        regards,

        Ashish.

        Comment

        • Banfa
          Recognized Expert Expert
          • Feb 2006
          • 9067

          #5
          Or just put both source files in your project, i.e. compile them both and link them together.

          Comment

          • tpybear
            New Member
            • Jul 2006
            • 3

            #6
            thanks, but how do u link them together?

            Comment

            • Banfa
              Recognized Expert Expert
              • Feb 2006
              • 9067

              #7
              Suppose the files are

              File1.c
              File2.c

              Then you would issue the commands

              cc File1.c
              cc File2.c

              link File1.obj File2.obj

              Where
              cc = the name of your compiler program plus any required flags
              link = the name of your linker program plus and required flags

              Comment

              • ssehgal2010
                New Member
                • Aug 2006
                • 10

                #8
                Hey Banfa can you eleborate this
                Suppose I am using Turbo C++ then what exactly I should use in through command line
                Thanks in advance

                Comment

                • Banfa
                  Recognized Expert Expert
                  • Feb 2006
                  • 9067

                  #9
                  I can not tell you because I have never used Turbo C++

                  Check you documentation it should tell you.

                  Comment

                  Working...