-1

I am looking for a good Makefile template for creating a dynamic loadable library on Linux. The dynamic library is developed in C++. I only want to specify the library name and its source files (.cc) in the Makefile. Furthermore, I want to be able to specify a directory (e.g. ./build) for the build process. After building, the dynamic library should be in another directory (e.g. ./libs) also specified as variable in the Makefile.

Any hints?

Thanks in advance & best regards! Jonas

Jonas
  • 2,974
  • 4
  • 24
  • 23
  • Please please use [libtool](http://www.gnu.org/software/libtool/manual/libtool.html) for this task. You'll thank yourself later. – Alexandre C. Feb 28 '12 at 09:18
  • 2
    Any hints ? SO is not a replacement for Google, you're workflow should be (1) Google, (2) struggle to make a fist of tailoring what Google finds to your problem, (3) post a question on SO which complies with local best practices and FAQs. – High Performance Mark Feb 28 '12 at 09:37

1 Answers1

1

My scons template for small and test projects (sources and includes in src dir, objects files in build dir, result lib in libs dir) :

env = Evironment()

env.Append(CPPPATH = ['#src']) # customize your additional included path
#env.Append(LIBPATH = ['/my/path']) # customize your additional lib path
#env.Append(LIBS = ['foo', 'bar']) # customize your additional libs to link

sources = Glob('src/*.cpp') # Get sources by mask from src dir

VariantDir('build', 'src')
env.SharedLibrary('#libs/mylib', sources)
Torsten
  • 21,726
  • 5
  • 24
  • 31