C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 7th, 2013, 01:17 AM
Z.K. Z.K. is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2009
Posts: 184 Z.K. User rank is Sergeant Major (2000 - 5000 Reputation Level)Z.K. User rank is Sergeant Major (2000 - 5000 Reputation Level)Z.K. User rank is Sergeant Major (2000 - 5000 Reputation Level)Z.K. User rank is Sergeant Major (2000 - 5000 Reputation Level)Z.K. User rank is Sergeant Major (2000 - 5000 Reputation Level)Z.K. User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Day 1 h 40 m 47 sec
Reputation Power: 28
Question Eclipse compiler problems with multiple C files

I am not by any means and expert using eclipse and I am having a problem that does not make any sense to me. This should be fairly straight forward. create a *.h file for the *.c file and include the *.h file in my main c file and compile. But when I use the function name in my main function I get a undefined reference error. So, I was wondering if there is something else I need to do?

Code:
/*  
* gpiotests.h  
*  
*  Created on: Feb 6, 2013  
*       
*/  
#ifndef GPIOTESTS_H_ 
#define GPIOTESTS_H_  
void gpiotests(void);  
#endif 
/* GPIOTESTS_H_ */


Code:
/*  
* gpiotests.c  
*  
*  Created on: Feb 6, 2013  
*     
*/  
#define __GPIOTESTS_C__  
#include <stdint.h> 
#include "print.h" 
#include "gpiotests.h"  

char stringbuffer[MAX_STRINGBUFFER_SIZE]; 
 
void gpiotests(void) 
{  	

    sprintf(stringbuffer, "\n\rGPIO Tests\n\r");
    printString(stringbuffer);  
}


Code:
/*

Module Name:

    main.c

Module Description:

    Used to call other features.

Author:


--*/
#define __MAIN_C__

#include <stdio.h>
#include "print.h"
#include "gpiotests.h"

char stringbuffer[MAX_STRINGBUFFER_SIZE];


int main( void )
{
  
            
    gpiotests();
    

    return 0;
}

/*void gpiotests(void)
{

	sprintf(stringbuffer, "\n\rGPIO Tests\n\r");
	printString(stringbuffer);

}*/



Reply With Quote
  #2  
