473,657 Members | 2,435 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1621
or******@hotmai l.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.goo glegroups.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.goo glegroups.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1510
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: http://www.freebreakfast.co.uk/Example1.zip I am new to C++ (esp. using multiple files) and I am not sure I have structured the files right (with the correct includes etc). Any other suggestions about the code would be greatly appreciated. Also, how do I implement threading in...
1
1830
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 it has problems. Under Windows 3GHz P4 runs twice slower than 800MHz P3... and under Linux not only that it runs slower (while AMD is 40 times faster), but it also produces wrong numerical results... Any suggestion what can be the problem?
100
6945
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 are discussing whether this newsgroup should focus on 100% ANSI C or simply topics related to the C language in the real world. There is a C standard which is defined by an international committee. People who write compilers refer to this in...
11
2552
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, right? I am not that familiar with compilers so I am not sure. It seems to me that it would not make a difference as to *which* file was compiled *when*. Dependencies are only an issue during linking?
5
1693
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 x; }
12
2485
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 main()
3
2130
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};
7
1533
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 succesfully. At run time, the porgram fails whit "SEGMENTATION FAULT". I have acces to the originals make files (gererated with Autoconf / Automake), using this file the program executes succesfully. This seems to be a good "turn around" for the...
6
2634
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 for ANSI. But since ANSI lacks some convenient facilities, such as M_PI just mentioned, I would like to use GNU C. Now, the question is if a platform has ANSI C, what is the chance it
0
8395
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8310
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8826
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
4155
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4306
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.