You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by bpmuser <br...@nrc.ca> on 2009/10/22 15:39:52 UTC
ActiveMq-Cpp std::vector and dll problem
I've been working with the ActiveMq-Cpp interface through a dll in windows
and I think I've fallen into stl-dll hell.
I was attempting to use:
MapMessage.h : virtual std::vector< std::string > getMapNames() const throw(
CMSException ) = 0;
or
Message.h: virtual std::vector<std::string> getPropertyNames() const throw(
CMSException ) = 0;
I started getting crashes whenever the returned vector fell out of scope. I
think this is related to stl and dll's not playing nicely with memory
management. If this is the cause of the problem then I see two possible
solutions (unless there is a more friendly way to access the map already).
1) Rework the functions
MapMessage.h : virtual void getMapNames(std::vector< std::string >&) const
throw( CMSException ) = 0;
or
Message.h: virtual getPropertyNames(std::vector< std::string >&) const
throw( CMSException ) = 0;
But I've never tested this so I'm not sure if it work properly, or if you
still have the same problem.
2) Add accessory functions
MapMessage.h : virtual size_t getMapNameCount() const throw( CMSException )
= 0;
and
MapMessage.h : virtual std::string getMapName(size_t) const throw(
CMSException ) = 0;
or
MapMessage.h : virtual void getMapName(size_t, std::string &) const throw(
CMSException ) = 0;
I've never taken on this problem before so I have no clue what would work.
Any insight would be really appreciated.
Brian!
--
View this message in context: http://www.nabble.com/ActiveMq-Cpp-std%3A%3Avector-and-dll-problem-tp26010092p26010092.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
Re: ActiveMq-Cpp std::vector and dll problem
Posted by Timothy Bish <ta...@gmail.com>.
On Thu, 2009-10-22 at 12:48 -0700, bpmuser wrote:
>
>
> Timothy Bish wrote:
> >
> >
> > Have you ensured that the application is linked against the same version
> > the runtime library as the DLL? ActiveMQ-CPP requires your application
> > to use the Multithreaded DLL Runtime Library, Debug or Release depending
> > on which AMQCPP dll you are using.
> >
> >
>
> Oh yeah... file that under the "I'm an idiot category". I built the dll in
> vs2005 and tried to link in vs2008. I'm recompiling right now!
>
> Thanks,
> Brian!
Ok, well that's good, our tests use those functions and don't fail so I
was kind of confused.
Regards
Tim.
--
Tim Bish
http://fusesource.com
http://timbish.blogspot.com/
Re: ActiveMq-Cpp std::vector and dll problem
Posted by bpmuser <br...@nrc.ca>.
Timothy Bish wrote:
>
>
> Have you ensured that the application is linked against the same version
> the runtime library as the DLL? ActiveMQ-CPP requires your application
> to use the Multithreaded DLL Runtime Library, Debug or Release depending
> on which AMQCPP dll you are using.
>
>
Oh yeah... file that under the "I'm an idiot category". I built the dll in
vs2005 and tried to link in vs2008. I'm recompiling right now!
Thanks,
Brian!
--
View this message in context: http://www.nabble.com/ActiveMq-Cpp-std%3A%3Avector-and-dll-problem-tp26010092p26016088.html
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
Re: ActiveMq-Cpp std::vector and dll problem
Posted by Timothy Bish <ta...@gmail.com>.
On Thu, 2009-10-22 at 06:39 -0700, bpmuser wrote:
> I've been working with the ActiveMq-Cpp interface through a dll in windows
> and I think I've fallen into stl-dll hell.
>
> I was attempting to use:
>
> MapMessage.h : virtual std::vector< std::string > getMapNames() const throw(
> CMSException ) = 0;
> or
> Message.h: virtual std::vector<std::string> getPropertyNames() const throw(
> CMSException ) = 0;
>
> I started getting crashes whenever the returned vector fell out of scope. I
> think this is related to stl and dll's not playing nicely with memory
> management. If this is the cause of the problem then I see two possible
> solutions (unless there is a more friendly way to access the map already).
>
> 1) Rework the functions
>
> MapMessage.h : virtual void getMapNames(std::vector< std::string >&) const
> throw( CMSException ) = 0;
> or
> Message.h: virtual getPropertyNames(std::vector< std::string >&) const
> throw( CMSException ) = 0;
>
> But I've never tested this so I'm not sure if it work properly, or if you
> still have the same problem.
>
> 2) Add accessory functions
>
> MapMessage.h : virtual size_t getMapNameCount() const throw( CMSException )
> = 0;
> and
> MapMessage.h : virtual std::string getMapName(size_t) const throw(
> CMSException ) = 0;
> or
> MapMessage.h : virtual void getMapName(size_t, std::string &) const throw(
> CMSException ) = 0;
>
> I've never taken on this problem before so I have no clue what would work.
> Any insight would be really appreciated.
>
Have you ensured that the application is linked against the same version
the runtime library as the DLL? ActiveMQ-CPP requires your application
to use the Multithreaded DLL Runtime Library, Debug or Release depending
on which AMQCPP dll you are using.
Regards
Tim.
--
Tim Bish
http://fusesource.com
http://timbish.blogspot.com/