title: c++ dynamic library linking in MacOsX
body: <p><b>If you want to watch source codes, download them here goo.gl/pGJwn1.</b></p>
  
  <p>When i've written my program all files were in a unique directory and the compiling was ok.
  Now i want to create a dynamic library for each package and link them. 
  I'm using a MacOsX.
  When I compile the "AnalysisFramework" package i use this command
  <code>c++-4.8 -std=c++0x -fPIC -shared -o libAnalysisFramework.so *.cc  -I../ -I. -Wall</code> and all it's ok.</p>
  
  <p>The problems occurs when i try to compile the "AnalysisObjects" package. In fact, using the same command the compiler returns these errors</p>
  
  <pre><code>Undefined symbols for architecture x86_64:
    "Event::minSize()", referenced from:
        BraggStatistic::BraggStatistic(int, int) in ccWYudnZ.o
        BraggStatistic::BraggStatistic(int, int) in ccWYudnZ.o
        BraggStatistic::add(Event const&amp;) in ccWYudnZ.o
        BraggStatistic::compute()      in ccWYudnZ.o
        TotalEnergy::update(Event const&amp;) in ccoA1A2B.o
    "Constants::bgMean", referenced from:
        BraggStatistic::compute()      in ccWYudnZ.o
        TotalEnergy::energy()      in ccoA1A2B.o
    "Event::energy(unsigned int) const", referenced from:
        BraggStatistic::add(Event const&amp;) in ccWYudnZ.o
        TotalEnergy::update(Event const&amp;) in ccoA1A2B.o
  ld: symbol(s) not found for architecture x86_64
  collect2: error: ld returned 1 exit status
  </code></pre>
  
  <p>It doesn't find the functions definitions that are in the other directory. Is it normal? How fix?</p>
  
  <p>I've these directory with source codes.</p>
  
  <pre><code>|____AnalysisFramework
  | |____AnalysisFactory.cc
  | |____AnalysisFactory.h
  | |____AnalysisInfo.cc
  | |____AnalysisInfo.h
  | |____AnalysisSteering.cc
  | |____AnalysisSteering.h
  | |____Event.cc
  | |____Event.h
  | |____EventReadFromFile.cc
  | |____EventReadFromFile.h
  | |____EventSim.cc
  | |____EventSim.h
  | |____EventSource.cc
  | |____EventSource.h
  | |____main.cc
  | |____SourceFactory.cc
  | |____SourceFactory.h
  |____AnalysisObjects
  | |____BraggStatistic.cc
  | |____BraggStatistic.h
  | |____TotalEnergy.cc
  | |____TotalEnergy.h
  |____AnalysisPlugins
  | |____BGCalc.cc
  | |____BGCalc.h
  | |____EnergyDist.cc
  | |____EnergyDist.h
  | |____EventDump.cc
  | |____EventDump.h
  |____AnalysisUtilities
  | |____Constants.cc
  | |____Constants.h
  |____braggPlot_v06.txt
  |____compile
  |____util
  | |____.DS_Store
  | |____class
  | | |____cloneClass
  | | |____createClass.cc
  | | |____info
  | |____include
  | | |____.DS_Store
  | | |____ActiveObserver.h
  | | |____ActiveObserver.hpp
  | | |____Dispatcher.h
  | | |____Dispatcher.hpp
  | | |____LazyObserver.h
  | | |____LazyObserver.hpp
  | | |____Random.h
  | | |____Singleton.h
  | | |____Singleton.hpp
  | |____info
  | |____lib
  | |____src
  | | |____random
  | | | |____base
  | | | | |____compile
  | | | | |____Random.cc
  | | | |____info
  | | | |____root
  | | | | |____compile
  | | | | |____RootRandom.cc
  | | | | |____RootRandom.h
  | | | |____std
  | | | | |____compile
  | | | | |____StdRandom.cc
  | | | | |____StdRandom.h
  | | | |____test
  | | | | |____compileRandom
  | | | | |____testRandom.cc
  </code></pre>