By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,663 Members | 1,337 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,663 IT Pros & Developers. It's quick & easy.

linkage problems when building a VC7.1 project from the command line

P: n/a
I have a project that I normally build (without problems) from the
DevStudio IDE. However, I have embarked on automating all my builds
(this test project being one of several).

The project creates a DLL. I am able to build the project without any
probs in the IDE, however - when I build the project from the command
line (using the same options shown in the 'Command line' node in the
'Project Settings' dialog box), I get the following linkage problem (the
compilation with cl.exe seems to work ok though) - however link.exe
barfs like this:

link /OUT:timer.dll /INCREMENTAL /NOLOGO /DLL /DEBUG /SUBSYSTEM:WIND
OWS /IMPLIB:timer.lib /MACHINE:X86 Winmm.lib kernel32.lib user32.lib
gdi32.lib winspool.lib advapi3
2.lib shell32.lib
LINK : warning LNK4001: no object files specified; libraries used
LINK : error LNK2001: unresolved external symbol __DllMainCRTStartup@12
timer.dll : fatal error LNK1120: 1 unresolved externals

Whats going on?. I suspect I must be using lib.exe somewhere along the
line in the build process (or is this a red herring?)

May 7 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
link /OUT:timer.dll /INCREMENTAL /NOLOGO /DLL /DEBUG /SUBSYSTEM:WIND
OWS /IMPLIB:timer.lib /MACHINE:X86 Winmm.lib kernel32.lib user32.lib
gdi32.lib winspool.lib advapi3
2.lib shell32.lib
LINK : warning LNK4001: no object files specified; libraries used
LINK : error LNK2001: unresolved external symbol __DllMainCRTStartup@12
timer.dll : fatal error LNK1120: 1 unresolved externals

Whats going on?. I suspect I must be using lib.exe somewhere along the
line in the build process (or is this a red herring?)


at least one problem seems to be that your link command does not take object
files as inputs.
without any object files, the linker only links the lib files, which do not
contain any entry points

If I look at a random link command on my system, it contains a list of
object files to link together.
/OUT:"D:\Projects\Visual Studio
Projects\TryoutProjects\LvArrayTemplate\Debug\LvAr rayTemplate.exe"
/INCREMENTAL /MANIFEST
/MANIFESTFILE:"Debug\LvArrayTemplate.exe.intermedia te.manifest" /DEBUG
/PDB:"d:\Projects\Visual Studio
Projects\TryoutProjects\LvArrayTemplate\debug\LvAr rayTemplate.pdb"
/SUBSYSTEM:CONSOLE /MACHINE:X86 kernel32.lib user32.lib gdi32.lib
winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib
uuid.lib odbc32.lib odbccp32.lib

".\Debug\LvArrayTemplate.obj"

".\Debug\stdafx.obj"

".\Debug\LvArrayTemplate.exe.embed.manifest.re s"

If your project links fine when using the IDE, check the buildlog to find
the differences between what the IDE does and what your command line does.

--

Kind regards,
Bruno van Dooren
br**********************@hotmail.com
Remove only "_nos_pam"
May 7 '06 #2

P: n/a
Hi Bit byte

"Bit byte" <fl**@flop.com> wrote in message
news:Cb********************@bt.com...
I have a project that I normally build (without problems) from the
DevStudio IDE. However, I have embarked on automating all my builds (this
test project being one of several).

The project creates a DLL. I am able to build the project without any
probs in the IDE, however - when I build the project from the command line
(using the same options shown in the 'Command line' node in the 'Project
Settings' dialog box), I get the following linkage problem (the
compilation with cl.exe seems to work ok though) - however link.exe barfs
like this:

link /OUT:timer.dll /INCREMENTAL /NOLOGO /DLL /DEBUG /SUBSYSTEM:WIND
OWS /IMPLIB:timer.lib /MACHINE:X86 Winmm.lib kernel32.lib user32.lib
gdi32.lib winspool.lib advapi3
2.lib shell32.lib
LINK : warning LNK4001: no object files specified; libraries used
LINK : error LNK2001: unresolved external symbol __DllMainCRTStartup@12
timer.dll : fatal error LNK1120: 1 unresolved externals

Whats going on?. I suspect I must be using lib.exe somewhere along the
line in the build process (or is this a red herring?)


Have you considered
devenv.exe /build
?

Marcus
May 7 '06 #3

P: n/a


Bruno van Dooren wrote:
link /OUT:timer.dll /INCREMENTAL /NOLOGO /DLL /DEBUG /SUBSYSTEM:WIND
OWS /IMPLIB:timer.lib /MACHINE:X86 Winmm.lib kernel32.lib user32.lib
gdi32.lib winspool.lib advapi3
2.lib shell32.lib
LINK : warning LNK4001: no object files specified; libraries used
LINK : error LNK2001: unresolved external symbol __DllMainCRTStartup@12
timer.dll : fatal error LNK1120: 1 unresolved externals

Whats going on?. I suspect I must be using lib.exe somewhere along the
line in the build process (or is this a red herring?)

at least one problem seems to be that your link command does not take object
files as inputs.
without any object files, the linker only links the lib files, which do not
contain any entry points

