[odb-users] Problem - Using ODB inside a DLL

Cuong Minh Tran vaioinman at googlemail.com
Fri Jan 6 11:50:32 EST 2012

Hi Boris,

I have a small discover regarding my problem. If I just specify the project `test' in your sample project to link with odb.lib and odd-mysql.lib, the problem disappears.

Hope this helps.

Best regards,


On 11 Dec 2011, at 19:59, Cuong Minh Tran wrote:

> Hi Boris,
> Great thanks to your reply. I will try your COM DLL project and communicate the progress.
> Nonetheless, looking back through the archives, I found my problem to be very much like this:
> http://www.codesynthesis.com/pipermail/odb-users/2011-June/000127.html
> But the archive does not seem to contain the solution.
> Best regards,
> Cuong
> On 11 Dec 2011, at 13:22, Boris Kolpackov wrote:
>> Hi Cuong,
>> Cuong Minh Tran <vaioinman at googlemail.com> writes:
>>> I am trying to use the set ODB - MYSQL/SQLite version 1.6 in my COM DLL,
>>> developed in MSVC 2010. I had no issues with compiling libodb, 
>>> libodb-mysql/sqlite on the same machine with my COM. My COM code also
>>> compiles without a problem. However, I want to trigger the COM in my
>>> application, the execution always fails at the (*) line:
>>>        ...
>>>        // create database pointer
>>>   std::auto_ptr<odb::database> db ( create_database ( ) );
>>> (*) odb::transaction t (db->begin ());
>>>   //persist an simple object
>> It is hard to say what's going on without knowing exactly how you
>> created your "COM DLL" and without seeing the create_database()
>> database implementation. One fairly common cause would be if ODB
>> is unable to connect to the database (which in this case will
>> happen during the db->begin () call) though you said that
>> everything works fine in plain Win32 setup so it is probably not
>> it.
>> In any case, I went ahead and created a test "COM DLL" project as
>> described on this page:
>> http://msdn.microsoft.com/en-us/library/dssw0ch4(v=VS.90).aspx
>> I then added code similar to the above to the property's get_XXX()
>> function. However, everything is working fine for me. Could you try
>> this project and see if it works for you?
>> http://www.codesynthesis.com/~boris/tmp/odb/com_dll.zip
>> You will need to make some modifications in Object1.cpp to use
>> your MySQL connection parameters before you can run the test.
>> If it works for you as well, then you can try to modify it to
>> resemble your code until it fails. Then I would be able to take
>> a look.
>> Boris

More information about the odb-users mailing list