Linking Failed.. help

I get these as errors how do i solve them?

Linking...
XC3Main.obj : error LNK2005: _DllMain@12 already defined in Hack3.obj
XC3Main.obj : warning LNK4006: _DllMain@12 already defined in Hack3.obj; second definition ignored
Creating library Debug/Hack3.lib and object Debug/Hack3.exp
Debug/Hack3.dll : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.

This always happens when i try to make dll
[474 byte] By [][THE][ANSWER][] at [2007-11-18 22:16:28]
# 1 Re: Linking Failed.. help
add
/FORCE:MULTIPLE
to your linker -> command line options

That should do the trick!
Tischnoetentoet at 2007-11-11 1:04:24 >
# 2 Re: Linking Failed.. help
and where exactly is that?
][THE][ANSWER][ at 2007-11-11 1:05:24 >
# 3 Re: Linking Failed.. help
Well, in VS Studio.net you have to do it like this:

1) Rightmousbuttonclick on the project object in the solution explorer

2) Click on properties

3) Set your Configuration to "All configurations"

4) Then click on the "linker" folder

5) Then click on command line

6) Add "/FORCE:MULTIPLE" to Additional options

Well, this can't go wrong :)
Tischnoetentoet at 2007-11-11 1:06:21 >
# 4 Re: Linking Failed.. help
sorry i dont VS Studio.net I have Microsoft Visual C++

I can find the properties but not the options you gave me after that.
][THE][ANSWER][ at 2007-11-11 1:07:21 >
# 5 Re: Linking Failed.. help
Aren't there linker options...

I bet they are there...

Just try to find it in the project properties and find the linker options...
Tischnoetentoet at 2007-11-11 1:08:31 >
# 6 Re: Linking Failed.. help
yeah i go to Project Properties and then there are 3 tabs: General, inputs, and outputs.

In the inputs there is a Bsc maker and a linker tool

same thing in the outputs
][THE][ANSWER][ at 2007-11-11 1:09:30 >
# 7 Re: Linking Failed.. help
oh i found it i set it to all confuigurations, ok there is a Link tab but not a Linker tab

where is the command line?
][THE][ANSWER][ at 2007-11-11 1:10:25 >
# 8 Re: Linking Failed.. help
Note that the linker option /FORCE:MULTIPLE is just a dirty workaround - you should rather solve the real problem underneath. How comes that the linker finds DllMain multiple times? Could it be that you have put DllMain's implementation in a header file which you #include in XC3Main.cpp and Hack3.cpp?
gstercken at 2007-11-11 1:11:28 >
# 9 Re: Linking Failed.. help
Could i just delete everything form the debug file and try again?
][THE][ANSWER][ at 2007-11-11 1:12:31 >
# 10 Re: Linking Failed.. help
of course you can...

All the data in the debug directory is created when it's not there...

Except if you dropped files in that directory yourself, they are of course not generated!
Tischnoetentoet at 2007-11-11 1:13:32 >
# 11 Re: Linking Failed.. help
i added /FORCE:MULTPLE to where i think it is supposed to be, now all it says are warnings like "ignoring incrementals due to /FORCE specification"
][THE][ANSWER][ at 2007-11-11 1:14:31 >
# 12 Re: Linking Failed.. help
yes, warnings, not errors, so it compiles...

There are several things to keep in mind:

You can protect classes for multiple includes this way:

top of the .h file
#ifndef YOURCLASS_H
#define YOURCLASS_H

bottom of the .h file
#endif //YOURCLASS_H
Tischnoetentoet at 2007-11-11 1:15:32 >
# 13 Re: Linking Failed.. help
[THE][ANSWER][']i added /FORCE:MULTPLE to where i think it is supposed to be, now all it says are warnings like "ignoring incrementals due to /FORCE specification"Did you read gstercken's message? What you're doing is not a good solution. I would even call it a mistake. It's similar to the "solution" of increasing the stack size setting, when the real solution is to fix the program.

Somewhere in your code, you are including the body of DllMain more than once. Did you figure out where you are doing this? It's your code, you should know what you're doing in it.

IMO, the only reason to use /FORCE:MULTIPLE is if someone gave you a (poorly written) library or set of object code where you don't have the source, and they included the body of one of the library's functions more than once. Since you can't change the library or object code, your only solution would be to use /FORCE:MULTIPLE.

Otherwise, there is no need to be using the linker to cover up mistakes in the way you've set up your source code and project. At some point, this error will come back to bite you. Just to let you know, I have a DLL that consists of over 150 C++ modules, and I have never received this linker error, therefore you are doing something fundamentally wrong.

Regards,

Paul McKenzie
Paul McKenzie at 2007-11-11 1:16:39 >