943,686 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 948
  • C++ RSS
Oct 28th, 2008
0

Errors compiling Loki on Mandriva One Spring 2008

Expand Post »
Hello,

I am writing an application that uses the Loki library and I get undefined references inside loki if I use the DefaultSPStorage with std::vector<int> (it happens the same with int or using HeapStorage instead). I am developing on Mandriva 2008. Can someone please help me?

Thank you in advance
Rui

main.cpp:
C++ Syntax (Toggle Plain Text)
  1. #include "include/loki/SmartPtr.h"
  2. #include "Solution.h"
  3. #include <iostream>
  4.  
  5. using namespace brickheuristics;
  6.  
  7. int main(void){
  8.  
  9. typedef Loki::DefaultSPStorage< std::vector<int> > SolStorage;
  10. typedef Solution<
  11. SolStorage,
  12. DummyEval,
  13. DummyFeasibility,
  14. DummyChanging,
  15. DummyPrinting
  16. > MySolution;
  17.  
  18. MySolution s = MySolution();
  19. cout << s.toString();
  20. return 0;
  21. }

Compiler output:
C++ Syntax (Toggle Plain Text)
  1. g++ -O2 -g -Wall -fmessage-length=0 -c -o main.o main.cpp
  2. g++ -o main.exe main.o
  3. main.o: In function `Loki::SmallObjectBase<Loki::SingleThreaded, 4096u, 256u, 4u, Loki::LongevityLifetime::DieAsSmallObjectParent, Loki::Mutex>::operator new(unsigned int)':
  4. /home/rmlopes/brickheuristics/src/include/loki/SmallObj.h:467: undefined reference to `Loki::SmallObjAllocator::Allocate(unsigned int, bool)'
  5. main.o: In function `Loki::SmallObjectBase<Loki::SingleThreaded, 4096u, 256u, 4u, Loki::LongevityLifetime::DieAsSmallObjectParent, Loki::Mutex>::operator delete(void*, unsigned int)':
  6. /home/rmlopes/brickheuristics/src/include/loki/SmallObj.h:489: undefined reference to `Loki::SmallObjAllocator::Deallocate(void*, unsigned int)'
  7. /home/rmlopes/brickheuristics/src/include/loki/SmallObj.h:489: undefined reference to `Loki::SmallObjAllocator::Deallocate(void*, unsigned int)'
  8. /home/rmlopes/brickheuristics/src/include/loki/SmallObj.h:489: undefined reference to `Loki::SmallObjAllocator::Deallocate(void*, unsigned int)'
  9. /home/rmlopes/brickheuristics/src/include/loki/SmallObj.h:489: undefined reference to `Loki::SmallObjAllocator::Deallocate(void*, unsigned int)'
  10. main.o: In function `AllocatorSingleton':
  11. /home/rmlopes/brickheuristics/src/include/loki/SmallObj.h:245: undefined reference to `Loki::SmallObjAllocator::SmallObjAllocator(unsigned int, unsigned int, unsigned int)'
  12. main.o: In function `~AllocatorSingleton':
  13. /home/rmlopes/brickheuristics/src/include/loki/SmallObj.h:249: undefined reference to `Loki::SmallObjAllocator::~SmallObjAllocator()'
  14. main.o: In function `void Loki::SetLongevity<Loki::AllocatorSingleton<Loki::SingleThreaded, 4096u, 256u, 4u, Loki::LongevityLifetime::DieAsSmallObjectParent, Loki::Mutex>, Loki::Private::Adapter<Loki::AllocatorSingleton<Loki::SingleThreaded, 4096u, 256u, 4u, Loki::LongevityLifetime::DieAsSmallObjectParent, Loki::Mutex> > >(Loki::AllocatorSingleton<Loki::SingleThreaded, 4096u, 256u, 4u, Loki::LongevityLifetime::DieAsSmallObjectParent, Loki::Mutex>*, unsigned int, Loki::Private::Adapter<Loki::AllocatorSingleton<Loki::SingleThreaded, 4096u, 256u, 4u, Loki::LongevityLifetime::DieAsSmallObjectParent, Loki::Mutex> >)':
  15. /home/rmlopes/brickheuristics/src/include/loki/Singleton.h:154: undefined reference to `Loki::Private::pTrackerArray'
  16. /home/rmlopes/brickheuristics/src/include/loki/Singleton.h:166: undefined reference to `Loki::Private::pTrackerArray'
  17. /home/rmlopes/brickheuristics/src/include/loki/Singleton.h:169: undefined reference to `Loki::Private::pTrackerArray'
  18. /home/rmlopes/brickheuristics/src/include/loki/Singleton.h:175: undefined reference to `Loki::Private::AtExitFn()'
  19. /home/rmlopes/brickheuristics/src/include/loki/Singleton.h:155: undefined reference to `Loki::Private::pTrackerArray'
  20. main.o: In function `AllocatorSingleton':
  21. /home/rmlopes/brickheuristics/src/include/loki/SmallObj.h:245: undefined reference to `Loki::SmallObjAllocator::SmallObjAllocator(unsigned int, unsigned int, unsigned int)'
  22. main.o: In function `Loki::SmallObjectBase<Loki::SingleThreaded, 4096u, 256u, 4u, Loki::LongevityLifetime::DieAsSmallObjectParent, Loki::Mutex>::operator delete(void*, unsigned int)':
  23. /home/rmlopes/brickheuristics/src/include/loki/SmallObj.h:489: undefined reference to `Loki::SmallObjAllocator::Deallocate(void*, unsigned int)'
  24. /home/rmlopes/brickheuristics/src/include/loki/SmallObj.h:489: undefined reference to `Loki::SmallObjAllocator::Deallocate(void*, unsigned int)'
  25. collect2: ld returned 1 exit status
  26. make: *** [main.exe] Error 1
Last edited by rmlopes; Oct 28th, 2008 at 6:09 am.
Reputation Points: 10
Solved Threads: 0
Light Poster
rmlopes is offline Offline
31 posts
since Sep 2008
Oct 28th, 2008
0

Re: Errors compiling Loki on Mandriva One Spring 2008

hmm, the thread name is kind of missguiding
this should better be "error linking to loki"
as you can see all your .o files compile fine, but the linking is the problem

did you build the Loki library?

I know Loki is mostly a template library that need not be compiled, but I think it has some parts that maybe do need to be compiled (just like boost is with it's concurrency and networking classes). Your example looks like this could be the case.

Look at the methods that you have undefined refrence to, compile the source files that they appear in, and then when you build your main.exe link to all the required object files
kux
Reputation Points: 66
Solved Threads: 11
Junior Poster
kux is offline Offline
119 posts
since Jan 2008
Oct 28th, 2008
0

Re: Errors compiling Loki on Mandriva One Spring 2008

Hello,

You're right, the title was a little bit unfortunate. Indeed the problem is that part of the library must be compiled. I linked the libloki.a and the problem is gone.

Thank you and kind regards,
Rui
Reputation Points: 10
Solved Threads: 0
Light Poster
rmlopes is offline Offline
31 posts
since Sep 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Simple Data Type
Next Thread in C++ Forum Timeline: DWM 2





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC