Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » Yocto Makefile.am doesn't not include new .c/.cpp files(Yocto ADT Autotools Project Makefile.am not adding new .c/.cpp files)
Yocto Makefile.am doesn't not include new .c/.cpp files [message #1773170] Fri, 22 September 2017 11:30 Go to next message
Eclipse UserFriend
Hi,

I have Eclipse-SDK-4.2.2-linux-gtk_x86_64 version installed with Yocto ADT plugin.

When I create C++ project with Yocto ADT Autotools wizard, the created project compiles and runs without error.

But when I add a .cpp /.c file into the project src folder, and refresh/clean the project, and recompile the project, it generates errors. I found that any functions in the user added .cpp file or .c file, can not be called from, because the files are simply not linked into the target file. I have to manually add the added .cpp file into the Makefile.am in the src folder.

such as (MyNewAdded.c):
bin_PROGRAM = HelloWorld.c MyNewAdded.c

Why the generated Makefile.am doesn't automatically include the MyNewAdded.c?

How to fix it?

Thank you,

David Zhou
Re: Yocto Makefile.am doesn't not include new .c/.cpp files [message #1773206 is a reply to message #1773170] Sun, 24 September 2017 04:32 Go to previous messageGo to next message
Eclipse UserFriend
Unfortunately, there is no easy way to automate this.
The usual way to specify Makefile.am is
bin_PROGRAMS=Hello
Hello_SOURCES=Hello.c MyNewAdded.c

But you can have more than one executable. For instance
bin_PROGRAMS=Hello HelloWorld
Hello_SOURCES=Hello.c
HelloWorld_SOURCES=Hello.c 

The autotools plugin would need to know which source files are needed for each executable.
It could just append it to all <exe>_SOURCES or perhaps just the first.
This may be fine for projects with single executables but potentially annoying for those with multiple executables.

That said, I've tried using wildcards such as: xxx_SOURCES=$(wildcard *.c)
but this confuses things and generates stuff like *.o instead of <file>.o

You could try writing a script (in say, Perl) that will modify the Makefile.am and it could even call automake and ./configure as well
FWIW: automake itself is a Perl script

[Updated on: Sun, 24 September 2017 09:26] by Moderator

Re: Yocto Makefile.am doesn't not include new .c/.cpp files [message #1773500 is a reply to message #1773206] Thu, 28 September 2017 11:43 Go to previous message
Eclipse UserFriend
Hi David Vavra,

Thank you for your explanation.

David
Previous Topic:Eclipse CDT "hello world" after "New ... Finish"
Next Topic:Remote Debugging Issue
Goto Forum:
  


Current Time: Thu Mar 20 14:15:34 EDT 2025

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

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

Back to the top