Hi,
Thank you Lukas for looking at my problem.
The LSS-version of Nightshade is a clone of the official Nightsade version
+ keyboard shortcuts which can launch scripts, videos and music.
Each key of the 105 keys has a special function and it is specially
designed for a planetarium public show.
With bluetooth modules, we can drive the show with a Nintendo Wii remote ;
very useful.
http://www.lss-planetariums.info/index.php?lang=en&menu=hardware&page=keyboard
I tried to compile Nightshade-LSS on Ubuntu-12, Linux Mint and Mageia2 via
VirtualBox and i get exactly the same errors.
So, i think it is not a Gentoo problem...but nevertheless very annoying :-(
I looked at the Nightshade-LSS sources and it seems that the error occurs
with the nshade_shared_memory.h and nshade_shared_memory.cpp in
~/nightshade-11.7.1/nscontrol/src
I join the two files ; may be these files would help us.
Thank you very much,
--
Jacques
2012/10/10 mindrunner <[email protected]>
> Hi,
> i stepped little further in the last hours. I copied the ebuild to my
> layman overlay (luman) and tried to emerge. I got the same error you got
> compiling your special version!
> At the moment I am cloning the official bzr repository (>1GB) which
> means waiting a long time at 1mbit DSL :(
> When cloned, I will dig some more into the sources.
>
> the error we get here points to some wrong usage of the boost container,
> but i cannot tell any more right now.
>
> what exactly is the difference to your ns-version compared to vanilla one?
>
> I think just replacing version number and url should provide you a
> working ebuild.
> we can try this after compiling vanilla sucesfull.
>
>
> lukas
>
> On 10/09/2012 10:53 PM, Jacques Montier wrote:
> > Hi ,
> >
> > Thank you Lukas for your post.
> > The Nighshade soft i use is a LSS version compiled for small
> > planetariums by Yves Lhoumeau and Lionel Ruiz.
> > I can only get the sources here :
> >
> http://www.lss-planetariums.info/index.php?lang=en&menu=nightshade&page=nightshade
> > The sabayon Nightshade ebuild is different .
> > I agree with you, i very much prefer to install packages using ebuilds,
> > but i am afraid i am not able to develop any ebuild...
> > Sorry... :-(
> > Some months ago i successfully compiled Nightshade with boost-1.46.1-r1
> > ; but unfortunately it does not anymore compile even with the same boost
> > version...
> >
> > Thank you again,
> >
> > Cheers,
> >
> > --
> > Jacques
> >
> >
> > 2012/10/9 mindrunner <[email protected] <mailto:[email protected]>>
> >
> > Hi,
> > I always prefer to NOT install software this way into my gentoo.
> Instead
> > of this I first check http://gpo.zugaina.org/ if there is already an
> > ebuild or outdated ebuild for this piece of software. If not I begin
> to
> > develop my own ebuild.
> >
> > In this case there is already one (sabayon-overlay). However, you
> should
> > NOT add sabayon overlay into your gentoo box. I got some weird
> problems
> > doing this some time ago. I think this shoul only be used in sabayon
> > distro, but I dont know exactly.
> >
> > If you want to, I could copy it into my overlay (luman), which
> should be
> > more safe not bricking your whole gentoo box.
> >
> > Yeah, I know... you asked sth. completely different, but in my
> opinion,
> > you should better do this way...
> >
> > KLooking at you Problem tells me that you got a boost problem. Maybe
> > wrong version you compile against?
> >
> > Since I am writing my bachelor thesis right now, I have only little
> > spartetime, but if you want to we could try to make a working ebuild
> on
> > base of the sabayon one.
> >
> >
> > regards
> > Lukas
> >
> >
> > On 10/09/2012 07:06 PM, Jacques Montier wrote:
> > > Hi everybody,
> > >
> > > Since a few months i have a problem about compiling Nightshade
> soft.
> > > Nightshade is a full dome planetarium opensource software.
> > >
> >
> http://www.lss-planetariums.info/index.php?lang=en&menu=nightshade&page=nightshade
> > > Nightshade is not in portage so i have to manually install it
> > > (./configure, make and make install).
> > > make fails with errors :
> > >
> > > -------------------------
> > > In file included from /usr/include/boost/container/map.hpp:26:0,
> > > from
> > /usr/include/boost/interprocess/containers/map.hpp:19,
> > > from nshade_shared_memory.h:34,
> > > from nshade_shared_memory.cpp:30:
> > > ------------------------
> > > -----------------------
> > > boost::interprocess::iset_index> > >, bool is_iterator = false, P0
> =
> > > std::less<boost::uuids::uuid>, P1 =
> > >
> >
> boost::interprocess::allocator<boost::container::container_detail::pair<boost::uuids::uuid,
> > > boost::interprocess::offset_ptr<NshadeSharedMemoryConnection> >,
> > > boost::interprocess::segment_manager<char,
> > >
> >
> boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family>,
> > > boost::interprocess::iset_index> >, size_t = long unsigned int]’
> > > nshade_shared_memory.cpp:251:1: instantiated from here
> > > /usr/include/boost/container/map.hpp:147:1: erreur: invalid
> > application
> > > of ‘sizeof’ to incomplete type
> > ‘boost::STATIC_ASSERTION_FAILURE<false>’
> > > make[4]: *** [nshade_shared_memory.lo] Erreur 1
> > >
> > > I don't know how to solve that problem.
> > > Have you any idea about it ?
> > > Thank you very much,
> > >
> > > Cheers,
> > >
> > > --
> > > Jacques
> >
> >
>
>
/*
* Copyright (C) 2010 Digitalis Education Solutions, Inc.
* Author: Trystan Larey-Williams
* Date: 2-22-2010
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* Nightshade is a trademark of Digitalis Education Solutions, Inc.
* See the TRADEMARKS file for trademark usage requirements.
*
*/
/*
* Helper class to manage named shared memory resources wraps read and write
* calls in mutex for IPC safety
*/
#include "nshade_shared_memory.h"
using namespace boost::interprocess;
using namespace std;
NshadeSharedMemory::NshadeSharedMemory() {
m_clsid = boost::uuids::random_generator()();
m_shm = new managed_shared_memory( open_or_create, "/nightshadeSM", 4096000 );
const ShmAlloc allocator( m_shm->get_segment_manager() );
m_connections = m_shm->find_or_construct<ShmMap>(unique_instance)(std::less<boost::uuids::uuid>(), allocator);
m_mutex = m_shm->find_or_construct<interprocess_mutex>("global_mutex")();
m_readerMutex = m_shm->find_or_construct<interprocess_mutex>("reader_mutex")();
m_writerMutex = m_shm->find_or_construct<interprocess_mutex>("writer_mutex")();
m_writeState = m_shm->find_or_construct<NshadeWriteState>(unique_instance)(m_shm);
m_readState = m_shm->find_or_construct<NshadeReadState>(unique_instance)(m_shm);
m_refCount = m_shm->find_or_construct<ReferenceCounter>(unique_instance)();
m_nsConf = m_shm->find_or_construct<NshadeConf>(unique_instance)(m_shm);
m_readPtr = m_shm->find_or_construct<RTQPtr>("read_ptr")();
m_writePtr = m_shm->find_or_construct<RTQPtr>("write_ptr")();
m_RTQGap = m_shm->find_or_construct<RTQGap>(unique_instance)();
if( m_refCount->m_ref == 0 ) {
cout << "Nightshade Shared Memory Segment Initialized.\n";
// Initialize 'fast' circular message buffer
*m_writePtr = m_shm->construct<RTQueueNode>(anonymous_instance)();
offset_ptr<RTQueueNode> tmp = *m_writePtr;
for( unsigned int i = 0; i < RTQSIZE; i++ ) {
tmp->next = m_shm->construct<RTQueueNode>(anonymous_instance)();
tmp = tmp->next;
}
*m_readPtr = tmp; // Initialize reader one node behind writer
tmp->next = *m_writePtr; // Close the circle
*m_RTQGap = 1;
}
m_refCount->m_ref++;
m_clientType = NshadeSharedMemoryConnection::user;
}
NshadeSharedMemory::~NshadeSharedMemory() {
if( --m_refCount->m_ref == 0 ) {
// Remove any unreleased connection objects
for( ShmMap::iterator itr = m_connections->begin(); itr != m_connections->end(); itr++ ) {
m_shm->destroy_ptr( (itr->second).get() );
}
m_connections->clear();
// Cleanup shared instances
try {
m_shm->destroy<interprocess_mutex>("global_mutex");
m_shm->destroy<interprocess_mutex>("reader_mutex");
m_shm->destroy<interprocess_mutex>("writer_mutex");
m_shm->destroy<NshadeReadState>(unique_instance);
m_shm->destroy<NshadeWriteState>(unique_instance);
m_shm->destroy<RTQPtr>("read_ptr");
m_shm->destroy<RTQPtr>("write_ptr");
m_shm->destroy<RTQGap>(unique_instance);
m_shm->destroy<NshadeConf>(unique_instance);
m_shm->destroy<ReferenceCounter>(unique_instance);
m_shm->destroy<ShmMap>(unique_instance);
}
catch( ... ) {
printf("Warning: Not all shared memory objects could be destroyed.\n");
}
// Tear-down shared memory
delete m_shm;
shared_memory_object::remove( "nightshadeSM" );
cout << "Nightshade Shared Memory Segment Removed.\n";
}
else
delete m_shm;
}
void NshadeSharedMemory::Connect( void ) {
m_mutex->lock();
if( m_connections->find(m_clsid) == m_connections->end() ) {
offset_ptr<NshadeSharedMemoryConnection> obj = m_shm->construct<NshadeSharedMemoryConnection>(anonymous_instance)( m_shm );
obj->SetOwner( m_clsid );
obj->SetClientType( m_clientType );
(*m_connections)[m_clsid] = obj;
}
m_mutex->unlock();
}
void NshadeSharedMemory::Disconnect( void ) {
m_mutex->lock();
ShmMap::iterator itr = m_connections->find(m_clsid);
if( itr != m_connections->end() ) {
m_shm->destroy_ptr( (itr->second).get() );
m_connections->erase( m_clsid );
}
m_mutex->unlock();
}
boost::interprocess::offset_ptr<NshadeConf> NshadeSharedMemory::Config( void ) {
return m_nsConf;
}
void NshadeSharedMemory::SetClientType( NshadeSharedMemoryConnection::Type type ) {
m_clientType = type;
}
bool NshadeSharedMemory::TryLock() {
return m_mutex->try_lock();
}
void NshadeSharedMemory::Lock() {
m_mutex->lock();
}
void NshadeSharedMemory::UnLock() {
m_mutex->unlock();
}
bool NshadeSharedMemory::Read( std::string& data ) {
bool have_data = false;
// cerr << "Available Shared Memory: " << m_shm->get_segment_manager()->get_free_memory() << endl;
m_mutex->lock();
try {
ShmMap::iterator itr = m_connections->find(m_clsid);
if( itr != m_connections->end() && !itr->second->Empty() ) {
have_data = true;
NshadeCommand cmd = itr->second->DeQueue();
data = std::string( cmd.buf, cmd.length );
}
}
catch( std::exception& e ) {
m_mutex->unlock();
cerr << e.what() << endl;
cerr << "Available Shared Memory: " << m_shm->get_segment_manager()->get_free_memory() << endl;
throw e;
}
m_mutex->unlock();
return have_data;
}
void NshadeSharedMemory::Write( std::string data ) {
m_mutex->lock();
try {
NshadeCommand cmd;
unsigned int len = data.length();
if( len >= NshadeCommand::szBuf )
len = NshadeCommand::szBuf - 1;
memcpy( (void*)cmd.buf, (void*)data.c_str(), len );
cmd.length = len;
for( ShmMap::iterator itr = m_connections->begin(); itr != m_connections->end(); itr++ ) {
if( itr->second->Owner() != m_clsid && itr->second->ClientType() != m_clientType ) {
itr->second->Queue( cmd );
}
}
}
catch( std::exception& e ) {
m_mutex->unlock();
cerr << e.what() << endl;
cerr << "Available Shared Memory: " << m_shm->get_segment_manager()->get_free_memory() << endl;
throw e;
}
m_mutex->unlock();
}
///////////////////////////////////////////////////////////////////////////////
// Experimental performance oriented RW methods. Do not currently have much
// effect on performance in practice and more effort is needed to integrate and
// encapsulate their data structures.
///////////////////////////////////////////////////////////////////////////////
bool NshadeSharedMemory::ReadRT( std::string& data ) {
m_readerMutex->lock();
m_mutex->lock();
bool empty = *m_RTQGap == 1;
m_mutex->unlock();
if( empty ) {
m_readerMutex->unlock();
return false;
}
*m_readPtr = (*m_readPtr)->next;
data = std::string( (*m_readPtr)->msg.buf, (*m_readPtr)->msg.length );
m_mutex->lock();
--(*m_RTQGap);
m_mutex->unlock();
m_readerMutex->unlock();
return true;
}
void NshadeSharedMemory::WriteRT( std::string data ) {
m_writerMutex->lock();
m_mutex->lock();
bool full = *m_RTQGap == (RTQSIZE - 1);
m_mutex->unlock();
if( full ) {
m_writerMutex->unlock();
return;
}
unsigned int len = data.length();
if( len >= NshadeCommand::szBuf )
len = NshadeCommand::szBuf - 1;
memcpy( (void*)(*m_writePtr)->msg.buf, (void*)data.c_str(), len );
(*m_writePtr)->msg.length = len;
*m_writePtr = (*m_writePtr)->next;
m_mutex->lock();
++(*m_RTQGap);
m_mutex->unlock();
m_writerMutex->unlock();
}
/*
* Copyright (C) 2010 Digitalis Education Solutions, Inc.
* Author: Trystan Larey-Williams
* Date: 2-22-2010
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* Nightshade is a trademark of Digitalis Education Solutions, Inc.
* See the TRADEMARKS file for trademark usage requirements.
*
*/
/*
* Helper class to manage named shared memory resources wraps read and write
* calls in mutex for IPC safety
*/
#pragma once
#include "nshade_shared_memory_connection.h"
#include "nshade_state.h"
#include <boost/interprocess/containers/map.hpp>
#include <boost/interprocess/containers/pair.hpp>
#include <boost/interprocess/allocators/allocator.hpp>
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_generators.hpp>
// A single instance of this object is loaded into shared memory to track the number of active
// SharedMemory objects. When an instance of SharedMemory is destroyed it will check the count.
// If zero, the shared memory segment will be cleaned up and all shared data removed.
struct ReferenceCounter {
ReferenceCounter() { m_ref = 0; };
unsigned long m_ref;
};
class NshadeSharedMemory {
public:
NshadeSharedMemory();
virtual ~NshadeSharedMemory();
void Connect( void );
void Disconnect( void );
bool ReadRT( std::string& data );
void WriteRT( std::string data );
bool Read( std::string& data );
void Write( std::string data );
boost::interprocess::offset_ptr<NshadeConf> Config( void );
void SetClientType( NshadeSharedMemoryConnection::Type );
// For nightshade suspend checking
void Lock( void );
void UnLock( void );
bool TryLock( void );
// end nightshade suspend checking
boost::interprocess::offset_ptr<NshadeWriteState> m_writeState;
boost::interprocess::offset_ptr<NshadeReadState> m_readState;
private:
static const unsigned int RTQSIZE = 100;
// Type definitions for IPC friendly linked-list container of connections to shared memory]
typedef boost::interprocess::pair<boost::uuids::uuid,
boost::interprocess::offset_ptr<NshadeSharedMemoryConnection> > ConnectionPair;
typedef boost::interprocess::allocator<ConnectionPair,
boost::interprocess::managed_shared_memory::segment_manager> ShmAlloc;
typedef boost::interprocess::map<boost::uuids::uuid,
boost::interprocess::offset_ptr<NshadeSharedMemoryConnection>, std::less<boost::uuids::uuid>, ShmAlloc> ShmMap;
// Unique (for each process) pointer to shared memory
boost::interprocess::managed_shared_memory* m_shm;
// Pointers to shared objects within shared memory
boost::interprocess::offset_ptr<NshadeConf> m_nsConf;
boost::interprocess::offset_ptr<ReferenceCounter> m_refCount;
boost::interprocess::offset_ptr<ShmMap> m_connections;
boost::interprocess::offset_ptr<RTQPtr> m_writePtr;
boost::interprocess::offset_ptr<RTQPtr> m_readPtr;
boost::interprocess::offset_ptr<RTQGap> m_RTQGap;
boost::interprocess::offset_ptr<boost::interprocess::interprocess_mutex> m_mutex;
boost::interprocess::offset_ptr<boost::interprocess::interprocess_mutex> m_readerMutex;
boost::interprocess::offset_ptr<boost::interprocess::interprocess_mutex> m_writerMutex;
NshadeSharedMemoryConnection::Type m_clientType;
boost::uuids::uuid m_clsid;
};