Compilation of simple console application with QuantLib-vc90-mt-sgd-0_9_7.lib

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Compilation of simple console application with QuantLib-vc90-mt-sgd-0_9_7.lib

Boris Skorodumov
Dear QuantLib Users,

I am a new user of QuantLib. I have compiled and run all test examples provided within Visual Studio 2008 with no problems.
I would like to create simple project and link it with QuantLib-vc90-mt-sgd-0_9_7.lib.

I have created console application with default project settings except for:

1.  Configuration Properties -> C/C++->General->Additional Include Directories
      C:\........\QuantLib-0.9.7

2.  Configuration Properties -> C/C++->Preprocessor
      WIN32;_DEBUG;_CONSOLE;_SCL_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;

3. Configuration Properties -> Linker->General->Additional Library Directories
    C:\ .......\QuantLib-0.9.7\lib

4. Configuration Properties -> Linker->Input->Additional Dependencies
    QuantLib-vc90-mt-sgd-0_9_7.lib


The following simple code produce linker error. My guess is that something wrong with project setting I use.
Thank you in advance for pointing out solution.

// main.cpp
#include <ql/time/date.hpp>
#include <iostream>

using namespace QuantLib;

int main()
{

    try {
   
         Date today = Date::todaysDate();

        return 0;
    } catch (std::exception& e) {
        std::cout << e.what() << std::endl;
        return 1;
    } catch (...) {
        std::cout << "unknown error" << std::endl;
        return 1;
    }
}


