I’ve got 2 projects using the same custom librarie (written in C).
One is a C project and the second is a C++ project.
Both projects are configured the same, but only the C project compiles
without errors.
In the C++ project I’ve got the following error:
Idefix.o: In function GPI(void)': Idefix.o(.text+0xe08): undefined reference to
mpc85xx_get_ccsr(void)’
Idefix.o(.text+0xe08): relocation truncated to fit: R_PPC_REL24
“mpc85xx_get_ccsr(void)” is obviously a function of the custom librarie.
Any idea how to solve this?
Environment:
- Momentics (Windows hosted)
- QNX 6.3.0 SP1
- gcc 2.95.3
I’d guess it’s looking for the C++ name mangled version.
Do you have an extern “C” prototype defined?
Armand Ciejak wrote:
I’ve got 2 projects using the same custom librarie (written in C).
One is a C project and the second is a C++ project.
Both projects are configured the same, but only the C project compiles
without errors.
In the C++ project I’ve got the following error:
Idefix.o: In function GPI(void)': Idefix.o(.text+0xe08): undefined reference to
mpc85xx_get_ccsr(void)’
Idefix.o(.text+0xe08): relocation truncated to fit: R_PPC_REL24
“mpc85xx_get_ccsr(void)” is obviously a function of the custom librarie.
Any idea how to solve this?
Environment:
- Momentics (Windows hosted)
- QNX 6.3.0 SP1
- gcc 2.95.3
Garry Turcotte wrote:
I’d guess it’s looking for the C++ name mangled version.
Do you have an extern “C” prototype defined?
Yes → extern uint32_t mpc85xx_get_ccsr();
Armand Ciejak wrote:
I’ve got 2 projects using the same custom librarie (written in C).
One is a C project and the second is a C++ project.
Both projects are configured the same, but only the C project compiles
without errors.
In the C++ project I’ve got the following error:
Idefix.o: In function GPI(void)': Idefix.o(.text+0xe08): undefined reference to
mpc85xx_get_ccsr(void)’
Idefix.o(.text+0xe08): relocation truncated to fit: R_PPC_REL24
“mpc85xx_get_ccsr(void)” is obviously a function of the custom librarie.
Any idea how to solve this?
Environment:
- Momentics (Windows hosted)
- QNX 6.3.0 SP1
- gcc 2.95.3
Armand Ciejak wrote:
Garry Turcotte wrote:
I’d guess it’s looking for the C++ name mangled version.
Do you have an extern “C” prototype defined?
Yes → extern uint32_t mpc85xx_get_ccsr();
No → extern “C” uint32_t mpc85xx_get_ccsr();
without the “C”, you’d be looking for something
like mpc85xx_get_ccsr__Fv
Armand Ciejak wrote:
I’ve got 2 projects using the same custom librarie (written in C).
One is a C project and the second is a C++ project.
Both projects are configured the same, but only the C project
compiles without errors.
In the C++ project I’ve got the following error:
Idefix.o: In function GPI(void)': Idefix.o(.text+0xe08): undefined reference to
mpc85xx_get_ccsr(void)’
Idefix.o(.text+0xe08): relocation truncated to fit: R_PPC_REL24
“mpc85xx_get_ccsr(void)” is obviously a function of the custom librarie.
Any idea how to solve this?
Environment:
- Momentics (Windows hosted)
- QNX 6.3.0 SP1
- gcc 2.95.3
Armand Ciejak wrote:
Garry Turcotte wrote:
I’d guess it’s looking for the C++ name mangled version.
Do you have an extern “C” prototype defined?
Yes → extern uint32_t mpc85xx_get_ccsr();
Try:
extern “C” uint32_t mpc85xx_get_ccsr();
Presumably there would be a header (protected by extern “C” { … })
defining that prototype somewhere…
–
Chris Herborth (cherborth@qnx.com)
Never send a monster to do the work of an evil scientist.
Monthly QNX newsletter - http://www.qnx.com/news/forms/newsletter.html
On Tue, 30 Aug 2005 19:50:31 +0200, Chris Herborth <cherborth@qnx.com>
wrote:
Armand Ciejak wrote:
Garry Turcotte wrote:
I’d guess it’s looking for the C++ name mangled version.
Do you have an extern “C” prototype defined?
Yes → extern uint32_t mpc85xx_get_ccsr();
Try:
extern “C” uint32_t mpc85xx_get_ccsr();
Presumably there would be a header (protected by extern “C” { … })
defining that prototype somewhere…
Now in my C++ file:
extern “C” {
#include <mpc8540_gpio.h>
}
in mpc8540_gpio.h:
uint32_t mpc85xx_get_ccsr();
everything work fine except that I got no warning or error if I do that
(in the C++ file):
float tmp = mpc85xx_get_ccsr();
In other word I have to do data type checking myself
The method I use to incorporate C libraries in C++ projects is
to begin the library header file with…
#ifdef __cplusplus
extern “C” {
#endif
Then, at the end of the header file are the lines
#ifdef __cplusplus
}
#endif
Armand Ciejak wrote:
On Tue, 30 Aug 2005 19:50:31 +0200, Chris Herborth <> cherborth@qnx.com
wrote:
Armand Ciejak wrote:
Garry Turcotte wrote:
I’d guess it’s looking for the C++ name mangled version.
Do you have an extern “C” prototype defined?
Yes → extern uint32_t mpc85xx_get_ccsr();
Try:
extern “C” uint32_t mpc85xx_get_ccsr();
Presumably there would be a header (protected by extern “C” { … })
defining that prototype somewhere…
Now in my C++ file:
extern “C” {
#include <mpc8540_gpio.h
}
in mpc8540_gpio.h:
uint32_t mpc85xx_get_ccsr();
everything work fine except that I got no warning or error if I do that
(in the C++ file):
float tmp = mpc85xx_get_ccsr();
In other word I have to do data type checking myself >
I tried but It doesn’t change anything!!!
On Wed, 31 Aug 2005 13:30:52 +0200, JohnMcClurkin <jwm@lsr.nei.nih.gov>
wrote:
The method I use to incorporate C libraries in C++ projects is
to begin the library header file with…
#ifdef __cplusplus
extern “C” {
#endif
Then, at the end of the header file are the lines
#ifdef __cplusplus
}
#endif
Armand Ciejak wrote:
On Tue, 30 Aug 2005 19:50:31 +0200, Chris Herborth <> cherborth@qnx.com
wrote:
Armand Ciejak wrote:
Garry Turcotte wrote:
I’d guess it’s looking for the C++ name mangled version.
Do you have an extern “C” prototype defined?
Yes → extern uint32_t mpc85xx_get_ccsr();
Try:
extern “C” uint32_t mpc85xx_get_ccsr();
Presumably there would be a header (protected by extern “C” { … })
defining that prototype somewhere…
Now in my C++ file:
extern “C” {
#include <mpc8540_gpio.h
}
in mpc8540_gpio.h:
uint32_t mpc85xx_get_ccsr();
everything work fine except that I got no warning or error if I do
that (in the C++ file):
float tmp = mpc85xx_get_ccsr();
In other word I have to do data type checking myself >
–
Using Opera’s revolutionary e-mail client: http://www.opera.com/mail/
Now in my C++ file:
extern “C” {
#include <mpc8540_gpio.h
}
in mpc8540_gpio.h:
uint32_t mpc85xx_get_ccsr();
everything work fine except that I got no warning or error if I do that
(in the C++ file):
float tmp = mpc85xx_get_ccsr();
In other word I have to do data type checking myself >
That’s normal C/C++ behavior, doesn’t have anything to do with the extern C
stuff.
It’s an automatic promotion.
Armand Ciejak <armand.ciejak@free.fr> wrote:
On Tue, 30 Aug 2005 19:50:31 +0200, Chris Herborth <> cherborth@qnx.com
wrote:
Now in my C++ file:
extern “C” {
#include <mpc8540_gpio.h
}
in mpc8540_gpio.h:
uint32_t mpc85xx_get_ccsr();
everything work fine except that I got no warning or error if I do that
(in the C++ file):
float tmp = mpc85xx_get_ccsr();
Because that is perfectly acceptable.
Would you expect a problem with:
float tmp = 5;
Nope. You’ve done the same thing – assigned an integer to a float,
which is a perfectly acceptable (and expected) promotion, and will
not generate a warning or error.
-David
David Gibbs
QNX Training Services
dagibbs@qnx.com