Members - Reputation: 152
Posted 02 August 2012 - 10:18 AM
1. I'll download the library from the site.
2. Open the file with MSVC 2010 - This will usually give me all manner of linker errors.
3. Search the file directory for the missing files, and create a .props to include these directories.
4. After including the files, I get missing file errors, for files that don't exist anywhere in the download. (I realize some libraries depend on other libraries, but I seem to encounter this issue regardless)
5. Google for several hours trying to locate where said missing files are, and ultimately come up empty, or with lots of unrelated forum threads.
It feels like compiling a library should be a straightforward process, but it never seems to open and compile smoothly. Is there an easier way to compile these libraries, or am I just missing a step somewhere along the line? I've never used any other program to compile with, so I'm unsure if a change of software might help. Anyone have any general advice?
Members - Reputation: 1141
Posted 02 August 2012 - 12:32 PM
Since C/C++'s standard library is very tiny, almost any library pulls in a ton of dependencies. Using them is usually as simple as linking to a DLL. Compiling it means you have to pull in all dependencies, recursively. What you need to do is basically track down all dependencies, and download the proper versions. After that, you will have to combine the source code appropriately, so that #include's work as they were meant to. You might need to change a source code that #include's the wrong way, and make certain that it used your local headers and not the compiler's/system's.
Java has Maven and Ivy, .NET has NuGet, Python has easy_install (setuptools), Ruby has gems, and Go has go get. Unfortunately, I'm not aware of anything similar for C/C++.
Because of this, many library authors provide a list of libraries on which their project depends. Sometimes, they also provide a single download for the dependencies in the form they were used to compile the distributed binary release. Other libraries provide a sing .h and .c file for simpler embedding. Usually googling for "compile X from source" yields tons of results of people screaming in agonizing pain.
My advice is to write down the dependency graph yourself. It will make your life easier. Google for libraries, not header files, you will end up finding more relevant results. Also, be very careful if a library author explicitly states that a particular version of a dependency is used. Using a newer version might as well break the original dependency.
Members - Reputation: 756
Posted 02 August 2012 - 09:00 PM
I found it's quite painful to compile some C++ open source libraries.
I have to bet my luck on the library author.
If the author provides one-shot make system, such like CMake, or decent make file, and the make system works in my development environment (the C++ compiler version, etc), then my life is quite easy.
But lots of times I can't compile the library that easily.
So now "easy to make" is a very important criteria for me to choose a library. If both A and B can meet my requirement and I can compile A but not B, I will choose A even if B has superior features.
And once you succeed compile the library after a lot failures, don't upgrade unless you must have to, or at least test compiling before you upgrade. Upgrading may cause you spend a lot of time on compiling again.
That's why I'm sticking with an old version Google V8 because I can't compile the latest one. :-)
Edited by wqking, 02 August 2012 - 09:01 PM.
cpgf library -- free C++ open source library for reflection, serialization, script binding, callbacks, and meta data for OpenGL Box2D, SFML and Irrlicht.
v1.5.5 was released. Now supports tween and timeline for ease animation.