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 4 1607 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
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? 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.
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 --- This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Connell Gauld |
last post by:
Hi,
I am having problems compiling a small project in VC++ 6. I have
included the error below and the full project (including workspace) can
be downloaded here:...
|
by: VNG |
last post by:
I have an ANSI C program that was compiled under Windows MSVC++ 6.0 (SP6) and
under Linux gnu, and ran under P3, P4 and AMD.
It runs fine on P3 and AMD under both Windows and Linux, but under P4...
|
by: Roose |
last post by:
Just to make a tangential point here, in case anyone new to C doesn't
understand what all these flame wars are about.
Shorthand title: "My boss would fire me if I wrote 100% ANSI C code"
We...
|
by: Michael Gaab |
last post by:
Compilation in c generally has four phases
1. Preprocessing
2. Compilation
3. Assembly
4. Linking.
If I use a flag that will not link the code, order of compilation is not an
issue,...
|
by: RK |
last post by:
I need to compile a library of C code with pre-ANSI C functions using MS
..NET 2003. The functions are declared something like this:
int myFunction(p)
double p;
{
int x;
code here...
return...
|
by: wanghz |
last post by:
Hi,
Could I ask some questions about the conditional compilaion? Suppose I
have three simple files: a.c, b.c and c.h
/* --------a.c--------- */
#include <stdio.h>
#include "c.h"
int...
|
by: Jens Müller |
last post by:
I have a file here with several enums:
#ifndef PLANARSEP_OPTIMIZE_H
#define PLANARSEP_OPTIMIZE_H
enum fund_cycle_behavior_t
{PASS_MODE_FIRST,
PASS_MODE_BEST,
PASS_MODE_ALL};
|
by: dupin |
last post by:
Hi,
I´m compiling a C++ program with g++ 2.9.5 on SunOS 5.8. I have made a project with NetBeans 5.5.1 and getting from it the make files.
The compilation and linking process ocurrs...
|
by: Peng Yu |
last post by:
Hi,
ANSI and GNU C are different in some delicate aspects (I'm not sure
about C++). For example, M_PI is not in ANSI C but in GNU C.
Of course, to make my program most portable, I should go...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |