Solved

UNICODE linkage

Posted on 1998-12-17
11
1,281 Views
Last Modified: 2013-12-03
I have a VC++5 project creating a dll. I define the following: WIN32,_DEBUG,_WINDOWS,_WINDLL,_USRDLL,UNICODE and I don't specify any lib.

My problem is I fail with linkage errors:
uafxcwd.lib(appcore.obj) : error LNK2001: unresolved external symbol ___wargv
uafxcwd.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argc

any ideas?
0
Comment
Question by:gilg
  • 5
  • 5
11 Comments
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1417429
You should also define _UNICODE.
0
 

Author Comment

by:gilg
ID: 1417430
It doesn't work. Please notice that I already defined UNICODE. Is there a difference between this and _UNICODE?
0
 
LVL 11

Accepted Solution

by:
mikeblas earned 150 total points
ID: 1417431
You're building with _USRDLL, which means you're writing a DLL.  DLLs don't have command-lines, so you won't see __argv or __argc, period.

B ekiM

0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 11

Expert Comment

by:mikeblas
ID: 1417432
Normally, you only need to define UNICODE--certainly, for an MFC app, it's all that's required.  _UNICODE is used by the Windows headers, while MFC And the C Runtimes headers use UNICODE.

There's 2 or three spots in the headers where the headers make sure that defining one defines the other.

B ekiM

0
 

Author Comment

by:gilg
ID: 1417433
So, why do I get the linkage errors? I actually solved the problem by defining _AFXDLL or by linkaging statically to MFC. I still don't understand where did the problem came from in the first place.
0
 
LVL 11

Expert Comment

by:mikeblas
ID: 1417434
That error means you reference the symbols, but they're not defined in any of the libraries or OBJ files you've given the linker.

B ekiM

0
 

Author Comment

by:gilg
ID: 1417435
But I'm not referencing those symbols.
A) I know I'm not
B) They don't appear in the source browser
C) The linkage error specifies the origin of the reference as: uafxcwd.lib(appcore.obj) (see in the body of the question).
0
 
LVL 11

Expert Comment

by:mikeblas
ID: 1417436
A) You must be.  The linker doesn't randomly decide to run off and look at symbols you're not at least indirectly using.

B) The source browser uses a completely separate code path and symbol table.

C) Right.  You're touching something in UAFXCWD.LIB that's, in turn, using the symbols.

If you can break it down into specific questions, I can probably explain away the holes in your knowledge. But I'm not prepared to offer a complete tutorial on how the linker works.

B ekiM


0
 

Author Comment

by:gilg
ID: 1417437
What do you mean indirectly using? How can I touch something in UAFXCWD.lib?

Can you illustrate this to me with a code sample?

Again, defining _AFXDLL solved the problem with no code modifications. As I understand it, MFC's h files generate some use of the erroneus variables when _AFXDLL is not defined. What I really want to know is what is the logical reason for this.
I have some notion that it has something to do with Extension DLLs or just MFC DLLs but I'm not sure.

If this is to vague to answer, just say so and I'll grade your answer.

Thanks for the efforts already made,
Gili
0
 
LVL 11

Expert Comment

by:mikeblas
ID: 1417438
UAFXCWD.LIB is the static debug build of MFC. You touch stuff in it by referencing any MFC-provided symbol. You cause the linker to consider the library the second you #include <afx.h> with _DEBUG and _UNICODE defined, and without _AFXDLL defined.

Check out all the #pragma comment(lib) directives at the beginning of AFX.H.

The logical reason is that _AFXDLL and _USRDLL cause MFC to behave differently. That behaviour is so different that you'll actually link with different libraries, and those different libraries reference external symbols in different patterns.

You really need to learn more about the linker; it's not magic, and it's something that you'll use several times every single day while you're writing code.

B ekiM

0
 

Author Comment

by:gilg
ID: 1417439
Thanks.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question