Pergunta

I am having trouble with Boost and my Mac OS X.

I am using Qt Creator as a development platform for C++ projects, primarily because of the IDE and qmake.

Right now I am working on a C++ app that is supposed to be cross-platform but I do not want to use the Qt framework itself. Instead I am using the STD libraries (C++11), Poco and Boost.

One of the things I am trying to achieve is a plugin system that loads dynamically linked libraries at runtime.

I saw a few projects like Boost-extension which is no longer supported and several others.

Right now I am using Poco's Shared Libraries and their Class Loader. I am following closely the tutorial at the end of the presentation. Unfortunately I cannot get it working and I am receiving the following error upon compilation, where the ServiceBase class is my plugin interface.

Undefined symbols for architecture x86_64:
"Poco::SharedLibrary::getSymbol(std::string const&)", referenced from:
      Poco::ClassLoader<ServiceBase>::loadLibrary(std::string const&, std::string const&) in main.o
  "Poco::SharedLibrary::hasSymbol(std::string const&)", referenced from:
      Poco::ClassLoader<ServiceBase>::loadLibrary(std::string const&, std::string const&) in main.o
  "Poco::SharedLibrary::SharedLibrary(std::string const&)", referenced from:
      Poco::ClassLoader<ServiceBase>::loadLibrary(std::string const&, std::string const&) in main.o
  "Poco::SystemException::SystemException(std::string const&, int)", referenced from:
      Poco::MutexImpl::unlockImpl() in main.o
      Poco::MutexImpl::lockImpl() in main.o
  "Poco::LibraryLoadException::LibraryLoadException(std::string const&, std::string const&, int)", referenced from:
      Poco::ClassLoader<ServiceBase>::loadLibrary(std::string const&, std::string const&) in main.o
ld: symbol(s) not found for architecture x86_64

I have the Poco libraries linked and pretty much everything seems to be implemented.

Any advice on how to fix that?

P.S. I am also looking for alternatives on implementing the plugin system, probably more-powerful and certainly cross-platform.

Foi útil?

Solução

Disclaimer. I have no experience with this Poco library.

Without further details on your environment or your tools... I can only provide some very general advice:

How I'd chase this is:

  1. Locate in what library or object file are defined the symbols reported as undefined symbols. On unix-like environments this can be achieved with the nm tool
  2. Verify that the libraries or objects are compiled on the right architecture (I see you're using x86_64) file tool might help you there
  3. Verify that you're referring to the library in the linker command line (look for a -l for dynamic or static libraries) or that you're including the object file or the static library in the list of things to link.
  4. Verify that you're referring to the right library (either through -L flags or the LD_LIBRARY_PATH env variable (or LD_LIBRARY_PATH_64 in some systems e.g. Solaris for 64bits build)

I know you said you have linked the Poco libraries, but the error is clearly that a symbol is missing. Either the library is missing or you need to fiddle with the order of the -l flags to satisfy the dependencies. The nm might help you there in determining what objects or libraries refer to the symbol (must come first) and what objects or libraries define the symbol (must come later).

Sorry not being of more help.

P.S. In addition you might want to look at Linking error with Poco Net which might be related.

One more reference to a question that details different causes for linker errors: What is an undefined reference/unresolved external symbol error and how do I fix it?

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top