473,406 Members | 2,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

LNK 2001 error using the cl compiler??

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
Nov 14 '05 #1
2 5805
ma***********@yahoo.com (Mary) wrote in
news:97**************************@posting.google.c om:
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.

--
- Mark ->
--
Nov 14 '05 #2
Mary wrote:
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
news:comp.lang.c++ but ... (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.

Nov 14 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: yanwan | last post by:
I met this problem in executing a c++ project in visual studio. Does anyone have suggestions to resolve "error lnk 2001"? --------------------Configuration: reconstruction - Win32...
13
by: Dr John Stockton | last post by:
Javascript date strings can have a one-letter postfix; it is taken as indicating time zone (not J, which causes NaN). // IIRC, VB accepts A & P in that location, for AM & PM. In my MS IE 4, the...
1
by: stoppal | last post by:
I have the below function written in VB, and everything works fine EXCEPT that the sql code is not executing correctly. The date field is in the table always shows "12/1/1899 11:59:17 PM" no other...
17
by: Steve Jorgensen | last post by:
If you've ever employed custom error numbers and messages in you programs, you've probably ended up with code similar to what I've ended up with in the past something like... <code> public...
16
by: pj | last post by:
(Was originally, probably wrongly, posted to the vc subgroup.) (This doesn't appear to be a c# problem, but a problem with a bug in the Visual Studio c# compiler, but, any help will be welcome...)...
0
by: Tim Sharrock | last post by:
We have hit an internal compiler error when processing a very long array initialiser (for a lookup table). Most of the compiler versions we tried compiled the code successfully, but very slowly...
10
by: k.jayachandran | last post by:
I have a very curious and unique problem here. I'm creating a parser using bison and flex. i did all the development work in a linux environment. the project includes the source files output from...
0
by: erik.erikson | last post by:
I am getting a compiler error that I can't well explain or even understand the origin of (though I boiled it down close...). Below is a bare-bones example. What I am doing is defining the...
2
by: mickey22 | last post by:
I am using a function template in my project which is member of a class and I have included the header file of this class.But I am getting a linking error LNK 2001: error LNK2001: unresolved...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.