1>Compiling...
1>main.cpp
1>Compiling manifest to resources...
1>Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0
1>Copyright (C) Microsoft Corporation.  All rights reserved.
1>Linking...
1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: void __thiscall std::basic_ios<char,struct std::char_traits<char> >::setstate(int,bool)" (?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z) already defined in QuantLib-vc90-mt-sgd-0_9_7.lib(date1.obj)
1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: int __thiscall std::ios_base::width(int)" (?width@ios_base@std@@QAEHH@Z) already defined in QuantLib-vc90-mt-sgd-0_9_7.lib(date1.obj)
1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: int __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::sputn(char const *,int)" (?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPBDH@Z) already defined in QuantLib-vc90-mt-sgd-0_9_7.lib(date1.obj)
1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: static bool __cdecl std::char_traits<char>::eq_int_type(int const &,int const &)" (?eq_int_type@?$char_traits@D@std@@SA_NABH0@Z) already defined in QuantLib-vc90-mt-sgd-0_9_7.lib(date1.obj)
1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: static int __cdecl std::char_traits<char>::eof(void)" (?eof@?$char_traits@D@std@@SAHXZ) already defined in QuantLib-vc90-mt-sgd-0_9_7.lib(date1.obj)
1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: int __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::sputc(char)" (?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHD@Z) already defined in QuantLib-vc90-mt-sgd-0_9_7.lib(date1.obj)
1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: class std::basic_streambuf<char,struct std::char_traits<char> > * __thiscall std::basic_ios<char,struct std::char_traits<char> >::rdbuf(void)const " (?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ) already defined in QuantLib-vc90-mt-sgd-0_9_7.lib(date1.obj)
1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: char __thiscall std::basic_ios<char,struct std::char_traits<char> >::fill(void)const " (?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDXZ) already defined in QuantLib-vc90-mt-sgd-0_9_7.lib(date1.obj)
1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: int __thiscall std::ios_base::flags(void)const " (?flags@ios_base@std@@QBEHXZ) already defined in QuantLib-vc90-mt-sgd-0_9_7.lib(date1.obj)
1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: int __thiscall std::ios_base::width(void)const " (?width@ios_base@std@@QBEHXZ) already defined in QuantLib-vc90-mt-sgd-0_9_7.lib(date1.obj)
1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)" (?length@?$char_traits@D@std@@SAIPBD@Z) already defined in QuantLib-vc90-mt-sgd-0_9_7.lib(date1.obj)
1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >::flush(void)" (?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ) already defined in QuantLib-vc90-mt-sgd-0_9_7.lib(date1.obj)
1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > * __thiscall std::basic_ios<char,struct std::char_traits<char> >::tie(void)const " (?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ) already defined in QuantLib-vc90-mt-sgd-0_9_7.lib(date1.obj)
1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: bool __thiscall std::ios_base::good(void)const " (?good@ios_base@std@@QBE_NXZ) already defined in QuantLib-vc90-mt-sgd-0_9_7.lib(date1.obj)
1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: void __thiscall std::basic_ostream<char,struct std::char_traits<char> >::_Osfx(void)" (?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ) already defined in QuantLib-vc90-mt-sgd-0_9_7.lib(date1.obj)
1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: void __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::_Lock(void)" (?_Lock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ) already defined in QuantLib-vc90-mt-sgd-0_9_7.lib(date1.obj)
1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: void __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::_Unlock(void)" (?_Unlock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ) already defined in QuantLib-vc90-mt-sgd-0_9_7.lib(date1.obj)
1>msvcprtd.lib(MSVCP90D.dll) : error LNK2005: "public: class std::locale::facet * __thiscall std::locale::facet::_Decref(void)" (?_Decref@facet@locale@std@@QAEPAV123@XZ) already defined in QuantLib-vc90-mt-sgd-0_9_7.lib(date1.obj)
1>libcpmtd.lib(ios.obj) : error LNK2005: "private: static void __cdecl std::ios_base::_Ios_base_dtor(class std::ios_base *)" (?_Ios_base_dtor@ios_base@std@@CAXPAV12@@Z) already defined in msvcprtd.lib(MSVCP90D.dll)
1>libcpmtd.lib(ios.obj) : error LNK2005: "public: static void __cdecl std::ios_base::_Addstd(class std::ios_base *)" (?_Addstd@ios_base@std@@SAXPAV12@@Z) already defined in msvcprtd.lib(MSVCP90D.dll)
1>libcpmtd.lib(locale0.obj) : error LNK2005: "void __cdecl _AtModuleExit(void (__cdecl*)(void))" (?_AtModuleExit@@YAXP6AXXZ@Z) already defined in msvcprtd.lib(locale0_implib.obj)
1>libcpmtd.lib(locale0.obj) : error LNK2005: __Fac_tidy already defined in msvcprtd.lib(locale0_implib.obj)
1>libcpmtd.lib(locale0.obj) : error LNK2005: "private: static void __cdecl std::locale::facet::facet_Register(class std::locale::facet *)" (?facet_Register@facet@locale@std@@CAXPAV123@@Z) already defined in msvcprtd.lib(locale0_implib.obj)
1>libcpmtd.lib(locale0.obj) : error LNK2005: "private: static class std::locale::_Locimp * __cdecl std::locale::_Getgloballocale(void)" (?_Getgloballocale@locale@std@@CAPAV_Locimp@12@XZ) already defined in msvcprtd.lib(MSVCP90D.dll)
1>libcpmtd.lib(locale0.obj) : error LNK2005: "private: static class std::locale::_Locimp * __cdecl std::locale::_Init(void)" (?_Init@locale@std@@CAPAV_Locimp@12@XZ) already defined in msvcprtd.lib(MSVCP90D.dll)
1>libcpmtd.lib(locale0.obj) : error LNK2005: "public: static void __cdecl std::_Locinfo::_Locinfo_ctor(class std::_Locinfo *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?_Locinfo_ctor@_Locinfo@std@@SAXPAV12@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z) already defined in msvcprtd.lib(MSVCP90D.dll)
1>libcpmtd.lib(locale0.obj) : error LNK2005: "public: static void __cdecl std::_Locinfo::_Locinfo_dtor(class std::_Locinfo *)" (?_Locinfo_dtor@_Locinfo@std@@SAXPAV12@@Z) already defined in msvcprtd.lib(MSVCP90D.dll)
1>libcpmtd.lib(xlock.obj) : error LNK2005: "public: __thiscall std::_Lockit::_Lockit(int)" (??0_Lockit@std@@QAE@H@Z) already defined in msvcprtd.lib(MSVCP90D.dll)
1>libcpmtd.lib(xlock.obj) : error LNK2005: "public: __thiscall std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) already defined in msvcprtd.lib(MSVCP90D.dll)
1>LIBCMTD.lib(setlocal.obj) : error LNK2005: __configthreadlocale already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LIBCMTD.lib(dbgheap.obj) : error LNK2005: __CrtSetCheckCount already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LIBCMTD.lib(lconv.obj) : error LNK2005: _localeconv already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LIBCMTD.lib(tidtable.obj) : error LNK2005: __encode_pointer already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LIBCMTD.lib(tidtable.obj) : error LNK2005: __decode_pointer already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LIBCMTD.lib(dbghook.obj) : error LNK2005: __crt_debugger_hook already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LIBCMTD.lib(crt0dat.obj) : error LNK2005: _exit already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LIBCMTD.lib(crt0dat.obj) : error LNK2005: __exit already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LIBCMTD.lib(crt0dat.obj) : error LNK2005: __cexit already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LIBCMTD.lib(crt0dat.obj) : error LNK2005: __amsg_exit already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LIBCMTD.lib(crt0dat.obj) : error LNK2005: __initterm_e already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LIBCMTD.lib(mlock.obj) : error LNK2005: __lock already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LIBCMTD.lib(mlock.obj) : error LNK2005: __unlock already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LIBCMTD.lib(winxfltr.obj) : error LNK2005: __XcptFilter already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LIBCMTD.lib(sprintf.obj) : error LNK2005: _sprintf_s already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in MSVCRTD.lib(cinitexe.obj)
1>LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in MSVCRTD.lib(cinitexe.obj)
1>LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in MSVCRTD.lib(cinitexe.obj)
1>LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in MSVCRTD.lib(cinitexe.obj)
1>LIBCMTD.lib(hooks.obj) : error LNK2005: "void __cdecl terminate(void)" (?terminate@@YAXXZ) already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LIBCMTD.lib(invarg.obj) : error LNK2005: __invalid_parameter already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LIBCMTD.lib(invarg.obj) : error LNK2005: __invoke_watson already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LIBCMTD.lib(crt0.obj) : error LNK2005: _mainCRTStartup already defined in MSVCRTD.lib(crtexe.obj)
1>LIBCMTD.lib(errmode.obj) : error LNK2005: ___set_app_type already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LIBCMTD.lib(dbgrptw.obj) : error LNK2005: __CrtDbgReportW already defined in MSVCRTD.lib(MSVCR90D.dll)
1>LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
1>LINK : warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library
1>C:\C++\TestQL\Debug\TestQL.exe : fatal error LNK1169: one or more multiply defined symbols found
1>Build log was saved at "file://c:\C++\TestQL\TestQL\Debug\BuildLog.htm"
1>TestQL - 55 error(s), 2 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========



