MacOSX中的c ++动态库链接

时间:2014-05-13 17:06:09

标签: c++ dynamic-linking

如果您想观看源代码,请在此处下载goo.gl/pGJwn1。

当我编写我的程序时,所有文件都在一个唯一的目录中,并且编译正常。 现在我想为每个包创建一个动态库并链接它们。 我正在使用MacOsX。 当我编译" AnalysisFramework"包我使用此命令 c++-4.8 -std=c++0x -fPIC -shared -o libAnalysisFramework.so *.cc -I../ -I. -Wall,一切都好。

当我尝试编译" AnalysisObjects"时出现问题。包。实际上,使用相同的命令编译器会返回这些错误

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&) in ccWYudnZ.o
      BraggStatistic::compute()      in ccWYudnZ.o
      TotalEnergy::update(Event const&) 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&) in ccWYudnZ.o
      TotalEnergy::update(Event const&) in ccoA1A2B.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status

它找不到其他目录中的函数定义。这是正常的吗?如何解决?

我的这些目录包含源代码。

|____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

0 个答案:

没有答案