Compiling and linking are just having the include dirs in -I's, a good dynamic search path or static lib dirs in -L's, libraries -lxxx and source or object files in the right order, and away you go. What happens when you compile?
Some prefer to do it in two lines, one for .cc.o and one for .o.exe or whatever, so the first also supports code going into libraries, and there is just one place for those options in make definitions.
I usually see the compiler options, -D's, -I's (preprocess is before compile, is before link), the -L right before the -l's it supports, -l's for each linked library and source or local object at the right end. I like to use dynamic linking, so no -L's, just a good LD_LIBRARY_PATH (or whatever your system likes to use, see man ld() for rules).
Sometimes I would -c compile all the .c or .cc into .o and ar them all into one library .a file, as order does not matter within a library, and finally compile with the .a file explicitly only. Only good for one main()! One best practice says put only one subroutine/function in each source file, and then the order is tricky. You can have one .a for each main() and it's "private" functions/methods/subroutines, and then link in any common code libraries.
The -I path must support the entry name or relative path in the source #include's (-I/a/b/c and #include "d/e.h" is for /a/b/c/d/e.h).
Last edited by DGPickett; 12-27-2012 at 06:07 PM..
You haven't said what you want to do with the path processing. But you can use strchr() to get each directory or use strrchr() to get to the filename directly.
Regarding your build system, I think it's best to have a make file in each program directory, then have a single make file in the top level program directory that calls the others. You can do it like this:
See: GNU `make'
Also, GNU Make has a lot of built in rules. It already defines CC and CXX macros for the C and C++ compilers. Flags common to both compilers are set with CPPFLAGS and LDFLAGS for linker options.
As your set of programs probably all need common paths, you should set them in a separate make include file in the programs directory.
The raytrac make file will look something like:
Do that for each project.
common.mk has:
Clearly you don't need to specify Boost if you're not using it (by using the string routines instead).
LINKcc is GNU Make's C++ link rule. You can see all the rules by running:
Hi,
I just started using CMake and the Boost Libraries. In this progress I encountered some problems.
One of these problems is combining Boost unit tests with cmake. I don't know how to set the whole project up. I tried to set up a simple test project. This contains a main.cpp a comp.cpp and the... (0 Replies)
Hello all,
I am trying to "make" a database system, VDB (Veritas Data Base), and when I run "make" I receive the following error:
VDBException.h:19: error: expected `)' before '*' token
VDBException.h:20: error: expected `)' before '*' token
VDBException.h:43: error: expected `)' before '*'... (4 Replies)
Hi,
Based on the following example in the Boost C++ website:
www. boost.org/doc/libs/1_47_0/doc/html/boost_asio/example/echo/async_tcp_echo_server.cpp]doc/html/boost_asio/example/echo/async_tcp_echo_server.cpp
I tried to create a similar TCP server that waits to accept a client connection... (0 Replies)
Hi All
I am working unders Sun Solaris and I am not
"/opt/boost/boost/thread/detail/thread.hpp", line 344: Error: boost::thread::thread(boost::thread&) is not accessible from boost::move(boost::detail::thread_move_t<boost::thread>).
Do you know if there are other solutions other than... (2 Replies)
Is it possible to build Boost 1.35 using Sun Studio 10?
I can build Boost 1.35 using Sun Studio 11 successful. However, i'm unable to build it using Sun Studio 10 using the exact method.
I really apprecaite if any expert can help on this.
Thanks, (2 Replies)
Hi All,
I installed Linux recently on my PC and finding it difficult to boost its performance.
It takes hell lot of time to open Mozilla, text pad , & even the booting process is too slow, many a times I got to manually power off to shutdown the computer.
I will be glad if you could help me... (18 Replies)