------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Compilation of simple console application with QuantLib-vc90-mt-sgd-0_9_7.lib

Luigi Ballabio
Hi Boris,

On Mon, 2009-01-12 at 18:08 -0500, Boris Skorodumov wrote:
> I am a new user of QuantLib. I have compiled and run all test examples
> provided within Visual Studio 2008 with no problems.
> I would like to create simple project and link it with
> QuantLib-vc90-mt-sgd-0_9_7.lib.

Just checking: you're aware that QuantLib-vc90-mt-sgd-0_9_7.lib is
compiled in debug mode and is much slower than the release version,
right?


> I have created console application with default project settings
> except for:
>
> 4. Configuration Properties -> Linker->Input->Additional Dependencies
>     QuantLib-vc90-mt-sgd-0_9_7.lib

This is not necessary. Instead of specifying the library directly, it's
better to add

#include <ql/auto_link.hpp>

to one of your source files. The above will try to pull in the correct
version of the library for your project settings, so that you won't have
linker errors like the ones you reported.  The downside is that, if you
want to link a specific library you compiled (such as
QuantLib-vc90-mt-sgd-0_9_7.lib) you'll have to adjust your project
settings accordingly. In your case, I think you'll to choose debug mode
and to set Configuration Properties -> C/C++ -> Code Generation as
"Multi-threaded".

Luigi


--

