Solved

UNICODE linkage

Posted on 1998-12-17
11
1,283 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Suggested Solutions

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

730 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