Thread: Porting code from VC++6 to VC .NET??

  1. #1
    Registered User dug's Avatar
    Join Date
    Jun 2003
    Posts
    66

    Porting code from VC++6 to VC .NET??

    hello,

    i have been using Visual Studio 6.0 for years, and for some reason, the powers that be are forcing me to upgrade to Visual Studio .NET now that i have a new workstation... i don't see why, but that's a different story.

    anyway, i'm getting pretty pi553d off porting my code.

    so i have a number of libraries that i have successfully rebuilt in .NET, but now when i come to compile my top-level programs that use these libraries i get linker errors like:

    >>>>>

    vclibd.lib(VCSession.obj) : error LNK2019: unresolved external symbol "void __cdecl std::_Xran(void)" (?_Xran@std@@YAXXZ) referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > & __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::assign(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned int,unsigned int)" (?assign@?$basic_string@DU?$char_traits@D@std@@V?$ allocator@D@2@@std@@QAEAAV12@ABV12@II@Z)

    >>>>>

    i understand that this is something to do with the STL... so i went back to the bottom, and cleaned all the library projects, and rebuilt them all, cleaned my top-level project, and rebuilt, and i still get the same errors....

    can anyone tell me what i should do becuase i'm getting pretty close to just throwing my new machine out the window.

    thanks in advance,
    dug.
    "take the long road.... and walk it."

  2. #2
    Registered User
    Join Date
    Aug 2003
    Posts
    1,218
    Remember to link the libraries with your project.

  3. #3
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    For MSVC 2005 (probably similar in VC 2003), under one of the menus, there's an item called "Project properties". Go into that, expand the linker tab, and then click on "input". Type the names of the external libraries under "additional dependencies".
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  4. #4
    Registered User dug's Avatar
    Join Date
    Jun 2003
    Posts
    66
    uh..., yeah..., all the libraries are there, they were copied in from the original dsp/dsw files...

    i have managed to reduce the errors and now all i have is this:

    >>>

    LINK : warning LNK4098: defaultlib 'LIBC' conflicts with use of other libs; use /NODEFAULTLIB:library
    ashlibd.lib(ImagedTarget.obj) : error LNK2019: unresolved external symbol "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl ashlib:perator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,class ashlib::Tuple2<float>)" (??6ashlib@@YAAAV?$basic_ostream@DU?$char_traits@D @std@@@std@@AAV12@V?$Tuple2@M@0@@Z) referenced in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl ashlib:perator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,class ashlib::ImagedTarget const &)" (??6ashlib@@YAAAV?$basic_ostream@DU?$char_traits@D @std@@@std@@AAV12@ABVImagedTarget@0@@Z)
    ashlibd.lib(Target.obj) : error LNK2019: unresolved external symbol "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl ashlib:perator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,class ashlib::Tuple3<float>)" (??6ashlib@@YAAAV?$basic_ostream@DU?$char_traits@D @std@@@std@@AAV12@V?$Tuple3@M@0@@Z) referenced in function "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl ashlib:perator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,class ashlib::Target const &)" (??6ashlib@@YAAAV?$basic_ostream@DU?$char_traits@D @std@@@std@@AAV12@ABVTarget@0@@Z)
    .\Debug/vcCalibrate.exe : fatal error LNK1120: 2 unresolved externals

    >>>

    any more ideas chaps?
    "take the long road.... and walk it."

  5. #5
    Registered User
    Join Date
    Dec 2004
    Posts
    95
    In VC6, did you specify extra (global - as opposed to per project) directories for library files? If so you'll need to add them in VS.NET (tools->options->projects->directories)

  6. #6
    Registered User dug's Avatar
    Join Date
    Jun 2003
    Posts
    66
    no, i specify everything per project and per configuration... i'm organised that way...
    "take the long road.... and walk it."

  7. #7
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Well, looks like the library is trying to reference ashlib:perator<<(ostream&, Tuple2<float>) and ashlib:perator<<(ostream&, Tuple3<float>) and the linker can't find them defined anywhere. This might be due to:

    LINK : warning LNK4098: defaultlib 'LIBC' conflicts with use of other libs

    So perhaps because of some conflict, the library you need wasn't linked in? Also, have you tried the linker's suggestion?
    "use /NODEFAULTLIB:library"
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  8. #8
    Registered User dug's Avatar
    Join Date
    Jun 2003
    Posts
    66
    declared in Tuple2.h as:

    Code:
    friend std::ostream& operator<<(std::ostream& os, Tuple2<T> v);
    implemented in Tuple2.h as:
    Code:
    template<class T> std::ostream& operator<<(std::ostream& os, Tuple2<T> v) {
        return os << "[" << v.x << "," << v.y << "]";
    }
    "take the long road.... and walk it."

  9. #9
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    I guess that's not the problem then. But have you given any consideration to:
    LINK : warning LNK4098: defaultlib 'LIBC' conflicts with use of other libs; use /NODEFAULTLIB:library
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  10. #10
    Registered User dug's Avatar
    Join Date
    Jun 2003
    Posts
    66
    i still get the linker errors, but without the:

    LINK : warning LNK4098: defaultlib 'LIBC' conflicts with use of other libs
    "take the long road.... and walk it."

  11. #11
    Registered User dug's Avatar
    Join Date
    Jun 2003
    Posts
    66
    i found this in the documentation:

    >>>

    This error can also be generated as a result of conformance work that was done for Visual Studio .NET 2003: template friends and specialization. In Visual Studio .NET 2003, a friend declaration that declares a new non-template function must be defined.
    For code that is valid in both the Visual Studio .NET 2003 and Visual Studio .NET versions of Visual C++, explicitly specify the friend function's template argument list.

    Code:
    // LNK2019.cpp
    // LNK2019 expected
    template<class T>
    void f(T)
    {
    }
    
    template<class T>
    struct S
    {
       friend void f(T);
       // Try the folowing line instead:
       // friend void f<T>(T);
    };
    
    int main()
    {
       S<int> s;
       f(1);   // unresolved external
    }
    however, how on eart h do you do this with an 'operator' i tried everything i could think of, and nothing worked....
    "take the long road.... and walk it."

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 04:17 PM
  2. Replies: 4
    Last Post: 01-16-2002, 12:04 AM
  3. Porting code form *nix to win
    By Merlion in forum C Programming
    Replies: 2
    Last Post: 11-23-2001, 02:42 PM
  4. Visual J#
    By mfc2themax in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 10-08-2001, 02:41 PM