I've finally learned what `upward compatible' means. It means we
get to keep all our old mistakes.
-- Dennie van Tassel



------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Compilation of simple console application with QuantLib-vc90-mt-sgd-0_9_7.lib

Boris Skorodumov
Dear Luigi and QuantLib Users,

Thank you very much for the reply. I am very appreciate your help.

>Just checking: you're aware that QuantLib-vc90-mt-sgd-0_9_7.lib is
>compiled in debug mode and is much slower than the release version,
>right?

 I was not aware of it. Thank you for pointing it out. I just recompiled library in release mode ( QuantLib-vc90-mt-0_9_7.lib). It also automatically runs test suite with success.

>This is not necessary. Instead of specifying the library directly, it's
>better to add
>#include <ql/auto_link.hpp>
>o one of your source files. The above will try to pull in the correct
>version of the library for your project settings, so that you won't have
l>inker errors like the ones you reported.  The downside is that, if you
>want to link a specific library you compiled (such as
>QuantLib-vc90-mt-sgd-0_9_7.

This is very helpful suggestion.  There is small issue with auto_link.hpp, though.

Line 63: #define QL_LIB_NAME "QuantLib-" QL_LIB_TOOLSET QL_LIB_THREAD_OPT QL_LIB_RT_OPT "-"
QL_LIB_VERSION ".lib"


QL_LIB_VERSION  macro is not defined in auto_link.hpp but in qldefines.hpp. So, I have included also qldefines.hpp  header.

I could compile main.cpp in debug/release mode including
    #include <ql/qldefines.hpp>
    #include <ql/auto_link.hpp>

 with following configuration properties:

Debug Mode:

    1.   Configuration Properties->General->Additional Include Directories
   
          C:\....\QuantLib-0.9.7
     2.  Configuration Properties->Preprosessor->Preprocessor Definitions
         
WIN32;_DEBUG;_CONSOLE;_SCL_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;
     3.  Configuration Properties->Code Generation->Runtime Library
         
Multi-threaded Debug (/MTd)
    
4.  Configuration Properties->Linker->Additional Library Directories
          C:\....\QuantLib-0.9.7\lib

Release Mode:

    1.   Configuration Properties->General->Additional Include Directories
   
          C:\....\QuantLib-0.9.7
     2.  Configuration Properties->Preprosessor->Preprocessor Definitions
         
WIN32;_DEBUG;_CONSOLE;_SCL_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;
     3.  Configuration Properties->Code Generation->Runtime Library
         
Multi-threaded DLL (/MD)
    
4.  Configuration Properties->Linker->Additional Library Directories
          C:\....\QuantLib-0.9.7\lib


Thank you,
Boris.




On Tue, Jan 13, 2009 at 3:57 AM, Luigi Ballabio <[hidden email]> wrote:
Hi Boris,

On Mon, 2009-01-12 at 18:08 -0500, Boris Skorodumov wrote:
> I am a new user of QuantLib. I have compiled and run all test examples
> provided within Visual Studio 2008 with no problems.
> I would like to create simple project and link it with
> QuantLib-vc90-mt-sgd-0_9_7.lib.

Just checking: you're aware that QuantLib-vc90-mt-sgd-0_9_7.lib is
compiled in debug mode and is much slower than the release version,
right?


> I have created console application with default project settings
> except for:
>
> 4. Configuration Properties -> Linker->Input->Additional Dependencies
>     QuantLib-vc90-mt-sgd-0_9_7.lib

This is not necessary. Instead of specifying the library directly, it's
better to add

#include <ql/auto_link.hpp>

to one of your source files. The above will try to pull in the correct
version of the library for your project settings, so that you won't have
linker errors like the ones you reported.  The downside is that, if you
want to link a specific library you compiled (such as
QuantLib-vc90-mt-sgd-0_9_7.lib) you'll have to adjust your project
settings accordingly. In your case, I think you'll to choose debug mode
and to set Configuration Properties -> C/C++ -> Code Generation as
"Multi-threaded".

Luigi


--

I've finally learned what `upward compatible' means. It means we
get to keep all our old mistakes.
-- Dennie van Tassel




------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users