Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » including source files in a project
including source files in a project [message #1753901] Sun, 12 February 2017 00:23 Go to next message
Eric Von Hoene is currently offline Eric Von HoeneFriend
Messages: 4
Registered: February 2017
Junior Member
ok, I feel kinda ridiculous asking this question, but I must be missing something really simple --

I'm writing a C program in Eclipse (for an STM32 application). I started with a canned "hello world" program that works great. Step 2 was to modify it to use a new peripheral, that requires new functions, defined in other library files.

I think all of the library files are in the project workspace. The new source files I need are in the same directory as others used in the original program. But when I try to build my project, it can't find the functions, failing with "undefined reference" errors. The header files seem to be included ok -- the source compilation succeeds. It's the link that's failing.

The new library source files are shown in the Project Explorer tree, and I can open them, but the names are greyed-out and there is a slash through the icon next to them.

Can some charitable soul please tell me what obvious thing I'm overlooking?

With lots of files in the project include directories, how does Eclipse know which ones to include in the build, and which ones to ignore?

thanks!
-Eric
Re: including source files in a project [message #1754002 is a reply to message #1753901] Mon, 13 February 2017 18:00 Go to previous messageGo to next message
Eric Von Hoene is currently offline Eric Von HoeneFriend
Messages: 4
Registered: February 2017
Junior Member
Anybody? Please?

Every internet search I make on including source files references how to include folders and such; but it seems that my folder is already part of the project -- other files in the same folder are compiled and linked correctly, and I can see the file I want in the exact same hierarchy in the Explorer pane, and I can open the file in Eclipse. It just doesn't compile and link with my project.

I am sure that it is something very simple that I'm missing, but searching for it hasn't given me any leads.....
Re: including source files in a project [message #1754020 is a reply to message #1754002] Mon, 13 February 2017 20:37 Go to previous messageGo to next message
Tauno Voipio is currently offline Tauno VoipioFriend
Messages: 742
Registered: August 2014
Senior Member
Your terminology is quite vague, but I'll make a guess:

You're intending to use functions from a static archive library file, and you have succeeded in compiling the main program with the proper header source files (.h).

There is more to it: You need to add the library file (usually libsomething.a) to the link instructions to get the required object modules from the archive.

How to add the required information depends on the way the linking is set up. It may be using a ready-made Makefile or using the CDT Makefile builder. For the CDT Makefile builder, see the instructions in the Eclipse Help CDT section.


--

Tauno Voipio
Re: including source files in a project [message #1754030 is a reply to message #1754020] Tue, 14 February 2017 02:23 Go to previous messageGo to next message
Eric Von Hoene is currently offline Eric Von HoeneFriend
Messages: 4
Registered: February 2017
Junior Member
ok, thanks for the reply!

And I apologize for sounding vague -- Eclipse is (obviously) a new environment for me, so I'm not sure even how to ask the question properly. I'm used to Microchip's IDE, and everything there is neatly integrated. Just installing all of the accessories to the Eclipse environment to be able to code, compile, download, and debug was a bit bewildering!

So, some clarification (I hope) -- I'm not trying to link to a compiled library. I have a library of source code, .c and .h files. The sample program successfully pulls in the necessary library files to build the application. My changes use functions in other files in the same directory, but for some reason they're not getting compiled and linked in. I have added the .h files to my code that uses the new functions, and that all compiles fine. But since the additional library .c files weren't compiled, the link fails.

Specifically, I'm developing for an ST Nucleo board, STM32F303RE, using the GNU ARM Eclipse distribution, the Cross ARM GCC toolchain, and the "Blinky (blink a led)" sample program with the stm32f30x standard peripheral library. The file stm32f30x_gpio.c compiles just fine; but the file stm32f30x_adc.c (which is in the same directory) is shown as not in the project (it's greyed out in the Project Explorer pane).

How do I get the environment to know that I need it to include the _adc.c file as well? I can't believe I'm stuck on what must be such a simple thing....
Re: including source files in a project [message #1754061 is a reply to message #1754030] Tue, 14 February 2017 08:57 Go to previous messageGo to next message
Tauno Voipio is currently offline Tauno VoipioFriend
Messages: 742
Registered: August 2014
Senior Member
The GNU ARM Eclipse is a Github project outside of the Eclipse project.

Have you read and followed the instructions at <http://gnuarmeclipse.github.io/>?


--

Tauno Voipio
Re: including source files in a project [message #1754175 is a reply to message #1754061] Wed, 15 February 2017 02:37 Go to previous message
Eric Von Hoene is currently offline Eric Von HoeneFriend
Messages: 4
Registered: February 2017
Junior Member
I have read and followed countless instructions. I am certain that there are several places that tell exactly how to do what it is that I am stuck on. But wading through endless documentation about similar-but-not-quite-right instructions is not very productive. I was hoping that my question was simple enough that someone could just take pity on me and clue me in.

Clearly, though, I'm asking the wrong question in the wrong place. So I guess I'll try over there.

thanks,
Eric
Previous Topic:Eclipse won't start? EXIT CODE 13, Java 9 and newer, macOS, and more
Next Topic:Java Runtime Environment-( JRE )
Goto Forum:
  


Current Time: Thu Apr 25 08:53:13 GMT 2024

Powered by FUDForum. Page generated in 0.08350 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top