The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> C Programming
|
Eclipse compiler problems with multiple C files
Discuss Eclipse compiler problems with multiple C files in the C Programming forum on Dev Shed. Eclipse compiler problems with multiple C files C programming forum discussing all C derivatives, including C#, C++, Object-C, and even plain old vanilla C. These languages are low level languages, and used on projects such as device drivers, compilers, and even whole computer operating systems.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

February 7th, 2013, 01:17 AM
|
|
|
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);
}*/

|

February 7th, 2013, 01:41 AM
|
 |
Contributing User
|
|
Join Date: Jan 2003
Location: USA
|
|
|
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.
|

February 7th, 2013, 02:14 AM
|
|
|
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.
|

February 7th, 2013, 03:30 AM
|
 |
Contributing User
|
|
Join Date: Jan 2003
Location: USA
|
|
|
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.
|

February 7th, 2013, 06:59 PM
|
|
|
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.
|

February 7th, 2013, 11:13 PM
|
|
|
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.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|