Jump to content

  • Log In with Google      Sign In   
  • Create Account


Makefile madness


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 greenzone   Members   -  Reputation: 662

Like
0Likes
Like

Posted 30 January 2013 - 01:21 PM

Can any one please in layman's terms explain "Makefiles". I would like to build a library that comes with make files but I don't understand them at all. I use visual studio 2010 as a compiler and I barely used gcc. So could any one try to take a stab at explaining it and its components with out getting to pedantic.

 

Thanks


J-GREEN

Greenpanoply

Sponsor:

#2 Bacterius   Crossbones+   -  Reputation: 7047

Like
4Likes
Like

Posted 30 January 2013 - 02:00 PM

Makefiles are basically files that associate rules, dependencies, and actions to effectively build a program (and more - they are often used in compilation but have a wide variety of applications). That's all you need to know if you just want to know how to use one to build a library, but if you want to make a makefile (no pun intended) then you can always find a more detailed explanation on the internet.

 

If you are under Linux, this is easy, the make utility comes with your distribution. Just cd into the library's folder where the Makefile resides, and type "make" (or perhaps the library tells you to use "make setup", it depends on the makefile). Do that, and it should just work. If there's an error that comes up, try googling it, perhaps you need to run the makefile as superuser or you need to download and install some package first, etc..

 

If you are under Windows, let's just say your day is going to suck, at least in my experience. Makefiles just don't work all that well under Windows, if the library also comes with an IDE project file (visual studio, or whatever) prefer that to using makefiles IMHO. Otherwise I think you need to install CMake, and a bunch of other stuff, and then I don't know. Sorry :(


Edited by Bacterius, 30 January 2013 - 02:01 PM.

"The best comment is a deleted comment."


#3 RobTheBloke   Crossbones+   -  Reputation: 2231

Like
2Likes
Like

Posted 30 January 2013 - 02:32 PM

To be honest, if it's visual C++, I'd just create a new static lib project, add all of the source files, hit compile, and hope for the best! :)
If it's a lib that only uses it's own methods/classes, then it's usually not too bad. If it's a lib with a tonne of external dependencies, then this may prove to be a nightmare! (and you may be better off with the makefile). You can set projects up to build a makefile in VC++, but I'm on linux at the moment, otherwise I'd have a quick look to remind myself.

Sometimes you may need to add a new define to the project settings for the lib to get it compiling. Have a hunt around in the headers for any #ifdef MY_LIB_FOO lines, and add that define to your project settings. Alternatively, look for any -DMY_FOO_LIB lines in the makefile. -D just means define, and that usually means you'll be wanting to use the identifier directly after it when building!

If the lib is supposed to compile to a DLL, you may want to create a dynamic library project instead of a static one (and you will definitely need to locate the BUILDING_MY_LIBRARY define, so that the lib gets compiled with declspec(dllexport). Alternatively, just delete the declspec from the headers leaving an empty macro in it's place.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS