Learning to (successfully) compile not-your-own code

BACKGROUND

I obtained a CS minor 7 years ago, and this year I have been brushing up on C++ (via a C++ textbook, the tutorial on this site, etc.).

I run Mac OS X, and I started out created programs with command line UI via XCode (e.g., a mock ATM, a Blackjack game, etc.). I have also made sure I know how to create files "from scratch" in a text editor and then compile them by hand (sometimes creating a makefile). In order to create apps with actual GUIs, I downloaded Qt and have used that to make a few *very* simple games. No problem.

MY ISSUE / QUESTION(S)

I am wondering what to do next. My next big goal is to get to the point where I can make a small contribute to an open source project (or at least follow along and learn a few things). I have downloaded several different project's source codes, and in each case, I can't get it to compile (despite hours of perusing "help" topics/posts on the web). Each project seems to have different issues.

I am not posting here to ask for debugging help, but instead to back up and make sure I am seeing the "big picture".

(1) Is it normal for a novice to have so much trouble compiling open source code (on mac)?

(2) Am I trying to do too much too soon? Do you have any ideas for "baby steps" I could take that would help me get the hang this more gradually?

AN FYI

FYI: I'm not sure if this helps, but I am doing all of this in hopes to gain enough knowledge/experience to be able to land an entry-level C++ software developer position (I hold an advanced degree in another field and am looking to change careers; I had fond memories of my CS minor courses, and I have really enjoyed getting back into it over the last year).
Last edited on
Sorry for the long post. I struggle with being brief. :-)
closed account (Dy7SLyTq)
plz i hardly call that a wot. and it depends. it could just be that the code your trying to compile wont run on a mac. it could be that you are linking to files compiled on windows.
Thanks for the reply, DTS.

In each case I used code that was supposed to be compilable on a mac and I followed instructions (via a README or a custom wiki) for how to compile the source code on Mac. In each case there were so many compile-time errors that troubleshooting ended up being fruitless for a novice like me.

Perhaps I'm taking too big of a step in trying to compile open source programs on my own, but if that is my ultimate goal, then what steps can I take to eventually get there?

It would be great if there was some sort of resource that had things like this: "...when you see output with warnings and errors like XXXXXXXX, it is usually caused by a different (more fundamental) error; when you see output with warnings and errors like YYYYYYYYY, it often means you should do ZZZZZZZZ". As is, sorting through dozens and dozens of warnings and errors that result from a compile attempt hasn't proved helpful. I try finding similar or the same errors posted online (and fixing it by doing as they did), but it never works.

I feel like I was thrown into the deep end to learn to swim, and I wondering if there is a way to ease into this (troubleshooting compiling errors) instead.
Last edited on
An ideal package requires (according to RMS):
./configure
make

The configure is a script that makes use of GNU autoconf. The script compares requirements set by package author to tools available on the build host. If they meet, you get an Makefile that will use the available compiler and appropriate options for it. Libraries too. Unsatisfied requirements produce an error.

qmake (in Qt) and cmake are similar to autoconf. In each case you do have platform-independent description of what to do and platform-specific rules, and the output is Makefile tailored for your system. The problem is that the rules may be lacking, the description not quite independent, and the source code dependent on libraries and features that are not available on every platform and compiler.
Why don't you try the mailing list of the any particular open source project that you are working on. Generally they have their own mailing lists.

Nevertheless, I have gone through the same problem many a time. If the project is small enough you can just ignore the default autoconf (or whatever) build system and add your own Makefile and list all the source files in it. Some points to remember if you take this approach:

- You need to be reasonably good with Makefiles
- You will need to refer to some important stuff from the default build system like CFLAGS, library
dependencies, etc.

Once you done with this just build the project and debug the errors thrown by the compiler. Most of these errors would be due missing include paths, missing command line options to compilers and library dependencies.
Thanks for the additional replies ... they give me some extra things to think about.

I think I'll return and go back to my own from-scratch [simple] Makefiles and play around with stuff to see if I can become more experienced with Makefiles. Maybe then I will have more success in getting already-made [big] Makefiles (as well as cmake and qmake) to work for me.
Last edited on
Good.

But note that generally the "big" makefiles that you refer to are generated automatically. The build system in such projects is in itself a hugely complex set of scripts and macros. The purpose of their existence is to enable a developer to make his software compatible to many many distributions and their variants available.

Refer: http://www.gnu.org/software/autoconf/

Since you are a beginner in this area, you can safely ignore all of this and just try to build the software with help from the experts on the web and just cross that initial hurdle. After that hurdle is crossed you can then focus on the real "C++" stuff that you are interested in anyway.

- Kau
Last edited on
Topic archived. No new replies allowed.