Communication Problems (VC6)

I opened the old workspace, which is libray and its test harness. It worked fine, but now it doesn't, and older versions of the code do not work with the same errors. I tried to recreate the project, and this also causes the same errors. In the project settings, nothing fails, and the generated code works in the main application.

I deleted most of the files and kept it to a minimum to generate an error. Unfortunately, I can not publish the project, because it is used in production code.

The LNK2001 linker error that I get usually means that I left the library or forgot to implement a virtual function. However, this is part of the standard template library - and this is the title.

The code that is indicated as having a problem in IOCompletionPort.obj does not actually use std::string directly, but calls a class that does: Comms::Exception takes the value std::string and the value GetLastError or WSAGetLastError .

The function mentioned in the error ( GetMessage ) is implemented, but it is a virtual function, so other classes can override it if necessary. However, it seems that the compiler did this as a version of Ansi, but I can not find any parameters in the settings that would control this. I suspect this may be a problem, but since there are very few options in the library, I don’t know for sure. However, both projects specify _MBCS in the compiler options.

-------------------- Configuration: TestComms - Win32 Debugging -------------------- Binding ... Comms.lib (IOCompletionPort.obj): error LNK2001: unresolved external character "public: virtual class stand :: basic_string, class std :: allocator> __thiscall Comms :: Exception :: GetMessageA (void) const" (? GetMessageA @ Exception @ Communication @@ UBO? AV? $ Basic_string @DU? $ Char_traits @D @ stand @@ V? $ Distributor @D @ 2 @@ stand @@ XZ) Debug / TestComms.exe: fatal error LNK1120: 1 unresolved external Runtime error link.exe.

TestComms.exe - 2 errors, 0 warnings (s)

Any suggestions? I have lost most of the morning and do not want to lose most of the day.

+6
c ++ visual-c ++ linker vc6
source share
5 answers

One possibility is to use Win32 ANSI / Unicode "name-mangling", which turns the GetMessage character into GetMessageA or GetMessageW . There are three possibilities:

  • Windows.h was not loaded, so GetMessage remains GetMessage

  • Windows.h was loaded with the characters set for ANSI, so GetMessage becomes GetMessageA

  • Windows.h was loaded with the characters set for Unicode, so GetMessage becomes GetMessageW

If you compiled two different files in ways that run two different scripts, you will get a linker error. The error message indicates that the Comms::Exception class was instance # 2, above - maybe it was used somewhere, that windows.h was not loaded?

Other things that I would do in your place, just in a routine:

1) Make sure my inclusion paths and libraries do not contain anything that I do not expect.

2) Make the “assembly clean” and then manually check it by deleting any additional object files, if necessary.

3) Make sure that include-applications do not have any hard-coded paths that do not mean what they had in mind when the project was originally rebuilt.

EDIT: Struggling with formatting: (

+4
source share

@ Kurt: I think you came closest. I have not tested this, but I think I gave an answer in my original question.

GetMessage is a Windows.h definition enclosed in an ifndef block to switch between Ansi (GetMessageA) and Unicode (GetMessageW).

+1
source share

windows.h is declared at the top of IOCompletionPort.h as include - it hurt me to see 7 lines to include only one file, so I wrapped it in my own file and included it myself. It also contains some additional #defines (e.g. ULONG_PTR), as our main application will not compile with the installed SDK platform: - (

  • It's confirmed. Nothing is out of place.
  • I did it - deleted build directories
  • I never use hardcoded paths.
0
source share

Assuming you are not futzed around with project options, deleting something you shouldn't have (where I expect external dependencies like User32.lib):

Check Tools | Options | Directories | Libraries (comes from the memory here) and make sure you don’t miss the directories with a list of lib files with a shared garden (again, without VC6 in front of me, I can’t tell you what it is)

0
source share

This is a common problem with how Microsoft handled the ANSI and Unicode APIs. Since all (or almost all) of them are executed by defining macros for function names that allow the version names of functions "A" or "W", you cannot safely have an identifier in your namespace / class / struct / enum / that matches the Windows name API

The windows.h macros trigger rough processing across all other namespaces.

0
source share

All Articles