Eclipse CDT doesn't use my Makefile when I try to build. - c

I have some source code with a Makefile that builds just fine from the command line.
I followed the eclipse CDT instructions for importing a project with existing sources.
I opened the make file, and saw all the makefile targets in the Outline view.
I right clicked on one, and added it to the "Make Target" tab.
I double clicked it, and the console said it couldn't find that target:
14:24:13 **** Build of configuration Debug for project xxxxxxxxxx ****
make build-modules
make: *** No rule to make target `build-modules'. Stop.
Go back to the command line and type "make build-modules" and it works fine.
There are no other makefiles in this project. I do not know why this is failing like this.

1) Create a new project in Eclipse.
2) Import just the files that you already have.
3) Click build and make sure that you have clicked inside an open file of the project, that is open in the editor view.
User had to do also:
"Import project from Makefile" and that got my targets working.

Related

Eclipse/Neon.2 ignoring a source file

I'm working with a CDT project in Eclipse/Neon.2 which cross compiles for an embedded target. I've added a bunch of .c files to the project and they are automatically included in the build except for (seemingly) one. In the project directory it is
STM32F7explore/Utilities/Log/lcd_log.c where STM32F7explore is the Eclipse project directory. If I try to build it manually, the Console window shows:
09:45:52 **** Building Selected Files of configuration Debug for project STM32F7explore ****
Info: Internal Builder is used for build
09:45:52 Build Finished (took 1ms)
For files that are included, the Console shows e.g.
09:54:50 **** Building Selected Files of configuration Debug for project STM32F7explore ****
Info: Internal Builder is used for build
arm-none-eabi-gcc -mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-sp-d16 -D__weak=__attribute__((weak)) -D__packed=__attribute__((__packed__)) -DUSE_HAL_DRIVER -DSTM32F746xx -DLWIP_TIMEVAL_PRIVATE=0 -I../Inc -I../Drivers/STM32F7xx_HAL_Driver/Inc -I../Drivers/STM32F7xx_HAL_Driver/Inc/Legacy -I../Drivers/CMSIS/Device/ST/STM32F7xx/Include -I../Drivers/CMSIS/Include -I../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM7/r0p1 -I../Middlewares/Third_Party/FreeRTOS/Source/include -I../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS -I../Middlewares/Third_Party/LwIP/src/include -I../Middlewares/Third_Party/LwIP/system -I../Middlewares/Third_Party/LwIP/src/include/lwip -I../Middlewares/Third_Party/LwIP/src/include/lwip/apps -I../Middlewares/Third_Party/LwIP/src/include/lwip/priv -I../Middlewares/Third_Party/LwIP/src/include/lwip/prot -I../Middlewares/Third_Party/LwIP/src/include/netif -I../Middlewares/Third_Party/LwIP/src/include/netif/ppp -I../Middlewares/Third_Party/LwIP/src/include/netif/ppp/polarssl -I../Middlewares/Third_Party/LwIP/src/include/posix -I../Middlewares/Third_Party/LwIP/src/include/posix/sys -I../Middlewares/Third_Party/LwIP/system/arch -I../Drivers/BSP/STM32746G_Discovery -I../Utilities/Log -O0 -g3 -Wall -fmessage-length=0 -ffunction-sections -c -fmessage-length=0 -o Src/main.o ../Src/main.c
09:54:51 Build Finished (took 224ms)
I'm baffled by why Eclipse doesn't add the lcd_log.c file to the build. I've looked at the file properties popup and they look the same for both (and in particular, Eclipse does recognize lcd_log.c as File (C Source File)
I've deleted .metadata/.plugins/org.eclipse.core.runtime/.settings from the workspace and .settings from the project to force Eclipse to regenerate these and that did not fix the problem.
The project is on Github (https://github.com/HankB/STM32F7explore) but the requirements to build are a bit steep unless you happen to be developing for ST embedded processors.
Thanks!
What is going on here is the Log (or its parent Utilities) directory is not part of the source of your project, but rather extra files in the project that are excluded.
There are some visual clues in the project explorer. Compare the two boxes in red below:
As you can see the Src and dma2d.c files use different icons than Log and lcd_log.c.
You can re-enable the folder, or individual files, by right-clicking -> Resource Configurations -> Exclude From Build... and unchecking Debug and Release in the pop-up that looks like this:
You can also control what is included by selecting project properties -> C/C++ General -> Paths and Symbols -> Source Locations tab.
What I would recommend is that rather than having Drivers, Inc, etc be explicitly included, that you include all files in your project starting at the root. To do that, select all the existing entries in Source Locations and press Delete. You should then have just one automatically re-created entry /STM32F7Explore, like this: (Remember to do the same change to both Debug and Release)
Then, if you actually do want to exclude files/folders, repeat the above steps with Resource Configurations. CDT will be be quite helpful here, if you have individual files/folders under a source directory excluded from the build you will get yet another icon. Here I have excluded a single C file (log_lcd.c) and the Fonts directory:
Some of the specific help for Eclipse CDT that relates to the above:
Icon overlays appear at the bottom of the C/C++ Projects View help
Source locations tab help

"symbol not found" in C codes of makefile project in xcode

I create a makefile project in xcode4.5 (OSX -> Other -> External Build System) and add some c files into it. And I can make the project successfully.
But it tells me "symbol not found" when I try to jump to the definition of a function.
I try some ways from google, such as delete the xcworkspace and xcuserdata folders and delete derived data of project and so on. But all they fail. Any solutions?
BTW, my project is very simple and locates here.
Makefile and code works fine commandline.
Setup a quick project in xcode (5.1.1 btw, it's what I have
installed)
OSX->Other->External Build System
Set the project directory to the git checkout in the project creation
wizard.
In the External Build Tool Configuration->Info, set the Directory to
the git checkout directory.
Product->Build
Builds fine, runs fine.
Nothing more can be done to help if there isn't a something in the steps I took that helps, would have to look at a dmg of your xcode project.

error compiling C code in Eclipse

I am new to using Eclipse and CDT and have been trying to get my C code to compile. When I Run As Local C Application, it returns an error message Launch Failed. Binary Not Found. I have MinGW-w64 in C:\mingw-w64. The program compiles and runs fine using gcc via cmd.
I would appreciate if eclipse-proficient users can help out with a how-to. Thanks!
Sometimes, if you try to launch first (before binary has been compiled) eclipse creates launch configuration automatically, that has no binary associated. Later even if you compiled your project (you do this using project/build or hammer icon), it will not associate binary automatically, as it tries to launch your old launch configuration. So:
make sure one of projects source files are selected (in editor for example)
click a down arrow next to bug icon
select debug configurations
select C/C++ application and click on "new launch configuration icon"
If C/C++ application field of your new launch configuration is empty, select search project or browse and tell it where your binary is
optionally set other launch/debug options
launch your new launch configuration using "Debug" button or from "bug" menu

Creating Project from existing source code in Eclipse

I am new to Eclipse. Working on school project from source code provided by instructor. Project compiles without problems using provided makefile, but I want to compile/edit inside of Eclipse.
I have tried to import as Makefile project, but right away getting an error
make: *** No rule to make target `all'.
Here is a basic list of files.
Main:
Makefile
mm.{c,h}
malloc.c
mdriver.c
short{1,2}-bal.rep
Supporting:
config.h
fsecs.{c,h}
clock.{c,h}
fcyc.{c,h}
ftimer.{c,h}
memlib.{c,h}
Why I can't simply "Import" source, as I can do it in Visual Studio ?
Thanks !
CDT will attempt to build the project using make all, and it seems that your Makefile does not have that target. Easiest is to add:
all: your-target-to-make-stuff
to your Makefile. If you want to configure how CDT invokes make, you can right-click on the project, select Properties → C/C++ Build. Under the Behavior tab, you can select which make targets CDT should invoke when building and cleaning.
I don't have an Eclipse with C/C++ plugin at my hands right now, but I have an idea what it could be:
It appears that your Eclipse is starting make with the specific target 'all', which doesn't seem to exist in the Makefile - you should be able to reproduce this behavior on the command line with the command make all instead of just make.
If this is the case, there are two solutions: one is to modify the Makefile to introduce a target 'all'; or modify the C/C++ builder settings in Eclipse to execute the make without any argument.
You can install the C/C++ for developers plugin.
Or in many cases I would use Ant to create or call make files.

