For Programmers: Free Programming Magazines  


Home > Archive > VC Language > May 2006 > multiply defined symbols









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author multiply defined symbols
Drew

2006-05-31, 7:15 pm

I recently took an existing C project and am now compiling it using C++
compiler (I don't think this part is relevant). Now I'm getting alot of link
errors that look like:

taucsgd.lib(taucs_ccs_ops.obj) : error LNK2005: "double *
taucs_temp_A_block" (?taucs_temp_A_block@@3PANA) already defined in
taucsgd.lib(taucs_vec_base.obj)
taucsgd.lib(taucs_ccs_ops.obj) : error LNK2005: "int taucs_solve"
(?taucs_solve@@3HA) already defined in taucsgd.lib(taucs_vec_base.obj)
taucsgd.lib(taucs_ccs_ops.obj) : error LNK2005: "int *
taucs_g_var2block_size" (?taucs_g_var2block_size@@3PAHA) already defined in
taucsgd.lib(taucs_vec_base.obj)
taucsgd.lib(taucs_ccs_ops.obj) : error LNK2005: "int *
taucs_A_block_allocated" (?taucs_A_block_allocated@@3PAHA) already defined in
taucsgd.lib(taucs_vec_base.obj)

Followed by basically identical warnings:

taucsgd.lib(taucs_ccs_ops.obj) : warning LNK4006: "double *
taucs_temp_A_block" (?taucs_temp_A_block@@3PANA) already defined in
taucsgd.lib(taucs_vec_base.obj); second definition ignored
taucsgd.lib(taucs_ccs_ops.obj) : warning LNK4006: "int taucs_solve"
(?taucs_solve@@3HA) already defined in taucsgd.lib(taucs_vec_base.obj);
second definition ignored
taucsgd.lib(taucs_ccs_ops.obj) : warning LNK4006: "int *
taucs_g_var2block_size" (?taucs_g_var2block_size@@3PAHA) already defined in
taucsgd.lib(taucs_vec_base.obj); second definition ignored
taucsgd.lib(taucs_ccs_ops.obj) : warning LNK4006: "int *
taucs_A_block_allocated" (?taucs_A_block_allocated@@3PAHA) already defined in
taucsgd.lib(taucs_vec_base.obj); second definition ignored

I also get the same warnings during compile time when compiling the library.
Does anyone know what causes this?

Thanks,
Drew
Carl Daniel [VC++ MVP]

2006-05-31, 7:15 pm

"Drew" <Drew@discussions.microsoft.com> wrote in message
news:0D8E88A4-7015-480E-A3AA-4E0BAF44DF6F@microsoft.com...
>I recently took an existing C project and am now compiling it using C++
> compiler (I don't think this part is relevant). Now I'm getting alot of
> link
> errors that look like:
>
> taucsgd.lib(taucs_ccs_ops.obj) : error LNK2005: "double *
> taucs_temp_A_block" (?taucs_temp_A_block@@3PANA) already defined in
> taucsgd.lib(taucs_vec_base.obj)
> taucsgd.lib(taucs_ccs_ops.obj) : error LNK2005: "int taucs_solve"
> (?taucs_solve@@3HA) already defined in taucsgd.lib(taucs_vec_base.obj)
> taucsgd.lib(taucs_ccs_ops.obj) : error LNK2005: "int *
> taucs_g_var2block_size" (?taucs_g_var2block_size@@3PAHA) already defined
> in
> taucsgd.lib(taucs_vec_base.obj)
> taucsgd.lib(taucs_ccs_ops.obj) : error LNK2005: "int *
> taucs_A_block_allocated" (?taucs_A_block_allocated@@3PAHA) already defined
> in
> taucsgd.lib(taucs_vec_base.obj)
>
> Followed by basically identical warnings:
>
> taucsgd.lib(taucs_ccs_ops.obj) : warning LNK4006: "double *
> taucs_temp_A_block" (?taucs_temp_A_block@@3PANA) already defined in
> taucsgd.lib(taucs_vec_base.obj); second definition ignored
> taucsgd.lib(taucs_ccs_ops.obj) : warning LNK4006: "int taucs_solve"
> (?taucs_solve@@3HA) already defined in taucsgd.lib(taucs_vec_base.obj);
> second definition ignored
> taucsgd.lib(taucs_ccs_ops.obj) : warning LNK4006: "int *
> taucs_g_var2block_size" (?taucs_g_var2block_size@@3PAHA) already defined
> in
> taucsgd.lib(taucs_vec_base.obj); second definition ignored
> taucsgd.lib(taucs_ccs_ops.obj) : warning LNK4006: "int *
> taucs_A_block_allocated" (?taucs_A_block_allocated@@3PAHA) already defined
> in
> taucsgd.lib(taucs_vec_base.obj); second definition ignored
>
> I also get the same warnings during compile time when compiling the
> library.
> Does anyone know what causes this?


Most likely:

You've got function definitions (not declarations) in a header file that's
included in several other files. That results in definitions of those
function in every module, leading to the linker error.

-cd


Drew

2006-05-31, 7:15 pm

Carl,

Found the problem. These symbols are all just variable declarations. In a
header there is code like:

#ifdef PP_SYMBOL

double* taucs_temp_A_block;

#else

extern double* taucs_temp_A_block;

#endif

The answer was to just #define PP_SYMBOL in one file. I should have seen
that sooner.

Thanks,
Drew

"Carl Daniel [VC++ MVP]" wrote:

> "Drew" <Drew@discussions.microsoft.com> wrote in message
> news:0D8E88A4-7015-480E-A3AA-4E0BAF44DF6F@microsoft.com...
>
> Most likely:
>
> You've got function definitions (not declarations) in a header file that's
> included in several other files. That results in definitions of those
> function in every module, leading to the linker error.
>
> -cd
>
>
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com