If I look at a random link command on my system, it contains a list of
object files to link together.
/OUT:"D:\Projects\Visual Studio
Projects\TryoutProjects\LvArrayTemplate\Debug\LvAr rayTemplate.exe"
/INCREMENTAL /MANIFEST
/MANIFESTFILE:"Debug\LvArrayTemplate.exe.intermedia te.manifest" /DEBUG
/PDB:"d:\Projects\Visual Studio
Projects\TryoutProjects\LvArrayTemplate\debug\LvAr rayTemplate.pdb"
/SUBSYSTEM:CONSOLE /MACHINE:X86 kernel32.lib user32.lib gdi32.lib
winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib
uuid.lib odbc32.lib odbccp32.lib

".\Debug\LvArrayTemplate.obj"

".\Debug\stdafx.obj"

".\Debug\LvArrayTemplate.exe.embed.manifest.re s"

If your project links fine when using the IDE, check the buildlog to find
the differences between what the IDE does and what your command line does.


I think you're onto something here Bruno - there appears to be a
difference in the commands used in the log file. Specifically, a .rsp
file is created which I am not doing at the command line:
<BuildLog>

Creating temporary file "c:\timer\Debug\RSP000007.rsp" with contents
[
/Od /D "WIN32" /D "BUILDING_DLL" /D "_WINDLL" /D "_MBCS" /Gm /EHsc /RTC1
/MTd /Fo"Debug/" /Fd"Debug/vc70.pdb" /W3 /c /Wp64 /ZI /TP
..\timer.cpp
]
Creating command line "cl.exe @c:\timer\Debug\RSP000007.rsp /nologo"
Creating temporary file "c:\timer\Debug\RSP000008.rsp" with contents
[
/OUT:"Debug/timer.dll" /INCREMENTAL /NOLOGO /DLL /DEBUG
/PDB:"Debug/timer.pdb" /SUBSYSTEM:WINDOWS /IMPLIB:"Debug/timer.lib"
/MACHINE:X86 Winmm.lib kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib
odbc32.lib odbccp32.lib
..\Debug\timer.obj
]
Creating command line "link.exe @c:\timer\Debug\RSP000008.rsp"

</BuildLog>
My questions are:

1). What are these .rsp (linker response) files and how may I re-create
them on the command line? - when I run the EXACT command shown in the
buildlog for the compiler, I do not get a message saying that a
temporary *.rsp file is being created - WHY ?
2). How are these .rsp files named? Are the assigned numbers (07 and 08
in the above log - random numbers?)
3). Why is the compiler (cl.exe) using linker options ("/DLL",
"/SUBSYSTEM:WINDOWS", "/MACHINE:X86" etc ?) - are these simply being
passed to the linker?

May 7 '06 #4

P: n/a
Bit byte wrote:
I think you're onto something here Bruno - there appears to be a
difference in the commands used in the log file. Specifically, a .rsp
file is created which I am not doing at the command line:
<BuildLog>

Creating temporary file "c:\timer\Debug\RSP000007.rsp" with contents
[
/Od /D "WIN32" /D "BUILDING_DLL" /D "_WINDLL" /D "_MBCS" /Gm /EHsc
/RTC1 /MTd /Fo"Debug/" /Fd"Debug/vc70.pdb" /W3 /c /Wp64 /ZI /TP
.\timer.cpp
]
Creating command line "cl.exe @c:\timer\Debug\RSP000007.rsp /nologo"
Creating temporary file "c:\timer\Debug\RSP000008.rsp" with contents
[
/OUT:"Debug/timer.dll" /INCREMENTAL /NOLOGO /DLL /DEBUG
/PDB:"Debug/timer.pdb" /SUBSYSTEM:WINDOWS /IMPLIB:"Debug/timer.lib"
/MACHINE:X86 Winmm.lib kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib
odbc32.lib odbccp32.lib
.\Debug\timer.obj
]
Creating command line "link.exe @c:\timer\Debug\RSP000008.rsp"

</BuildLog>
My questions are:

1). What are these .rsp (linker response) files and how may I
re-create them on the command line? - when I run the EXACT command shown
in the
buildlog for the compiler, I do not get a message saying that a
temporary *.rsp file is being created - WHY ?
The .rsp file simply contains more command-line options for the linker. You
can simply pile everything on the command line in most cases. There is an
upper limit though - the linker only accepts (IIRC) about 4000 characters on
the command line, so if you're linking a lot of modules it's not too hard to
exceed that limit. That's why the IDE uses the response file to hold the
list of files to be linked - there's no limit on how much stuff you can pile
into a response file.
2). How are these .rsp files named? Are the assigned numbers (07 and
08 in the above log - random numbers?)
For all practical purposes, yes. The name is unimportant - the IDE simply
generates consequtive numbers. The file extension is also unimportant -
there's nothing special about .rsp - it's just a text file.
3). Why is the compiler (cl.exe) using linker options ("/DLL",
"/SUBSYSTEM:WINDOWS", "/MACHINE:X86" etc ?) - are these simply being
passed to the linker?


I don't see those options in the cl command line you've shown above.
Rather, those are being passed to the linker.

-cd
May 7 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.