Creating a make file for a c++ project

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mickey22
    New Member
    • Feb 2007
    • 105

    Creating a make file for a c++ project

    hi all,

    I have a c++ project and would like to create a make file.

    say my main program is a.cpp and other source file associated with this project is b.bpp and its header file b.h.There are different lib files also used to execute this program.

    Could anyone please give me an idea of how to start creating it and how to execute a c++ project using make file on windows??

    Thanks.
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Are you using Visual Studio??

    If so, the make file is generated when you select Build and deleted when the build is complete. Your source files are part of your program if they are part of your project.

    Make files are different between Unix and Windows so if you want to write one from scratch you will need to get the approppriate book.

    Comment

    • vermarajeev
      New Member
      • Aug 2006
      • 180

      #3
      Originally posted by mickey22
      hi all,

      I have a c++ project and would like to create a make file.

      say my main program is a.cpp and other source file associated with this project is b.bpp and its header file b.h.There are different lib files also used to execute this program.

      Could anyone please give me an idea of how to start creating it and how to execute a c++ project using make file on windows??

      Thanks.
      Well,
      If you are aware about Qt (GUI tool) your work will be very easy. There is a tool provided by Qt which helps you create a Makefile. This tool is called qmake. You just need to create a pro file and then say qmake test.pro. This creates a makefile.
      I suggest you to use qmake.
      But if you are not interested in Qt then too creating Makefile is not a big deal. Just refer to this link http://mrbook.org/tutorials/make/ .

      But I suggest you to first see this link about Qt..http://www.qtcentre.or g/ . You will love it.

      Thanks

      Comment

      • Banfa
        Recognized Expert Expert
        • Feb 2006
        • 9067

        #4
        If all you want to do is make you programs form the command line then there is no need for make files. you can call msdev.exe (the MSVC++ IDE exe name) with the workspace and project to build from the command line.

        Or at least you could in MSVC++ 6.0 not to sure about later versions but you'd hope they didn't get rid of that feature.

        Comment

        • mickey22
          New Member
          • Feb 2007
          • 105

          #5
          Thank you all for the information.

          I have a sample make file and need to build my program in clearcase.Thats what I am trying to do.

          I have small question.Usuall y the code is built in debug and release modes.I guess the library files used during linking for debug and release modes are different.So in the sample make file, there is STATIC LIBS (list of lib files).

          When I am building my project in clearcase, am I building it in debug or release mode or in both and dont I have to include lib files for both debug and release.How does that work??Please let me know if I am not clear with my question?

          Could anyone please explain me this concept?

          Thanks a lot in advance.

          Comment

          • weaknessforcats
            Recognized Expert Expert
            • Mar 2007
            • 9214

            #6
            A debug build has embedded code to allow you to use the debugger. Therefore, the executable is much larger than necessary. Usually a debug build is the default. Along with build, all libraries must also be debug libraries. With a tool there is usually a project setting that specifies debug or release.

            A release build just doesn't have the debug support code in the executable. You will have release libraries for this type of build. If you get a problem with a release build, you can't debug it.

            A debug library will have a different name from a release library or they will have the same name but the tool will separate them into separate folders.

            Comment

            • mickey22
              New Member
              • Feb 2007
              • 105

              #7
              Sorry I am still not clear.What libraries(debug or release) should I provide in the make file when I build my program in clear case?

              I have tested my program with release libraries in my local directory and it is working.
              In my make file there is only set of LIB's.To which do they refer?My program generates an executable file.

              Thanks.

              Comment

              • weaknessforcats
                Recognized Expert Expert
                • Mar 2007
                • 9214

                #8
                ClearCase is a version control system. You would install ClearCase and then use it with, say, Visual Studio.NET 2005. The debug/release settings would be part of the Visual Studio project. If you set for debug, then set a property for the linker to include your libraries. There is a secoind property to set the path top those debug libraries. If you set for release, then set a path to your release libraries.

                What IDE are you using?

                Comment

                • mickey22
                  New Member
                  • Feb 2007
                  • 105

                  #9
                  Clear case is installed and I am using Visual C++ 2005.I was able to create a make file and able to build it in release mode.When I use the same make file with the same include paths and lib files, it generates executable file in debug version, but exception as
                  "Unable to locate some .dll"

                  As I have posted separately also (sorry if I am repeating it) , I tried to run my program in debug mode with samelib files as in release mode in my local director.I got theses linking errors.


                  LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/LTCG' specification
                  1>LIBCMT.lib(in varg.obj) : error LNK2005: ___pInvalidArgH andler already defined in LIBCMTD.lib(inv arg.obj)
                  1>LIBCMT.lib(in varg.obj) : error LNK2005: __initp_misc_in varg already defined in LIBCMTD.lib(inv arg.obj)
                  1>LIBCMT.lib(in varg.obj) : error LNK2005: __invoke_watson already defined in LIBCMTD.lib(inv arg.obj)
                  1>LIBCMT.lib(in varg.obj) : error LNK2005: __set_invalid_p arameter_handle r already defined in LIBCMTD.lib(inv arg.obj)
                  1>LIBCMT.lib(in varg.obj) : error LNK2005: __get_invalid_p arameter_handle r already defined in LIBCMTD.lib(inv arg.obj)
                  1>LIBCMT.lib(in varg.obj) : error LNK2005: "void __cdecl _invoke_watson( unsigned short const *,unsigned short const *,unsigned short const *,unsigned int,unsigned int)" (?_invoke_watso n@@YAXPBG00II@Z ) already defined in LIBCMTD.lib(inv arg.obj)
                  1>LIBCMT.lib(in varg.obj) : error LNK2005: __invalid_param eter already defined in LIBCMTD.lib(inv arg.obj)
                  1>LIBCMT.lib(in varg.obj) : error LNK2005: "void __cdecl _invalid_parame ter(unsigned short const *,unsigned short const *,unsigned short const *,unsigned int,unsigned int)" (?_invalid_para meter@@YAXPBG00 II@Z) already defined in LIBCMTD.lib(inv arg.obj)
                  1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:li brary


                  When i used different lib files I got these warnings

                  LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/LTCG' specification
                  LINK : /LTCG specified but no code generation required; remove /LTCG from the link command line to improve linker performance

                  Sorry If I am creating confusion.Its just I am little bit new and just trying to learn all theses things.I really appreciate and thank you for helping me .

                  Please let me know if I am not clear.


                  Thanks.

                  Comment

                  • mickey22
                    New Member
                    • Feb 2007
                    • 105

                    #10
                    The make file that has been created generates the teargets in debug and release modes and lib files needed for debug as well as release mode are taken care by the paths given in the make file automatically.

                    Thats solved my issue.

                    Thank you all once again.

                    Comment

                    Working...