Using custom Makefile with Eclipse/CDT [duplicate]

This question already has answers here:
How to use external makefile in Eclipse
(3 answers)
Closed 5 years ago.
I have a project of multiple .c and .h files and I write my own makefile.
How can I configure Eclipse to use my makefile and my source files from their original locations?
You can create a custom Makefile and make sure it's in your project root. Then you need to disable the auto generated makefiles. You can do that by going here:
Project Properties (right click on project and select properties) -> C/C++ Build -> in that window uncheck "Generate Makefiles Automatically."
To use your own targets you can open the View called "Make Target":
Window -> Show View -> Make Target
In that view you can create a new target that will use the corresponding target in your custom Makefile.
There is an option to create a project from existing makefiles: use the "Project Wizard" and select "Makefile project".
You can disable "Generate makefiles automatically" in eclipse project properties -> c/c++ build (builder settings.)
In my latest attempt to compile a Cross ARM compile, I made a painful discovery on how to get this working.
First I created a "Makefile project with existing Code". I selected the Cross ARM tool chain. If I now open a console within Eclipse and make, it works.
Now to build within the GUI, I had to:
Change properties to Internal Builder, with Generate Makefile
checked.
The settings option now offers Build Artifact tab. pick executable with ${Project}.
Build. This will result in error in link stage.
Switch the settings to External Builder, uncheck "Automatic Makefile generation"
Clean
Build
All that you have to do is tell gmake to use your makefile. The default command for Code Composer Studio is ${CCS_UTILS_DIR}/bin/gmake. Simply tell gmake to use your own makefile (e.g. sri.mk). We do this with the -f option. So the default command would become ${CCS_UTILS_DIR}/bin/gmake -f ../sri.mk
Note that Code Composer Studio is Eclipse based.
Here are the instructions:
project->properties->C/C++ Build
click on the 'Builder' tab
Un-select 'Use default build command"
Change the command to ${CCS_UTILS_DIR}/bin/gmake -f ../sri.mk
Note that the build is kicked off from the Debug directory. The Debug directory contains the makefiles that are generated by Eclipse. I put my makefile in the top level directory of the project so that's why I put ../ in -f ../sri.mk.
Also, there might be a line that says "default: esh $(PLUGIN_SO)," or something along those lines depending on your project. I've found that changing the "default" to "all" will enable the project to compile too. This is a handy feature, eclipse :)

Resources