LNK 2001 error using the cl compiler??

M

Mary

Hello,

I am having a problem with the cl compiler. I have written a C class
(RegConnect.c) which uses Win32 API functions such as RegOpenKey,
RegCloseKey etc. Initially when I was trying to create a dll, using
the cl compiler I was getting many unresolved external errors, Example
1 below (8 in total, 7 to do with the registry function calls and 1
from wsprintfA call) as I hadn't included the AdvAPI32.lib file. So I
created a LINK environment variable and set the value to be
"C:\Program Files\Microsoft SDK\Lib\AdvAPI32.lib". When I tried to
generate the dll again I only got 1 link error this time, Example 2,
for wsprintfA. I modified the LINK environment variable, to change the
value to "C:\Program Files\Microsoft SDK\Lib\User32.lib", and re ran
the command, This time I got 7 errors, the 7 registry errors but the
wsprintfA wasn't one of the errors! So I know I need to include both
the User32.lib (for wsprintfA ) and AdvAPI32.lib for the calls to the
Win32 API functions. But if I change the LINK environment variable to
have 2 files, I get LNK2001 error: cannot find file, example 3 below.

1) No LINK environment variable:
cl -I%WINDOWS_INCLUDE% -I%JAVA_INCLUDE% -I%JAVA_INCLUDE%\win
32 -LD RegConnect.c -FeRegConnect.dll
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for
80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

RegConnect.c
Microsoft (R) Incremental Linker Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

/dll
/implib:RegConnect.lib
/out:RegConnect.dll
RegConnect.obj
Creating library RegConnect.lib and object RegConnect.exp
RegConnect.obj : error LNK2001: unresolved external symbol
__imp__RegCloseKey@4
RegConnect.obj : error LNK2001: unresolved external symbol
__imp__RegQueryValueE
xA@24
RegConnect.obj : error LNK2001: unresolved external symbol
__imp__RegOpenKeyExA@
20
RegConnect.obj : error LNK2001: unresolved external symbol
__imp__RegConnectRegi
stryA@12
RegConnect.obj : error LNK2001: unresolved external symbol
__imp__wsprintfA
RegConnect.obj : error LNK2001: unresolved external symbol
__imp__RegSetValueExA
@24
RegConnect.obj : error LNK2001: unresolved external symbol
__imp__RegCreateKeyEx
A@36
RegConnect.obj : error LNK2001: unresolved external symbol
__imp__RegDeleteKeyA@
8
RegConnect.dll : fatal error LNK1120: 8 unresolved externals

2) LINK environment variable is: "C:\Program Files\Microsoft
SDK\Lib\AdvAPI32.Lib":
cl -I%WINDOWS_INCLUDE% -I%JAVA_INCLUDE% -I%JAVA_INCLUDE%\wi
32 -LD RegConnect.c -FeRegConnect.dll
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for
80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

RegConnect.c
Microsoft (R) Incremental Linker Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

"C:\Program Files\Microsoft SDK\Lib\AdvAPI32.Lib"
/dll
/implib:RegConnect.lib
/out:RegConnect.dll
RegConnect.obj
Creating library RegConnect.lib and object RegConnect.exp
RegConnect.obj : error LNK2001: unresolved external symbol
__imp__wsprintfA
RegConnect.dll : fatal error LNK1120: 1 unresolved externals


3) LINK environment variable is: "C:\Program Files\Microsoft
SDK\Lib\User32.Lib":
cl -I%WINDOWS_INCLUDE% -I%JAVA_INCLUDE% -I%JAVA_INCLUDE%\win
32 -LD RegConnect.c -FeRegConnect.dll
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for
80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

RegConnect.c
Microsoft (R) Incremental Linker Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

"C:\Program Files\Microsoft SDK\Lib\User32.Lib"
/dll
/implib:RegConnect.lib
/out:RegConnect.dll
RegConnect.obj
Creating library RegConnect.lib and object RegConnect.exp
RegConnect.obj : error LNK2001: unresolved external symbol
__imp__RegCloseKey@4
RegConnect.obj : error LNK2001: unresolved external symbol
__imp__RegQueryValueE
xA@24
RegConnect.obj : error LNK2001: unresolved external symbol
__imp__RegOpenKeyExA@
20
RegConnect.obj : error LNK2001: unresolved external symbol
__imp__RegConnectRegi
stryA@12
RegConnect.obj : error LNK2001: unresolved external symbol
__imp__RegSetValueExA
@24
RegConnect.obj : error LNK2001: unresolved external symbol
__imp__RegCreateKeyEx
A@36
RegConnect.obj : error LNK2001: unresolved external symbol
__imp__RegDeleteKeyA@
8
RegConnect.dll : fatal error LNK1120: 7 unresolved externals


4) when i include both in the LINK environment variable:
"C:\Program Files\Microsoft SDK\Lib\AdvAPI32.Lib;C:\Program
Files\Microsoft SDK\
Lib\User32.Lib"
cl -I%WINDOWS_INCLUDE% -I%JAVA_INCLUDE% -I%JAVA_INCLUDE%\win
32 -LD RegConnect.c -FeRegConnect.dll
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for
80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

"C:\Program Files\Microsoft SDK\Lib\AdvAPI32.Lib;C:\Program
Files\Microsoft SDK\
Lib\User32.Lib"
RegConnect.c
Microsoft (R) Incremental Linker Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.


/dll
/implib:RegConnect.lib
/out:RegConnect.dll
RegConnect.obj
LINK : fatal error LNK1104: cannot open file "C:\Program
Files\Microsoft SDK\Lib
\AdvAPI32.Lib;C:\Program Files\Microsoft SDK\Lib\User32.Lib"


I have also tried the newer version of the cl compiler (version 13...)
but it still doesn't work!!!
Is it how I can't have 2 paths in the LINK variable?
Please HELP as this is driving me in sane!!

Thanks in advance!
Mary
 
M

Mark A. Odell

(e-mail address removed) (Mary) wrote in

I am having a problem with the cl compiler. I have written a C class
(RegConnect.c) which uses Win32 API functions such as RegOpenKey,

Mary, C does not specify how the cl compiler works, does not support
classes (that's C++), nor does it include the win32 API. Thus, this
question is off-topic here. There are many Microsoft newsgroups available,
I suggest you find one that deals with win32 and programming.
 
M

Martin Ambuhl

Mary said:
Hello,

I am having a problem with the cl compiler. I have written a C class

No, you didn't. There is no such thing as a 'class' in C. Perhaps you
meant the different languagee C++, for which there is a newsgroup
(RegConnect.c) which uses Win32 API functions such as RegOpenKey,
RegCloseKey etc. Initially when I was trying to create a dll,

Win32 API functions and DLLs are not part of C++ either. Perhaps you
want a newsgroup, mailing list, or tech support for your implementation
or for Windows.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top