Old February 7th, 2013, 01:41 AM
dwise1_aol's Avatar
dwise1_aol dwise1_aol is offline
Contributing User
Dev Shed God 2nd Plane (6000 - 6499 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 6,123 dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 3 Days 16 h 5 m 8 sec
Reputation Power: 1949
I've never used Eclipse myself, but I would assume that it has features common to many other integrated development environments (IDEs). Such as project management.

Under File | New, it allows you to create a new project. Have you done that?

There should be a way to add files to that project, but I cannot find it (Visual Studio has it!). However, under File | New, you can add new files or classes or various other things.

The bottom line is that the project needs some way of knowing which files are part of the project. Once those files become part of the project, then whenever you build that project it will know to also compile those files and link their object files together. If they are not part of the project, then that won't happen and you will get undefined/unresolved references.

General principles of IDEs and project management.

Reply With Quote
  #3  
Old February 7th, 2013, 02:14 AM
Z.K. Z.K. is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2009
Posts: 184 Z.K. User rank is Sergeant Major (2000 - 5000 Reputation Level)Z.K. User rank is Sergeant Major (2000 - 5000 Reputation Level)Z.K. User rank is Sergeant Major (2000 - 5000 Reputation Level)Z.K. User rank is Sergeant Major (2000 - 5000 Reputation Level)Z.K. User rank is Sergeant Major (2000 - 5000 Reputation Level)Z.K. User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Day 1 h 40 m 47 sec
Reputation Power: 28
Quote:
Originally Posted by dwise1_aol
I've never used Eclipse myself, but I would assume that it has features common to many other integrated development environments (IDEs). Such as project management.

Under File | New, it allows you to create a new project. Have you done that?

There should be a way to add files to that project, but I cannot find it (Visual Studio has it!). However, under File | New, you can add new files or classes or various other things.

The bottom line is that the project needs some way of knowing which files are part of the project. Once those files become part of the project, then whenever you build that project it will know to also compile those files and link their object files together. If they are not part of the project, then that won't happen and you will get undefined/unresolved references.

General principles of IDEs and project management.


Yes, I did all that. It was part of a larger project that was working before until I added the new files. I did do the exact same thing in visual studio and it worked like I thought it should. I don't have an option of using a different compiler though.

Reply With Quote
  #4  
Old February 7th, 2013, 03:30 AM
dwise1_aol's Avatar
dwise1_aol dwise1_aol is offline
Contributing User
Dev Shed God 2nd Plane (6000 - 6499 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 6,123 dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 3 Days 16 h 5 m 8 sec
Reputation Power: 1949
As I said, I have never worked with Eclipse, though I did load it in a failed attempt to create a development environment for Android apps.

In Microsoft's Visual Studio, you have the "Project Explorer" tree-view that lists all files that have been added to the project. Do you have the same thing available for Eclipse?

Many IDEs allow you to generate a makefile for that project. Does Eclipse allow that as well? If so, then what does that makefile show you?

Sorry, but I'm at the end of my own rope at this point.

Reply With Quote
  #5  
Old February 7th, 2013, 06:59 PM
Z.K. Z.K. is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2009
Posts: 184 Z.K. User rank is Sergeant Major (2000 - 5000 Reputation Level)Z.K. User rank is Sergeant Major (2000 - 5000 Reputation Level)Z.K. User rank is Sergeant Major (2000 - 5000 Reputation Level)Z.K. User rank is Sergeant Major (2000 - 5000 Reputation Level)Z.K. User rank is Sergeant Major (2000 - 5000 Reputation Level)Z.K. User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Day 1 h 40 m 47 sec
Reputation Power: 28
Quote:
Originally Posted by dwise1_aol
As I said, I have never worked with Eclipse, though I did load it in a failed attempt to create a development environment for Android apps.

In Microsoft's Visual Studio, you have the "Project Explorer" tree-view that lists all files that have been added to the project. Do you have the same thing available for Eclipse?

Many IDEs allow you to generate a makefile for that project. Does Eclipse allow that as well? If so, then what does that makefile show you?

Sorry, but I'm at the end of my own rope at this point.


Okay, well thanks for trying.

Quote:
In Microsoft's Visual Studio, you have the "Project Explorer" tree-view that lists all files that have been added to the project. Do you have the same thing available for Eclipse?


Yes, it has the same thing.

Quote:
Many IDEs allow you to generate a makefile for that project. Does Eclipse allow that as well? If so, then what does that makefile show you?

Well, eclipse has the ability to compile with or without a make file. I chose both and had the same problem though I did not actually look at the make file. That is a good idea.

I did download another copy of eclipse, the juno version today and noticed it had the same problem. I also noticed that compiling a C++ project worked, but doing the exact same thing with the C project does not work.

Again, thanks for trying.

Reply With Quote
  #6  
Old February 7th, 2013, 11:13 PM
Z.K. Z.K. is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2009
Posts: 184 Z.K. User rank is Sergeant Major (2000 - 5000 Reputation Level)Z.K. User rank is Sergeant Major (2000 - 5000 Reputation Level)Z.K. User rank is Sergeant Major (2000 - 5000 Reputation Level)Z.K. User rank is Sergeant Major (2000 - 5000 Reputation Level)Z.K. User rank is Sergeant Major (2000 - 5000 Reputation Level)Z.K. User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Day 1 h 40 m 47 sec
Reputation Power: 28
Quote:
Originally Posted by dwise1_aol
As I said, I have never worked with Eclipse, though I did load it in a failed attempt to create a development environment for Android apps.

In Microsoft's Visual Studio, you have the "Project Explorer" tree-view that lists all files that have been added to the project. Do you have the same thing available for Eclipse?

Many IDEs allow you to generate a makefile for that project. Does Eclipse allow that as well? If so, then what does that makefile show you?

Sorry, but I'm at the end of my own rope at this point.


You were correct about the make file. I added the file to the make file by hand and it worked. I was assuming that would be done when I just added the new files, but I guess not. I don't use make files a lot. Of course I also had some problems where my virus scanner was deleting my executable, but that is another story. Anyway, it works now.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Eclipse compiler problems with multiple C files

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap