DatabaseLayer as a DLL Topic is solved

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
Post Reply
rodrigod
I live to help wx-kind
I live to help wx-kind
Posts: 172
Joined: Thu Jun 26, 2008 8:50 pm

DatabaseLayer as a DLL

Post by rodrigod »

I was using databaselayer statically no problem there. Though when I tried to change it to a dll i noticed that it didn't create a .lib file. After some investigation I realized that there is not a single export in any file. So that's why there was no lib file.

So how do I use this library dinamically? Because all my libraries are all linking dinamically to everything so I cant leave just this one library linked statically because they will end up using different Runtime libraries. Has anyone run into this problem before?

Thanks
mja2112
In need of some credit
In need of some credit
Posts: 6
Joined: Thu Jan 22, 2009 5:48 pm

DLL

Post by mja2112 »

I have the same issue.
I am using codeblocks with wxwidgets from wxpack.
Did you compile widgets yourself?

I have also noticed I can't create any new wxwidgets projects using the static build- if I do I get a bunch of undef refs at link.

databaselayer is the exact opposite- it can create the static lib but not the dll.
mja2112
In need of some credit
In need of some credit
Posts: 6
Joined: Thu Jan 22, 2009 5:48 pm

Fixed

Post by mja2112 »

Fixed!

I downloaded msvc express 2008- rebuilt wxwidgets and databaselayer (I was using the builds from wxpack).
Setup codeblocks to use the ms compiler and everything works now.
rodrigod
I live to help wx-kind
I live to help wx-kind
Posts: 172
Joined: Thu Jun 26, 2008 8:50 pm

Post by rodrigod »

My problem was that DatabaseLayer wasn't exporting any classes. So I had to add a WXEXPORTS on the classes that needed exporting and it's ok now.

But here is the idea to jbcoder to add this to the library.


Bye
jb_coder
Super wx Problem Solver
Super wx Problem Solver
Posts: 267
Joined: Mon Oct 18, 2004 10:55 am

Post by jb_coder »

Do you remember which classes needed to be exported for the library to work for you?
rodrigod
I live to help wx-kind
I live to help wx-kind
Posts: 172
Joined: Thu Jun 26, 2008 8:50 pm

Post by rodrigod »

jb_coder,

I only use odbc and postgre, so what I did was simply add WXEXPORT on all the classes contained in the headers of each of these projects. It's not much work, and since i didn't know exactly which one of these classes I use or will use I thought better to export all the classes. Worked as a charm if you want I can send you the headers of the odbc and postgres project.

See ya
jb_coder
Super wx Problem Solver
Super wx Problem Solver
Posts: 267
Joined: Mon Oct 18, 2004 10:55 am

Post by jb_coder »

I wonder if it would work to only export the base classes

Code: Select all

DatabaseLayer
PreparedStatement
ResultSet
ResultSetMetaData
DatabaseLayerException
and the main DatabaseLayer classes of each derived backend

Code: Select all

SqliteDatabaseLayer
PostgresDatabaseLayer
OdbcDatabaseLayer
MysqlDatabaseLayer
FirebirdDatabaseLayer
rodrigod
I live to help wx-kind
I live to help wx-kind
Posts: 172
Joined: Thu Jun 26, 2008 8:50 pm

Post by rodrigod »

there is one other detail, is not just add wxexport you need to define a macro for it to choose either to export or import
here is what I did:

Code: Select all

#ifdef DLL_EXPORTS
#define EXPORT WXEXPORT
#else
#define EXPORT WXIMPORT
#endif

class EXPORT
just did a search and replace for "class"

Ow and just one more thing I've had problems compiling databaselayer because "libpq-fe.h" from postgre uses uint32 that is not defined anywhere, I just added the line "typedef unsigned int uint32" and it worked well.

I dont think this is the best thing thing to do for a library to be used in any case by anyone, so it needs to be ifdef'd to see if the machine uses 32bit integer.

I am no expert in building a generic library but if you have any permanent solution for this please tell me. I am still learning these portability issues.

edit: Adding some more info
I don't think anyone uses the string converter classes (at least I don't), it's more of an internal class, no need to export.
But i also use DatabaseErrorReporter. So I think I would add this class to the exported ones.


Thanks
Post Reply