|
Posted by hgernhardt
at Feb 14, 2011 6:53:13 AM
|
Retrieving a random bible verse
Folks—
I'm trying to get a random bible verse out of a Bible module. Given, what I'm about to go into is C++/Linux/Ubuntu stuffs, so if you know of a good tool/option that will let me do this easily, I'll be almost as happy. Caveat: The generated random verse must either be a protestant canon address, or be retrieved from an installed Bible module.
On to the technical stuffs, then!
Here's the issue: I can't get any of my test programs to run without a segfault.
My test code:
#include <swmgr.h> #include <swmodule.h> #include <iostream>
using sword::SWMgr; using sword::SWModule; using sword::SWKey; using sword::ModMap; using std::cout;
int main () { SWMgr library; SWModule *curModule = 0; ModMap::iterator it; for (it = library.Modules.begin(); it != library.Modules.end(); it++) { curModule = (*it).second; cout << curModule->Name() << std::endl; } return 0; }
My compile line:
g++ -g -D_GLIBCXX_DEBUG -I/usr/include/sword -lsword randomverse.cpp -o randomverse
The funny thing is that the segfault occurs not within the sword functionality, but within the standard c++ library:
#0 0x00007ffff77cb965 in __gnu_debug::_Safe_iterator_base::_M_attach_single(__gnu_debug::_Safe_sequence_base*, bool) () from /usr/lib/libstdc++.so.6 #1 0x00007ffff77cbd62 in __gnu_debug::_Safe_iterator_base::_M_attach(__gnu_debug::_Safe_sequence_base*, bool) () from /usr/lib/libstdc++.so.6 #2 0x0000000000401372 in __gnu_debug::_Safe_iterator_base::_Safe_iterator_base ( this=0x7fffffffe060, __seq=0x7fffffffdfe8, __constant=false) at /usr/include/c++/4.4/debug/safe_base.h:90 #3 0x00000000004019eb in __gnu_debug::_Safe_iterator<std::_Rb_tree_iterator<std::pair<sword::SWBuf const, sword::SWModule*> >, std::__debug::map<sword::SWBuf, sword::SWModule*, std::less<sword::SWBuf>, std::allocator<std::pair<sword::SWBuf const, sword::SWModule*> > > >::_Safe_iterator ( ---Type <return> to continue, or q <return> to quit--- this=0x7fffffffe060, __i=..., __seq=0x7fffffffdfb8) at /usr/include/c++/4.4/debug/safe_iterator.h:109 #4 0x000000000040172a in std::__debug::map<sword::SWBuf, sword::SWModule*, std::less<sword::SWBuf>, std::allocator<std::pair<sword::SWBuf const, sword::SWModule*> > >::begin ( this=0x7fffffffdfb8) at /usr/include/c++/4.4/debug/map.h:139 #5 0x0000000000400fdd in main () at src/randomverse.cpp:16
I have a sneaky suspicion that I'm failing to include a necessary library or something. My system is Ubuntu 10.10, and I've installed build-essentials and libsword-dev. Am I missing anything?
Thanks and God bless!
|