PDA

View Full Version : Qt and the Loki Library



tbrowder
14th August 2008, 15:41
We are using Qt and the Loki library with a program and cannot get a succesfule link with MS Visual C++ 2005. There is no problem, however, linking and executing the program under Linux.

We use many QT functions and classes, but only the SafeFormat functions from Loki. The compiler error message is:

1>x.obj : error LNK2019: unresolved external symbol
1>"void __cdecl Loki::_write(class std::basic_ostream<char,struct
1>std::char_traits<char> > &,char const *,char const *)"
1>(?_write@Loki@@YAXAAV?$basic_ostream@DU?$char_trai ts@D@std@@@std@@PBD1
1>@Z) referenced in function "private: void __thiscall
1>Loki::PrintfState<class std::basic_ostream<char,struct
1>std::char_traits<char> > &,char>::Write(char const *,char const *)"
1>(?Write@?$PrintfState@AAV?$basic_ostream@DU?$char_ traits@D@std@@@std@@
1>D@Loki@@AAEXPBD0@Z)

1>x.obj : error LNK2019: unresolved external symbol
1>"void __cdecl Loki::_write(struct _iobuf *,char const *,char const *)"
1>(?_write@Loki@@YAXPAU_iobuf@@PBD1@Z) referenced in function "private:
1>void __thiscall Loki::PrintfState<struct _iobuf *,char>::Write(char
1>const *,char const *)"
1>(?Write@?$PrintfState@PAU_iobuf@@D@Loki@@AAEXPBD0@ Z)

We have double checked our paths for includes and finding
the loki.lib.

We have also tried adding the Loki source file and header for SafeFormat to our program solution but get the same errors.

We would like to use loki.lib under Windows but can't get past this.

Thanks for any help.

wysota
14th August 2008, 16:08
Could you verify the linker command arguments that the loki library indeed is getting linked with the executable?

tbrowder
14th August 2008, 18:53
Thanks for the response. We confirmed it as best we can.

As we said, we also added the source and header files to our project and ignored the library but got the same error.

We have have looked into low-level Qt headers and MS C library headers to see if we can find a clue. Not long ago we found that some programs with Loki and Qt have no problem, so we may be missing a library somewhere.

The hunt goes on...

wysota
14th August 2008, 20:59
Are you sure the Loki lib is compiled for MSVC and not MinGW? Do you have a corresponding dll file, by the way?

jpn
14th August 2008, 21:06
Also, does the library have necessary import/export macros for its public classes?

tbrowder
15th August 2008, 13:44
We used the MSVC solution for 2005 that came with the library. It produces a static library (.lib).

Note that we get the same errors if we drop the source and header files into our program source and do not link with the library.

It has been suggested that _write may be a Qt macro that is somehow confusing the linker. We do know that Qt has a QT_WRITE macro but are not sure how that works in the IO system.

wysota
17th August 2008, 20:37
This is "Loki::_write" and not "_write". If the name "_write" is reported by the linker, it is not a macro as macros are expanded by the preprocessor. Check if your Loki library indeed has the referenced symbol (Loki::_write) in it.

tbrowder
18th August 2008, 13:00
Thanks--we'll see.