M
mowgli
Hi,
maybe my problem is a well know thing but i recently switched from
developing under Visual Studio to Linux and gcc. I ported a medium
size project and after some time everything compiled but the linking
failed.
The code that caused the problem worked with VS and is the following:
I have header file called Legendre.h where is this code
/** \brief Scaled Legendre Polynomial Order 0 */
static inline void Legendre0( double * value, void ** info )
{
(* value) = FAC0;
}
/** \brief Scaled Legendre Polynomial Order 1 */
static inline void Legendre1( double * value, void ** info )
{
(* value) = FAC1 * ( *( (double *) info[0]) );
}
FAC0 and FAC1 are constants. This continues until Legendre6 ( ). I
also declare this
/** \brief Definition of the Set of Basis Functions */
LEGFunc LegendreBasis[7];
where LEGFunc itself is
typedef void (* LEGFunc) (void * item, void ** data);
Then in the file Legendre.c there is
/** \brief Defines the Legendre Basis up to 6th order. */
LEGFunc LegendreBasis[7] =
{
(LEGFunc) Legendre0, (LEGFunc) Legendre1, (LEGFunc) Legendre2,
(LEGFunc) Legendre3,
(LEGFunc) Legendre4, (LEGFunc) Legendre5, (LEGFunc) Legendre6
};
Here i get an "undefined reference" error for Legendre0 - Legendre6. I
checked the Legendre.o object file with nm and there the Legendre
objects exist but are undefined.
I solved it by moving the Legendre0-6 functions into the Legendre.c
file and i had to remove the static which now doesn't have any
function anymore in any case. With static the linker gives the same
errors.
Can somebody explain this to me?
Thank you,
Sascha
maybe my problem is a well know thing but i recently switched from
developing under Visual Studio to Linux and gcc. I ported a medium
size project and after some time everything compiled but the linking
failed.
The code that caused the problem worked with VS and is the following:
I have header file called Legendre.h where is this code
/** \brief Scaled Legendre Polynomial Order 0 */
static inline void Legendre0( double * value, void ** info )
{
(* value) = FAC0;
}
/** \brief Scaled Legendre Polynomial Order 1 */
static inline void Legendre1( double * value, void ** info )
{
(* value) = FAC1 * ( *( (double *) info[0]) );
}
FAC0 and FAC1 are constants. This continues until Legendre6 ( ). I
also declare this
/** \brief Definition of the Set of Basis Functions */
LEGFunc LegendreBasis[7];
where LEGFunc itself is
typedef void (* LEGFunc) (void * item, void ** data);
Then in the file Legendre.c there is
/** \brief Defines the Legendre Basis up to 6th order. */
LEGFunc LegendreBasis[7] =
{
(LEGFunc) Legendre0, (LEGFunc) Legendre1, (LEGFunc) Legendre2,
(LEGFunc) Legendre3,
(LEGFunc) Legendre4, (LEGFunc) Legendre5, (LEGFunc) Legendre6
};
Here i get an "undefined reference" error for Legendre0 - Legendre6. I
checked the Legendre.o object file with nm and there the Legendre
objects exist but are undefined.
I solved it by moving the Legendre0-6 functions into the Legendre.c
file and i had to remove the static which now doesn't have any
function anymore in any case. With static the linker gives the same
errors.
Can somebody explain this to me?
Thank you,
Sascha