Giter Club home page Giter Club logo

Comments (5)

poletti-marco avatar poletti-marco commented on June 20, 2024 2

You should also link with Fruit. Just add -lfruit to your g++ command.

In hindsight, this is probably the same issue that @PedroAreias was reporting, so I've now added a note to the prebuilt packages section of the wiki explaining this.

from fruit.

poletti-marco avatar poletti-marco commented on June 20, 2024

Thanks for the report. Could you please provide some more info?

  • What version of Fruit are you using?
  • What commands did you execute to get that error? (cmake then make I guess? With what options?)

from fruit.

poletti-marco avatar poletti-marco commented on June 20, 2024

I cannot reproduce this issue.
I've tried with the latest version (Fruit 2.0.4) using GCC 5.4.0, building the example either via cmake+make or via a manual compile command.
If you haven't managed to find a solution yet, please let me know what you did to get this issue, without additional information I'm unable to help.

from fruit.

poletti-marco avatar poletti-marco commented on June 20, 2024

Closing since I am unable to reproduce/fix this without more information. If you can still reproduce please reopen and provide the information asked in the previous comments.

from fruit.

Brandon2255p avatar Brandon2255p commented on June 20, 2024

Getting the same error

main.o: In function `fruit::impl::MemoryPool::~MemoryPool()':
/usr/include/fruit/impl/data_structures/memory_pool.defn.h:51: undefined reference to `fruit::impl::MemoryPool::destroy()'
main.o: In function `fruit::impl::SemistaticGraph<fruit::impl::TypeId, fruit::impl::NormalizedBinding>::at(fruit::impl::TypeId)':
/usr/include/fruit/impl/data_structures/semistatic_graph.defn.h:125: undefined reference to `fruit::impl::SemistaticMap<fruit::impl::TypeId, fruit::impl::SemistaticGraphInternalNodeId>::at(fruit::impl::TypeId) const'
main.o: In function `fruit::Injector<Logger>::Injector<>(fruit::Component<Logger> (*)())':
/usr/include/fruit/impl/injector.defn.h:37: undefined reference to `fruit::impl::InjectorStorage::InjectorStorage(fruit::impl::ComponentStorage&&, std::vector<fruit::impl::TypeId, fruit::impl::ArenaAllocator<fruit::impl::TypeId> > const&, fruit::impl::MemoryPool&)'
main.o: In function `std::default_delete<fruit::impl::InjectorStorage>::operator()(fruit::impl::InjectorStorage*) const':
/usr/include/c++/5/bits/unique_ptr.h:76: undefined reference to `fruit::impl::InjectorStorage::~InjectorStorage()'
collect2: error: ld returned 1 exit status

g++ version:

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu1~16.04.10' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.10)

main.cpp

#include <fruit/fruit.h>
#include <iostream>
#include "Logger.h"

int main(int argc, char const *argv[])
{
    fruit::Injector<Logger> injector(getLoggerImplComponent);
    Logger* logger = injector.get<Logger*>();
    logger->Log("Hello");
    /* code */
    return 0;
}

Logger.h

#include <string>

class Logger {
public:
    virtual void Log(const std::string& s) = 0;
};

fruit::Component<Logger> getLoggerImplComponent();

LoggerImpl.cpp

#include <fruit/fruit.h>
#include <iostream>
#include "Logger.h"

class LoggerImpl : public Logger {
public:
    INJECT(LoggerImpl()) = default;

    virtual void Log(const std::string &s) override {
        std::cout << s;
    }
};

fruit::Component<Logger> getLoggerImplComponent() {
    return fruit::createComponent()
        .bind<Logger, LoggerImpl>();
}

$ g++ -std=c++11 -g main.cpp LoggerImpl.cpp

Using Fruit 3.1.1 installed from the apt repo

from fruit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.