473,659 Members | 2,920 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MSVC not linking in "unused" libraries

At link time, MSVC determines some of my libraries are unused and doesn't
link them into my exe. This undesirable feature causes problems when I
employ the factory pattern. With the factory pattern, the app decides at
run time which code to use.

Is there a link option to turn of this feature?

MSVC 7.1 .net 2003 69462-270-0000007-18536

Thanks,

Chris
Apr 3 '06 #1
6 2565
> At link time, MSVC determines some of my libraries are unused and doesn't
link them into my exe. This undesirable feature causes problems when I
employ the factory pattern. With the factory pattern, the app decides at
run time which code to use.


You should be able to use the linker option /INCLUDE for that.
Alternatively, you can use LoadLibrary at runtime to load dlls at runtime.
That way you have an extensible plugin framework.

--

Kind regards,
Bruno van Dooren
br************* *********@hotma il.com
Remove only "_nos_pam"
Apr 3 '06 #2

"Chris Stankevitz" wrote
At link time, MSVC determines some of my libraries are unused and doesn't
link them into my exe. This undesirable feature causes problems when I
employ the factory pattern. With the factory pattern, the app decides at
run time which code to use.

Is there a link option to turn of this feature?


I'm going to try /OPT:NOREF
Apr 3 '06 #3

"Bruno van Dooren"
You should be able to use the linker option /INCLUDE for that.
Alternatively, you can use LoadLibrary at runtime to load dlls at runtime.
That way you have an extensible plugin framework.

Hi Bruno,

Thanks for the help. Do I have to use /INCLUDE for every symbol? My
developers are adding objects (symbols) via the Factory pattern every day.
I don't want to change my link options everytime I add an object. My app is
about 1 million lines of code.

I will try the /OPT:NOREF option.

Thanks,

Chris
Apr 3 '06 #4
> "Bruno van Dooren"
You should be able to use the linker option /INCLUDE for that.
Alternatively, you can use LoadLibrary at runtime to load dlls at runtime.
That way you have an extensible plugin framework.

Hi Bruno,

Thanks for the help. Do I have to use /INCLUDE for every symbol? My
developers are adding objects (symbols) via the Factory pattern every day.
I don't want to change my link options everytime I add an object. My app is
about 1 million lines of code.

I will try the /OPT:NOREF option.


If your libraries are dlls, then you have to reference only 1 symbol per
library.

If your libraries are static libraries, then a common technique is to have 1
function that is never to be called by actual code, put a call to all other
functions in there, and then use /INCLUDE to reference that unused function
that automatically references all other functions.

/OPT:NOREF is the default for debug builds, so if your debug configuration
does not include all the libraries, you know it won't work.

--

Kind regards,
Bruno.
br************* *********@hotma il.com
Remove only "_nos_pam"
Apr 4 '06 #5

"Bruno van Dooren" <br************ **********@hotm ail.com> wrote
If your libraries are static libraries, then a common technique is to have
1
function that is never to be called by actual code, put a call to all
other
functions in there, and then use /INCLUDE to reference that unused
function
that automatically references all other functions.


Bruno,

Thanks for your help.

I'm curious about this trick. What do you mean by "put a call to all other
functions"? Are you assuming that my static library consists of only global
functions? My static libraries consist of many classes each with many
functions, a few static functions, and some static variables. What would my
"dummy function" look like for such a static library?

Thanks,

Chris
Apr 11 '06 #6
> "Bruno van Dooren" <br************ **********@hotm ail.com> wrote
If your libraries are static libraries, then a common technique is to have
1
function that is never to be called by actual code, put a call to all
other
functions in there, and then use /INCLUDE to reference that unused
function
that automatically references all other functions.


Bruno,

Thanks for your help.

I'm curious about this trick. What do you mean by "put a call to all other
functions"? Are you assuming that my static library consists of only global
functions? My static libraries consist of many classes each with many
functions, a few static functions, and some static variables. What would my
"dummy function" look like for such a static library?


The way I saw this technique used after some googling (though i cannot find
that page again it seems. I hate it when that happens) looked like this:

void dummyFunctionFo rSymbolReferenc e(void)
{
Class1 myClass1();
Class2 myClass3();
Class3 myClass3();
}

You only need to reference each class once inside the function that you
include by force. all the classes that are contained inside that function
should be added to the library.

You can easily test this with one of your classes that contain both member
and static function sand variables.

This page:
http://austria.sourceforge.net/dox/h...Factories.html
seems to describe another trick for making sure that symbols get included.
Maybe that could be usefull to you as well?

--

Kind regards,
Bruno.
br************* *********@hotma il.com
Remove only "_nos_pam"

Apr 12 '06 #7

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

Similar topics

4
2514
by: J. Campbell | last post by:
From reading this forum, it is my understanding that C++ doesn't require the compiler to keep code that does not manifest itself in any way to the user. For example, in the following: { for(int i = 0; i < 10; ++i){ std::cout << i << std::endl; for(int j = 0; j < 0x7fffffff; ++j){} } }
4
14394
by: mairhtin o'feannag | last post by:
Hello, I have a tablespace striped across three drives, call them 1,2,3, just to be clever. :) I allocated a lot more space (DMS) than I should have, since I didn't know a way to estimate the space required (long story, but the original space was in one huge tablespace for all tables ((35 million row tables)) and I needed to segregate them out into separate tablespaces for backup and restore purposes. So I allocated, like 4 million...
0
987
by: Steve B. | last post by:
Hello I'm building a Web service that have some methods. I've also two datasets class : DataSet1 and DataSet2. If I add a method in my WS that waits for or return either DataSet1 and DataSet2, the DataSet is embedded in the WSDL so the client application can use them as typed DataSet, which is working well with VS.
11
23224
by: Charles Sullivan | last post by:
I have a number of functions, e.g.: int funct1( int arg1, int arg2, int arg3 ); int funct2( int arg1, int arg2, int arg3 ); int funct3( int arg1, int arg2, int arg3 ); that are called via pointers in a table, with the same parameters regardless of the particular function. In some of the functions, one or more of the
13
9736
by: Rex Mottram | last post by:
I'm using an API which does a lot of callbacks. In classic callback style, each routine provides a void * pointer to carry user-defined data. Sometimes, however, the user-defined pointer is not needed which causes the compiler to spit out a "helpful" warning. For example: % cat unused.c #include <stdio.h> int foo(char *str, void *data) {
0
8335
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8528
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8627
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7356
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6179
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2752
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.