Solved

Linkage flag difference questions

Posted on 2010-09-01
14
391 Views
Last Modified: 2012-05-10
Hi,

I have a 1st linkage of a project with the link parameters appear in the attached file nm133.txt and a 2nd
linkage of a project with the link parameters appear in the attached file nm133.txt.
In both there is a use of a makefile.
The question: Is there any difference between the artifact of the 1st linkage httpsender.lib to the artifact of the 2st linkage httpencoder.lib?

Thanks!
nm133.txt
nm139.txt
0
Comment
Question by:HPBSM
  • 7
  • 7
14 Comments
 

Author Comment

by:HPBSM
ID: 33576121
Of course these are c++ projects.
Thanks
0
 
LVL 86

Expert Comment

by:jkr
ID: 33576355
Well, the 1st one uses '/DEBUGTYPE', yet that flag is ignored if '/DEBUG' isn't explicitly specified. So, apart from the various input files, the major diference is that the 1st is linked as a DLL, the second one as a GUI application.
0
 

Author Comment

by:HPBSM
ID: 33576461
As a matter of fact the 1st one creates a dll and a lib and the 2nd one creates a lib and my question is if there is a difference between these libs? Is the lib created by the 2nd one is a static library? How actually the code affects in run time in the 2nd? In the client code compiles with the lib and in run time it loads the dll, but what happens in the lib created in the 2nd one? There is no dll created there...
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 86

Expert Comment

by:jkr
ID: 33576709
>>Is the lib created by the 2nd one is a static library?

If 'lib.exe' is tun after 'link', yes. If that the case, the code (if it's the same) will only be affected at runtime in the way that it is not loaded from the DLL, but from the executable that is linked with the static library the code resides in. In that case, the code in question is 'copied' to the executable when it is built.
0
 

Author Comment

by:HPBSM
ID: 33578492
Hi,

This is the order of build: link.exe is activate. The artifact is transdata.dll. So httpencoder.lib is a static library?

Thanks.

1>Creating dll...
1> C:\progra~1\MID05A~1\VC\bin\link @C:\DOCUME~1\levy\LOCALS~1\Temp\nm274.tmp
1>Microsoft (R) Incremental Linker Version 8.00.50727.42
1>Copyright (C) Microsoft Corporation.  All rights reserved.
1>-machine:i386
1>-subsystem:windows
1>-debugtype:cv /DEBUG
1>-dll
1>-entry:_DllMainCRTStartup@12
1>/out:..\obj\transdata.dll
1>/implib:..\obj\transdata.lib
1>..\obj\transdata_ext.obj
1>..\obj\ts_sample_ctor.obj
1>..\obj\ts_sample_ctor_for_http_comm.obj
1>..\obj\ts_sample_ctor_for_samples_comm.obj
1>..\obj\ts_repot_data_ctor.obj
1>..\obj\ts_samples_to_http_conv.obj
1>..\obj\soa_ts_repot_data_ctor.obj
1>..\obj\soa_ts_sample_ctor_for_http_comm.obj
1>..\obj\soa_ts_sample_ctor_for_samples_comm.obj
1>std-vc-mt.lib
1>wrapicu.lib
1>mosifs32.lib
1>miclogger.lib
1>breakdown.lib
1>libxdrutil.lib
1>thrdutil.lib
1>httpencoder.lib
1>ws2_32.lib
1>libcurl_imp.lib
1>data_types_ifs.lib
1>protodata.lib
1>mictime.lib
1>oldnames.lib
1>kernel32.lib
1>advapi32.lib
1>user32.lib
1>gdi32.lib
1>comdlg32.lib
1>shell32.lib
1>winspool.lib
1>default.res
1>LINK : ..\obj\transdata.dll not found or not built by the last incremental link; performing full link
1>   Creating library ..\obj\transdata.lib and object ..\obj\transdata.exp
1>httpencoder.lib(http_encoder.obj) : warning LNK4099: PDB 'vc80.pdb' was not found with 'C:\Workspaces\tp26_agent_data\sccs\arch\httpencoder.lib' or at 'c:\Workspaces\tp26_agent_data\sccs\app\transdata\obj\vc80.pdb'; linking object as if no debug info
1> if exist ..\obj\transdata.dll.manifest C:\progra~1\MID05A~1\VC\bin\mt -manifest ..\obj\transdata.dll.manifest -outputresource:..\obj\transdata.dll;2
1>Microsoft (R) Manifest Tool version 5.2.3790.2014
1>Copyright (c) Microsoft Corporation 2005.
1>All rights reserved.
1>done!!
1>lib done
1>system done
1> copy ..\obj\transdata.lib C:\Workspaces\tp26_agent_data\sccs\arch
1>        1 file(s) copied.
1> copy ..\obj\transdata.dll C:\Workspaces\tp26_agent_data\sccs\arch
1>        1 file(s) copied.
1> copy ..\obj\transdata.pdb C:\Workspaces\tp26_agent_data\sccs\arch
1>        1 file(s) copied.
1>install done
1>Build log was saved at "file://c:\Workspaces\tp26_agent_data\sccs\app\transdata\src\Interface Compile Install\BuildLog.htm"
1>transdata - 0 error(s), 2 warning(s)

0
 
LVL 86

Expert Comment

by:jkr
ID: 33578730
>>So httpencoder.lib is a static library?

No, this creates a DLL called 'transdata.dll' and an import library with the corresponding name (transdata.lib) as indicated by these lines:

1>-dll
1>-entry:_DllMainCRTStartup@12
1>/out:..\obj\transdata.dll
1>/implib:..\obj\transdata.lib

/DLL Builds a DLL (http://msdn.microsoft.com/en-us/library/527z7zfs.aspx)
/OUT Specifies the output file name (http://msdn.microsoft.com/en-us/library/8htcy933.aspx)
/IMPLIB Overrides the default import library name (http://msdn.microsoft.com/en-us/library/67wc07b9.aspx)

See also http://msdn.microsoft.com/en-us/library/y0zzbyt4%28v=VS.100%29.aspx ("Linker Options")
0
 

Author Comment

by:HPBSM
ID: 33578886
But how the code of httpencoder.lib takes affect at run time in transdata.dll?
0
 
LVL 86

Expert Comment

by:jkr
ID: 33579121
'httpencoder.lib' is just one if the inout files in the above link process, i.e. line 28:

1>httpencoder.lib

This means thar the code that transdata.dll uses in httpencoder.lib is copied and placed in transdata.dll during this run.
0
 

Author Comment

by:HPBSM
ID: 33595438
jkr:

Does it mean that httpencoder.lib is a static library or no?
0
 
LVL 86

Expert Comment

by:jkr
ID: 33596990
Well, it does - if it was an import library for a DLL, no code would be copied, just the additional dependency to the related DLL would be added.
0
 

Author Comment

by:HPBSM
ID: 33606822
jkr:

O.K. I think I need some more explanation about your last sentence: Can you please explain it a bit more?

Thanks!
0
 
LVL 86

Expert Comment

by:jkr
ID: 33607094
OK: In case of a satatic library, the code referenced by the target project is copied into that target during the link process. In case of a dynamic library, just a reference to that dynamic library is placed target project (i.e. name of the DLL and entry point addresses of the functions).
0
 

Author Comment

by:HPBSM
ID: 33615855
Is there any way to identify that a library is a static one according to the compilation flags, in another words that it creates only a .lib file and not a dll?

Thanks
0
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 33620990
You mean when building it or when using it? In the 1st case, there will be a '/DLL' switch in the linker options, in the latter, you can use 'lib' or 'dumpbin' to check whether the library contains any actual code.
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

809 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