469,592 Members | 2,030 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,592 developers. It's quick & easy.

ANSI C Compilation linking problem

Ben
I get an error when the compilator tries to link the object files of
my program. I have the files group.h and group.c that use a struct
define in logic.h and two fonctions define in logic.c.

The program compile group.o fine, but when trying to link, I get an
error in group.h saying that a struct that is defined in logic.h
cannot be found. Include logic.h is explicitly call in group.h because
it used an instance of that struct. What I dont understand is how,
when the program compile, it is able to find the reference to the
struct in logic, but when he tries to link, he does not find it
anymore.

If I take all the code from logic.h and logic.c and I copy it in
group.h and group.c respectively, it links fine.

I don't know what else to try, any ideas is welcome.

Benoit Grimard
Nov 15 '05 #1
4 1500
or******@hotmail.com (Ben) wrote:
I get an error when the compilator tries to link the object files of
my program. I have the files group.h and group.c that use a struct
define in logic.h and two fonctions define in logic.c.

The program compile group.o fine, but when trying to link, I get an
error in group.h saying that a struct that is defined in logic.h
cannot be found.


This sounds suspicious. By the time you're linking, you shouldn't be
refering to group.h any more - by then they should all be object files
created during the compilation stage. What precisely is the error you
get?

Richard
Nov 15 '05 #2


Ben wrote:
I get an error when the compilator tries to link the object files of
my program. I have the files group.h and group.c that use a struct
define in logic.h and two fonctions define in logic.c.

The program compile group.o fine, but when trying to link, I get an
error in group.h saying that a struct that is defined in logic.h
cannot be found. Include logic.h is explicitly call in group.h because
it used an instance of that struct. What I dont understand is how,
when the program compile, it is able to find the reference to the
struct in logic, but when he tries to link, he does not find it
anymore.

If I take all the code from logic.h and logic.c and I copy it in
group.h and group.c respectively, it links fine.

I don't know what else to try, any ideas is welcome.

Benoit Grimard


Can you show us the exact commands you are using to compile and link,
and the exact error message you are getting?

Nov 15 '05 #3
Ben
jo*******@my-deja.com wrote in message news:<11*********************@f14g2000cwb.googlegr oups.com>...
Ben wrote:
I get an error when the compilator tries to link the object files of
my program. I have the files group.h and group.c that use a struct
define in logic.h and two fonctions define in logic.c.

The program compile group.o fine, but when trying to link, I get an
error in group.h saying that a struct that is defined in logic.h
cannot be found. Include logic.h is explicitly call in group.h because
it used an instance of that struct. What I dont understand is how,
when the program compile, it is able to find the reference to the
struct in logic, but when he tries to link, he does not find it
anymore.

If I take all the code from logic.h and logic.c and I copy it in
group.h and group.c respectively, it links fine.

I don't know what else to try, any ideas is welcome.

Benoit Grimard


Can you show us the exact commands you are using to compile and link,
and the exact error message you are getting?

The ANSI-C code Im writing is to be run on opentv middleware platform,
and it just ended up that modified GNU compiler didnt catch an error
while making logic.o. I think because it postponed the definition of a
pointer to a struct because the include for that struct was missing.
So the logic.o wasnt really compile and he forgot that it wasnt
complete and still tryed to link it. So, he wasnt able to find the
struct in the not complete logic.o, so it gave me an error in group.h.
I have yet to understand why the compiler didnt catch that or write an
error code on the good object at least.

^^^^^^
I have include the file which contain the struct and it compile and
link fine, this is just a guess of what I think happened.

It was my fault after all, but the compiler didnt helped me to find
the error at all.
Nov 15 '05 #4
Ben wrote:
jo*******@my-deja.com wrote in message news:<11*********************@f14g2000cwb.googlegr oups.com>...
Ben wrote:
I get an error when the compilator tries to link the object files of
my program. I have the files group.h and group.c that use a struct
define in logic.h and two fonctions define in logic.c.

The program compile group.o fine, but when trying to link, I get an
error in group.h saying that a struct that is defined in logic.h
cannot be found. Include logic.h is explicitly call in group.h because
it used an instance of that struct. What I dont understand is how,
when the program compile, it is able to find the reference to the
struct in logic, but when he tries to link, he does not find it
anymore.

If I take all the code from logic.h and logic.c and I copy it in
group.h and group.c respectively, it links fine.

I don't know what else to try, any ideas is welcome.

Benoit Grimard


Can you show us the exact commands you are using to compile and link,
and the exact error message you are getting?


The ANSI-C code Im writing is to be run on opentv middleware platform,
and it just ended up that modified GNU compiler didnt catch an error
while making logic.o. I think because it postponed the definition of a
pointer to a struct because the include for that struct was missing.
So the logic.o wasnt really compile and he forgot that it wasnt
complete and still tryed to link it. So, he wasnt able to find the
struct in the not complete logic.o, so it gave me an error in group.h.
I have yet to understand why the compiler didnt catch that or write an
error code on the good object at least.

^^^^^^
I have include the file which contain the struct and it compile and
link fine, this is just a guess of what I think happened.

It was my fault after all, but the compiler didnt helped me to find
the error at all.


Most of my C programming involves only one 'source.c' file. As soon as I
have two translation units, I do compiles with 'make' and a carefully
constructed makefile. It saves a lot of time.

--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Nov 15 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Connell Gauld | last post: by
1 post views Thread by VNG | last post: by
100 posts views Thread by Roose | last post: by
11 posts views Thread by Michael Gaab | last post: by
12 posts views Thread by wanghz | last post: by
3 posts views Thread by Jens Müller | last post: by
6 posts views Thread by Peng Yu | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.