Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

UNICODE linkage

Posted on 1998-12-17
11
Medium Priority
?
1,306 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 600 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
Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying 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 programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
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…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

972 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