MSVC runtime libs

Help
Paul Brown
2004-09-22
2013-04-24
  • Paul Brown
    Paul Brown
    2004-09-22

    Hi

    i'm building some C++ libs using cpptasks and at the moment only shipping on Windows (!)

    i've got a linker error and suspect its because i am not pulling in the MSVC C++ runtime.

    Does anyone know which libraries I need exactly.

    Thanks

    Here's my linker error (or part of it):

        [cc] nativecpubsubtest.obj : error LNK2001: unresolved external symbol "public: class std::basic_string<char,struct std::char_tr
    aits<char>,class std::allocator<char> > __thiscall ncjms::JMSException::getContext(void)const " (?getContext@JMSException@ncjms@@QBE
    ?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
        [cc] nativecpubsubtest.obj : error LNK2001: unresolved external symbol "public: class std::basic_string<char,struct std::char_tr
    aits<char>,class std::allocator<char> > __thiscall ncjms::JMSException::getDomain(void)const " (?getDomain@JMSException@ncjms@@QBE?A
    V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
        [cc] nativecpubsubtest.obj : error LNK2001: unresolved external symbol "public: class std::basic_string<char,struct std::char_tr
    aits<char>,class std::allocator<char> > __thiscall ncjms::JMSException::getErrorMsg(void)const " (?getErrorMsg@JMSException@ncjms@@Q
    BE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
        [cc] nativecpubsubtest.obj : error LNK2001: unresolved external symbol "public: void __thiscall ncjms::Connection::close(void)"
    (?close@Connection@ncjms@@QAEXXZ)

     
    • Curt Arnold
      Curt Arnold
      2004-09-22

      It looks like it is missing a library that defines the ncjms namespace and the JMSExeception class.  It does not look like I would expect a failure to find the runtime libraries.

      If you can build the project in Visual Studio or another environment and turn the map file generation on, you can see where a successful link found those symbols.

      The add something like:

      <libset dir="${ncjms.dir}" libs="ncjms"/>

      inside your <cc> element.  Do not add the ".lib" (likewise on Linux don't add the leading "lib" or trailing ".so", "a", etc).  Cpptask needs just the root name and will append all the nice platform specific flourishes.

      If you think that you are specifying everything, try building using a "-v" option when you invoke Ant which will allow you to see the assembled command line.

       
      • Paul Brown
        Paul Brown
        2004-09-22

        its weird ...i know the library containing the symbols...found that by "dumpbin /exports mylib.lib"

        it should be on the linker path as i'm doing this:

        <linker name="${cc}">
            <linkerarg value="/machine:I386" location="mid"/>
             <libset libs="kernel32 user32 gdi32 winspool comdlg32 advapi32 shell32 ole32 oleaut32 uuid odbc32 odbccp32 "/>
            
             <fileset dir="lib_g" includes="ncjms"/>
             <fileset dir="lib_g" includes="wmdcc"/>
             <fileset dir="lib_g" includes="glib-2.0"/>
        </linker>

        but it's still not linking.

        i'm not sure i can do the '-v' thing to Ant, as i'm using Maven.

        thanks
        paul

         
        • Curt Arnold
          Curt Arnold
          2004-09-22

          You can use fileset to add library files to MSVC-style links, but in that case you use filespec that contain the .lib, so you either need to do:

          <libset dir="lib_g" libs="ncjms wmdcc glib-2.0"/>

          or

          <fileset dir="lib_g" libs="ncjms.lib wmdcc.lib glib-2.0.lib"/>

          However, I would recommend the libset since it should also work the gcc-style linking.

           
    • Paul Brown
      Paul Brown
      2004-09-23

      i found the solution to my problem!!

      it was the old __declspec(dllimport) ... or __declspec(dllexport) problem .... where you have to make sure you have the right one defined depending on whether you are compiling your DLL, or using it in another app.

      i had the wrong one defined.

      Thanks,
      paul