Hi,

Dnia 29 marca 2012 12:27 Mateusz Loskot <mate...@loskot.net> napisaƂ(a):

> On 29 March 2012 10:10, rno <r...@o2.pl> wrote:
> > Hi all,
> >
> > Considering usage of SOCI I made some simple tests and the following line 
> > does not work under Visual Studio 2010 version with PostgreSQL backend:
> >
> > soci::session sql(soci::postgresql, "string");
> >
> > There are linker errors. The dynamically loadable backend version:
> >
> > soci::session sql(*soci::factory_postgresql(), "string");
> >
> > works well.
> 
> What do you mean as "does not work" ?


The program soci-test.cpp:

#include <soci.h>
#include <soci-postgresql.h>

int main() {
    soci::session sql(soci::postgresql, "string");
    return 0;
}

compiled by Visual Studio (cl compiler) by the command:

cl /Fosoci_test.obj /c soci_test.cpp /TP /nologo /EHsc /MD /D "WIN32" /D 
"_WIN32_WINNT#0x501" /D "_CONSOLE" /W4 /ID:\3pty\soci-3.1.0\backends\postgresql 
/ID:\3pty\soci-3.1.0\core "/IC:\Program Files\PostgreSQL\9.1\include"

and linked by:

link /nologo /OUT:test.exe /LIBPATH:D:\3pty\soci-3.1.0\build\lib\Release 
/LIBPATH:D:\3pty\soci-3.1.0\build\bin\Release "/LIBPATH:C:\Program 
Files\PostgreSQL\9.1\lib" soci_postgresql_3_1.lib soci_core_3_1.lib libpq.lib 
soci_test.obj

gives linker error:

soci_test.obj : error LNK2019: unresolved external symbol "struct 
soci::postgresql_backend_factory const soci::postgresql" 
(?postgresql@soci@@3Upostgresql_backend_factory@1@B) referenced in function 
_main
st.exe : fatal error LNK1120: 1 unresolved externals

The change mentioned in previous e-mail eliminates this error and program is 
created correctly. IMHO the 'soci::postgres' literal is more conveninent than
derefernce of 'soci::factory_postgresql()'.

Best regards,
Robert

> > Both versions works under Ubuntu. I suspect errors in export symbols, but 
> > maybe I did not notice some settings. Do You have some experience with this 
> > case?
> 
> Yes, I remember I experienced some linker errors while trying to use
> the static object directly under Visual Studio.
> I'd not tried to pursue it further to find out what's wrong as there
> is factory function available.
> 
> Best regards,
> 

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Soci-users mailing list
Soci-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/soci-users

Reply via email to