Why make utility cannot find header file? - eclipse

I have been working in Eclipse based IDE called Vitis (IDE from Xilinx).
I have an automatically generated software project containing three automatically
generated Makefiles. Organization of the project is following:
zynq_fsbl
-Makefile_level_01
-main.c
-zynq_fsbl_bsp
-Makefile_level_02
-ps7_cortexa9_0
-code
-include
-Config.h
-lib
-libsrc
-peripheral_01
-src
-driver_peripheral_01.c
-driver_peripheral_01.h
-Makefile_level_03_01
-peripheral_02
-src
-driver_peripheral_02.c
-driver_peripheral_02.h
-Makefile_level_03_02
- ... same pattern repeats for other perpherals
Makefile_level_01 contains:
# Auto Generated by Xilinx generate_app. Modify at your own risk
CC := arm-none-eabi-gcc
CC_FLAGS := -MMD -MP -mcpu=cortex-a9 -mfpu=vfpv3 -mfloat-abi=hard
CFLAGS :=
LN_FLAGS := -mcpu=cortex-a9 -mfpu=vfpv3 -mfloat-abi=hard -Wl,-build-id=none -specs=Xilinx.spec -lrsa -Wl,--start-group,-lxil,-lgcc,-lc,--end-group -Wl,--start-group,-lxilffs,-lxil,-lgcc,-lc,--end-group -Wl,--start-group,-lrsa,-lxil,-lgcc,-lc,--end-group -Wl,--gc-sections
c_SOURCES := $(wildcard *.c)
S_SOURCES := $(wildcard *.S)
INCLUDES := $(wildcard *.h)
OBJS := $(patsubst %.c, %.o, $(c_SOURCES))
OBJS += $(patsubst %.S, %.o, $(S_SOURCES))
LSCRIPT := -Tlscript.ld
CURRENT_DIR = $(shell pwd)
DEPFILES := $(patsubst %.o, %.d, $(OBJS))
LIBS := zynq_fsbl_bsp/ps7_cortexa9_0/lib/libxil.a
EXEC := executable.elf
INCLUDEPATH := -Izynq_fsbl_bsp/ps7_cortexa9_0/include -I.
LIBPATH := -Lzynq_fsbl_bsp/ps7_cortexa9_0/lib -L./
all: $(EXEC)
$(EXEC): $(LIBS) $(OBJS) $(INCLUDES)
$(CC) -o $# $(OBJS) $(CC_FLAGS) $(CFLAGS) $(LN_FLAGS) $(LIBPATH) $(LSCRIPT)
$(LIBS):
$(MAKE) -C zynq_fsbl_bsp
%.o:%.c
$(CC) $(CC_FLAGS) $(CFLAGS) -c $< -o $# $(INCLUDEPATH)
%.o:%.S
$(CC) $(CC_FLAGS) $(CFLAGS) -c $< -o $# $(INCLUDEPATH)
%.o:%.s
$(CC) $(CC_FLAGS) $(CFLAGS) -c $< -o $# $(INCLUDEPATH)
clean:
rm -rf $(OBJS) $(LIBS) $(EXEC) *.o
-include $(DEPFILES)
Makefile_level_02 contains:
# Makefile generated by Xilinx.
PROCESSOR = ps7_cortexa9_0
LIBRARIES = ${PROCESSOR}/lib/libxil.a
BSP_MAKEFILES := $(wildcard $(PROCESSOR)/libsrc/*/src/Makefile)
SUBDIRS := $(patsubst %/Makefile, %, $(BSP_MAKEFILES))
ifneq (,$(findstring win,$(RDI_PLATFORM)))
SHELL = CMD
endif
all: libs
#echo 'Finished building libraries'
include: $(addsuffix /make.include,$(SUBDIRS))
libs: $(addsuffix /make.libs,$(SUBDIRS))
clean: $(addsuffix /make.clean,$(SUBDIRS))
$(PROCESSOR)/lib/libxil.a: $(PROCESSOR)/lib/libxil_init.a
cp -f $< $#
%/make.include: $(if $(wildcard $(PROCESSOR)/lib/libxil_init.a),$(PROCESSOR)/lib/libxil.a,)
#echo "Running Make include in $(subst /make.include,,$#)"
$(MAKE) -C $(subst /make.include,,$#) -s include "SHELL=$(SHELL)" "COMPILER=arm-none-eabi-gcc" "ASSEMBLER=arm-none-eabi-as" "ARCHIVER=arm-none-eabi-ar" "COMPILER_FLAGS= -O2 -c" "EXTRA_COMPILER_FLAGS=-mcpu=cortex-a9 -mfpu=vfpv3 -mfloat-abi=hard -nostartfiles -g -Wall -Wextra"
%/make.libs: include
#echo "Running Make libs in $(subst /make.libs,,$#)"
$(MAKE) -C $(subst /make.libs,,$#) -s libs "SHELL=$(SHELL)" "COMPILER=arm-none-eabi-gcc" "ASSEMBLER=arm-none-eabi-as" "ARCHIVER=arm-none-eabi-ar" "COMPILER_FLAGS= -O2 -c" "EXTRA_COMPILER_FLAGS=-mcpu=cortex-a9 -mfpu=vfpv3 -mfloat-abi=hard -nostartfiles -g -Wall -Wextra"
%/make.clean:
$(MAKE) -C $(subst /make.clean,,$#) -s clean
clean:
rm -f ${PROCESSOR}/lib/libxil.a
Makefile_level_03 for peripheral_01 contains:
COMPILER=
ARCHIVER=
CP=cp
COMPILER_FLAGS=
EXTRA_COMPILER_FLAGS=
LIB=libxil.a
LEVEL=0
RELEASEDIR=../../../lib
INCLUDEDIR=../../../include
INCLUDES=-I./. -I${INCLUDEDIR}
INCLUDEFILES=*.h
LIBSOURCES=*.c
OUTS = *.o
libs:
echo "Compiling driver_peripheral_01 ..."
$(COMPILER) $(COMPILER_FLAGS) $(EXTRA_COMPILER_FLAGS) $(INCLUDES) $(LIBSOURCES)
$(ARCHIVER) -r ${RELEASEDIR}/${LIB} ${OUTS}
make clean
include:
${CP} $(INCLUDEFILES) $(INCLUDEDIR)
clean:
rm -rf ${OUTS}
My problem is that I am not able to compile the driver_peripheral_01.c module due to the problem with
Config.h header file inclusion. The "fatal error: Config.h: No such file or directory" is being invoked despite the fact that I have copied the header file in question into the include subdirectory in project directory structure. Does anybody have any idea why the make cannot find the Config.h header file? Thanks for any suggestions.

Related

rpmbuild bad exit status error while creating binary RPM

It is my first time creating RPM package and I followed this documentation to build a simple RPM package. I created source RPM but I can't create binary RPM.
Here is the result when I execute rpmbuild --rebuild /SRPMS/bello-0.1.1.el8.src.rpm:
Installing ../SRPMS/bello-0.1-1.el8.src.rpm
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.LmHvbG
+ umask 022
+ cd /root/rpmbuild/BUILD
+ cd /root/rpmbuild/BUILD
+ rm -rf bello-0.1
+ /usr/bin/gzip -dc /root/rpmbuild/SOURCES/bello-0.1.tar.gz
+ /usr/bin/tar -xof -
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd bello-0.1
+ /usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ exit 0
Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.k6UGT9
+ umask 022
+ cd /root/rpmbuild/BUILD
+ cd bello-0.1
+ CFLAGS='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection'
+ export CFLAGS
+ CXXFLAGS='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection'
+ export CXXFLAGS
+ FFLAGS='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -I/usr/lib64/gfortran/modules'
+ export FFLAGS
+ FCFLAGS='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -I/usr/lib64/gfortran/modules'
+ export FCFLAGS
+ LDFLAGS='-Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld'
+ export LDFLAGS
+ '[' 1 = 1 ']'
+++ dirname ./configure
++ find . -name config.guess -o -name config.sub
+ '[' 1 = 1 ']'
+ '[' x '!=' 'x-Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld' ']'
++ find . -name ltmain.sh
+ ./configure --build=x86_64-redhat-linux-gnu --host=x86_64-redhat-linux-gnu --program-prefix= --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64 --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/var/lib --mandir=/usr/share/man --infodir=/usr/share/info
/var/tmp/rpm-tmp.k6UGT9: line 49: ./configure: No such file or directory
error: Bad exit status from /var/tmp/rpm-tmp.k6UGT9 (%build)
RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.k6UGT9 (%build)
I get the same result when I execute rpmbuild -bb bello.spec command.
Here is my SPEC file:
Name: bello
Version: 0.1
Release: 1%{?dist}
Summary: Hello World example implemented in bash script
License: GPLv3+
URL: https://example.com/%{name}
Source0: https://example.com/%{name}/releases/%{name}-%{version}.tar.gz
Requires: bash
BuildArch: noarch
%description
some description for this basic code.
%prep
%setup -q
%build
%configure
%make_build
%install
mkdir -p %{buildroot}/%{_bindir}
install -m 0755 %{name} %{buildroot}/%{_bindir}/%{name}
%make_install
%files
%{_bindir}/%{name}
%license LICENSE
%doc add-docs-here
%changelog
* Tue Aug 30 2022 talat ayhan <fadedship#gmail.com> - 0.1-1
- First bello package
- Example second item in the changelog for version-release 0.1-1

Cannot install Algorithm::AhoCorasick::XS on Windows 10, MSYS2: ‘sigjmp_buf’ does not name a type; did you mean ‘Sigjmp_buf’

I am trying to install Algorithm::AhoCorasick::XS on Windows 10, MSYS2:
$ perl Makefile.PL
Generating a Unix-style Makefile
Writing Makefile for Algorithm::AhoCorasick::XS
Writing MYMETA.yml and MYMETA.json
cp lib/Algorithm/AhoCorasick/XS.pm blib/lib/Algorithm/AhoCorasick/XS.pm
Running Mkbootstrap for XS ()
chmod 644 "XS.bs"
"/usr/bin/perl.exe" -MExtUtils::Command::MM -e 'cp_nonempty' -- XS.bs blib/arch/auto/Algorithm/AhoCorasick/XS/XS.bs 644
g++ -c -Wall -std=c++11 -DUSEIMPORTLIB -march=x86-64 -mtune=generic -O2 -pipe -DVERSION=\"0.04\" -DXS_VERSION=\"0.04\" "-I/usr/lib/perl5/core_perl/CORE" Matcher.cpp
"/usr/bin/perl.exe" "/usr/share/perl5/core_perl/ExtUtils/xsubpp" -C++ -typemap '/usr/share/perl5/core_perl/ExtUtils/typemap' -typemap '/home/hakon/perl/cpan-source/Algorithm-AhoCorasick-XS-0.04/perlobject.map' -typemap '/home/hakon/perl/cpan-source/Algorithm-AhoCorasick-XS-0.04/typemap' -typemap '/home/hakon/perl/cpan-source/Algorithm-AhoCorasick-XS-0.04/typemap' ac.xs > ac.xsc
mv ac.xsc ac.c
g++ -c -Wall -std=c++11 -DUSEIMPORTLIB -march=x86-64 -mtune=generic -O2 -pipe -DVERSION=\"0.04\" -DXS_VERSION=\"0.04\" "-I/usr/lib/perl5/core_perl/CORE" ac.c
In file included from ac.xs:11:
ppport.h:4594: warning: "WIDEST_UTYPE" redefined
4594 | # define WIDEST_UTYPE U64TYPE
|
In file included from /usr/lib/perl5/core_perl/CORE/perl.h:2753,
from ac.xs:5:
/usr/lib/perl5/core_perl/CORE/handy.h:1251: note: this is the location of the previous definition
1251 | # define WIDEST_UTYPE U64
|
In file included from /usr/lib/perl5/core_perl/CORE/perl.h:28,
from ac.xs:5:
/usr/lib/perl5/core_perl/CORE/config.h:1011:20: error: ‘sigjmp_buf’ does not name a type; did you mean ‘Sigjmp_buf’?
1011 | #define Sigjmp_buf sigjmp_buf
| ^~~~~~~~~~
/usr/lib/perl5/core_perl/CORE/cop.h:34:5: note: in expansion of macro ‘Sigjmp_buf’
34 | Sigjmp_buf je_buf; /* uninit if je_prev is NULL */
| ^~~~~~~~~~
make: *** [Makefile:341: ac.o] Error 1
What can be the problem here?
It seems like the C++ option -std=c++11 is confusing MSYS2. In Makefile.PL line #20, we have:
CCFLAGS => '-Wall -std=c++11',
if I remove -std=c++11 and save the file and recompile, it works fine:
$ make clean
$ perl Makefile.PL
$ make
cp lib/Algorithm/AhoCorasick/XS.pm blib/lib/Algorithm/AhoCorasick/XS.pm
Running Mkbootstrap for XS ()
chmod 644 "XS.bs"
"/usr/bin/perl.exe" -MExtUtils::Command::MM -e 'cp_nonempty' -- XS.bs blib/arch/auto/Algorithm/AhoCorasick/XS/XS.bs 644
g++ -c -Wall -DUSEIMPORTLIB -march=x86-64 -mtune=generic -O2 -pipe -DVERSION=\"0.04\" -DXS_VERSION=\"0.04\" "-I/usr/lib/perl5/core_perl/CORE" Matcher.cpp
"/usr/bin/perl.exe" "/usr/share/perl5/core_perl/ExtUtils/xsubpp" -C++ -typemap '/usr/share/perl5/core_perl/ExtUtils/typemap' -typemap '/home/hakon/perl/cpan-source/Algorithm-AhoCorasick-XS-0.04/perlobject.map' -typemap '/home/hakon/perl/cpan-source/Algorithm-AhoCorasick-XS-0.04/typemap' -typemap '/home/hakon/perl/cpan-source/Algorithm-AhoCorasick-XS-0.04/typemap' ac.xs > ac.xsc
mv ac.xsc ac.c
g++ -c -Wall -DUSEIMPORTLIB -march=x86-64 -mtune=generic -O2 -pipe -DVERSION=\"0.04\" -DXS_VERSION=\"0.04\" "-I/usr/lib/perl5/core_perl/CORE" ac.c
In file included from ac.xs:11:
ppport.h:4594: warning: "WIDEST_UTYPE" redefined
4594 | # define WIDEST_UTYPE U64TYPE
|
In file included from /usr/lib/perl5/core_perl/CORE/perl.h:2753,
from ac.xs:5:
/usr/lib/perl5/core_perl/CORE/handy.h:1251: note: this is the location of the previous definition
1251 | # define WIDEST_UTYPE U64
|
g++ -c -Wall -DUSEIMPORTLIB -march=x86-64 -mtune=generic -O2 -pipe -DVERSION=\"0.04\" -DXS_VERSION=\"0.04\" "-I/usr/lib/perl5/core_perl/CORE" test.c
rm -f blib/arch/auto/Algorithm/AhoCorasick/XS/XS.dll
g++ --shared -Wl,--enable-auto-import -Wl,--export-all-symbols -Wl,--enable-auto-image-base -fstack-protector-strong Matcher.o ac.o test.o -o blib/arch/auto/Algorithm/AhoCorasick/XS/XS.dll \
/usr/lib/perl5/core_perl/CORE/msys-perl5_32.dll \
chmod 755 blib/arch/auto/Algorithm/AhoCorasick/XS/XS.dll
Manifying 1 pod document
$ make test
"/usr/bin/perl.exe" -MExtUtils::Command::MM -e 'cp_nonempty' -- XS.bs blib/arch/auto/Algorithm/AhoCorasick/XS/XS.bs 644
PERL_DL_NONLAZY=1 "/usr/bin/perl.exe" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/basic.t ....... ok
t/details.t ..... ok
t/edge_cases.t .. ok
t/utf8.t ........ ok
t/variation.t ... ok
All tests successful.
Files=5, Tests=1624, 2 wallclock secs ( 0.14 usr 0.06 sys + 0.64 cusr 0.85 csys = 1.69 CPU)
Result: PASS
See also this question.

How to add a library (header + .c) compilation in MakeFile (Eclipse) ?

I'm working on a project, coding in C++, to develop a communication Modbus over TCP/IP between a Raspberry pi and an Arduino.
I have a basic exemple of "hello world" which works in Raspberry. I want to add the libmodbus library (.h and .c files) in my Eclipse Project, and test a server-unit-test provided. I have already added the directory in "Path and Symbol" (GNU C and GNU C++) and the "included ".
In the MakeFile, I have added the directory of the libmodbus file section (#Include paths). When I build the project, only the .h files are compiled, no the .c file. The "modbus.h" is recognized, but they are errors like "undefined reference to ....(modbus fonctions).
I have tested many solutions but it doesn't work yet.
Thanks in advance.
################################################################################
# MAKEFILE : RPi2Test01
################################################################################
#===============================================================================
# User compiling options
#===============================================================================
#HOST: PC, PCLINUX, ARM
HOST := PC
#HOST := PCLINUX
#HOST :: ARM
#TARGET: PC, ARM, RASPBERRYPI
#TARGET := PC
#TARGET := ARM
TARGET := RASPBERRYPI
#DEBUG: YES, NO
DEBUG := NO
#===============================================================================
# Compiling options
#===============================================================================
#-------------------------------------------------------------------------------
# Determine compiling environment #ENVIRONMENT: CYGWIN,LINUX,WCROSS,LCROSS,ARM
#-------------------------------------------------------------------------------
ifeq ($(HOST),PC)
ifeq ($(TARGET),PC)
ENVIRONMENT := CYGWIN
else
ENVIRONMENT := WCROSS
endif
else
ifeq ($(HOST),LINUXPC)
ifeq ($(TARGET),PC)
ENVIRONMENT := LINUX
else
ENVIRONMENT := LCROSS
endif
else
ifeq ($(HOST),ARM)
ENVIRONMENT := ARM
endif
endif
endif
#-------------------------------------------------------------------------------
# Customize: WIN32 (CYGWIN)
#-------------------------------------------------------------------------------
ifeq ($(ENVIRONMENT),CYGWIN)
PREFIX :=
BINPREFIX :=
CFLAGS := -std=gnu99 -Wno-write-strings
CFLAGS += -D_WIN32_ -D__CYGWIN__ -D_$(TARGET)_
CPPFLAGS := -pipe -g2 -Wall -Wno-write-strings -Wno-reorder
CPPFLAGS += -D_WIN32_ -D__CYGWIN__ -D_$(TARGET)_
LDFLAGS := -enable-auto-import
LIBEXT := .a
BINEXT := .exe
endif
#-------------------------------------------------------------------------------
# Customize: LINUX (LINUX)
#-------------------------------------------------------------------------------
ifeq ($(ENVIRONMENT),LINUX)
PREFIX :=
BINPREFIX :=
CFLAGS := -std=gnu99 -Wno-write-strings
CFLAGS += -D_LINUX_ -D_$(TARGET)_
CPPFLAGS := -Wno-write-strings -Wno-reorder
CPPFLAGS += -D_LINUX_ -D_$(TARGET)_
LDFLAGS := -g
LIBEXT := .a
BINEXT := .out
endif
#-------------------------------------------------------------------------------
# Customize: Cross-compiling CYGWIN to ARM-LINUX-LINARO (WCROSS)
#-------------------------------------------------------------------------------
ifeq ($(ENVIRONMENT),WCROSS)
PREFIX := arm-linux-gnueabihf-
BINPREFIX := /cygdrive/c/Linaro/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09/bin/
CFLAGS := -std=gnu99 -Wno-write-strings
CFLAGS += -D_LINUX_ -D_$(TARGET)_
CPPFLAGS := -Wno-write-strings -Wno-reorder
CPPFLAGS += -D_LINUX_ -D_$(TARGET)_
LDFLAGS := -g
LIBEXT := .a
BINEXT := .out
endif
#-------------------------------------------------------------------------------
# Customize: Cross-compiling LINUX to ARM-LINUX-LINARO (LCROSS)
#-------------------------------------------------------------------------------
ifeq ($(ENVIRONMENT),LCROSS)
PREFIX := arm-linux-gnueabihf-
BINPREFIX := /usr/local/Linaro/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09/bin/
CFLAGS := -std=gnu99 -Wno-write-strings
CFLAGS += -D_LINUX_ -D_$(TARGET)_
CPPFLAGS := -Wno-write-strings -Wno-reorder
CPPFLAGS += -D_LINUX_ -D_$(TARGET)_
LDFLAGS := -g
LIBEXT := .a
BINEXT := .out
endif
#-------------------------------------------------------------------------------
# Customize: ARM-LINUX-LINARO (ARM)
#-------------------------------------------------------------------------------
ifeq ($(ENVIRONMENT),ARM)
PREFIX :=
BINPREFIX :=
CFLAGS := -std=gnu99 -Wno-write-strings
CFLAGS += -D_LINUX_ -D_$(TARGET)_
CPPFLAGS := -Wno-write-strings -Wno-reorder
CPPFLAGS += -D_LINUX_ -D_$(TARGET)_
LDFLAGS := -g
LIBEXT := .a
BINEXT := .out
endif
#-------------------------------------------------------------------------------
# Compiling and linking features - Paths and libraries
#-------------------------------------------------------------------------------
CINC_PATH := $(INCLUDE)
CLIB_PATH := $(CLIB_PATH)
ifeq ($(ENVIRONMENT),ARM)
CINC_PATH += -I/usr/local/include
CLIB_PATH += -L/usr/local/lib
endif
ifeq ($(DEBUG),YES)
LIBSUBFIX := d
CPPFLAGS += -D_DEBUG_
else
LIBSUBFIX :=
CPPFLAGS +=
endif
LDADDLIBS += -lpthread -lrt -lm -lstdc++
#===============================================================================
# Building tools
#===============================================================================
CC := #$(BINPREFIX)$(PREFIX)gcc
CXX := #$(BINPREFIX)$(PREFIX)g++
LD := #$(BINPREFIX)$(PREFIX)ld
AR := #$(BINPREFIX)$(PREFIX)ar
MD := #mkdir -p
RM := #rm -rf
ECHO := #echo
#===============================================================================
# File pathts
#===============================================================================
SRCDIR := .
OBJPATH := ./OBJ
LIBPATH := ./LIB
GENPATH := ./BIN
#===============================================================================
# Source files
#===============================================================================
MAIN_HOME := $(SRCDIR)
CPP_SRCS_MAIN := $(MAIN_HOME)/RPi2Test01.cpp
#===============================================================================
# Object files
#===============================================================================
OBJS_MAIN := $(patsubst $(MAIN_HOME)/%.cpp, \
$(OBJPATH)/%.cpp.o, \
$(CPP_SRCS_MAIN))
#LIB_SRC := C:/libmodbus-3.0.6/src/%.c
#LIBSMAIN := $(patsubst C:/libmodbus-3.0.6/src/%.c, \
$(LIBPATH)/%.c.o, \
$(LIB_SRC))
#===============================================================================
# Building options
#===============================================================================
# Include paths
CINC_PATH += -I C:/libmodbus-3.0.6/src
CLIB_PATH += -L C:/libmodbus-3.0.6/src
CLIB_PATH += -L$(LIBPATH)
# Compiling and Linking options
CFLAGS := $(CINC_PATH) $(CFLAGS)
CPPFLAGS := $(CINC_PATH) $(CPPFLAGS)
LDFLAGS := $(CLIB_PATH) $(LDFLAGS)
#===============================================================================
# Building targets
#===============================================================================
BINMAIN := $(GENPATH)/RPi2Test01$(BINEXT)
#-------------------------------------------------------------------------------
# All targets
#-------------------------------------------------------------------------------
.PHONY: all
all: dirs $(BINMAIN)
#-------------------------------------------------------------------------------
# Building directories
#-------------------------------------------------------------------------------
dirs:
$(MD) $(OBJPATH)
$(MD) $(LIBPATH)
$(MD) $(GENPATH)
#-------------------------------------------------------------------------------
# Targets
#-------------------------------------------------------------------------------
$(BINMAIN): $(OBJS_MAIN) $(LIBSMAIN)
$(ECHO) 'Building target: $#'
$(CC) $(OBJS_MAIN) -o$# $(LDFLAGS) $(LDADDLIBS)
#-------------------------------------------------------------------------------
# Compiling
#-------------------------------------------------------------------------------
# File compiling: Main Programs ------------------------------------------------
$(OBJPATH)/%.cpp.o: $(MAIN_HOME)/%.cpp
$(ECHO) 'Building file: $<'
$(CXX) -c $(CPPFLAGS) -o$# $<
#===============================================================================
# Clean
#===============================================================================
.PHONY: clean
clean:
$(ECHO) 'Removing...'
$(RM) ${OBJPATH}/*.o ${OBJPATH}/*.err ${OBJPATH}/*.map
$(RM) ${GENPATH}/*.o ${GENPATH}/*.out ${GENPATH}/*.exe ${GENPATH}/*.tmp
$(RM) ${SRCDIR}/*.a ${OBJPATH}/*.a ${LIBPATH}/*.a ${GENPATH}/*.a
$(RM) ${SRCDIR}/*.so ${OBJPATH}/*.so ${LIBPATH}/*.so ${GENPATH}/*.so
$(RM) ${SRCDIR}/*.out.stackdump ${SRCDIR}/*.exe.stackdump
$(RM) ${GENPATH}/*.out.stackdump ${GENPATH}/*.exe.stackdump
$(RM) ${OBJPATH} ${LIBPATH} ${GENPATH}
$(RM) ./*.o ./*.out ./*.exe ./*.a ./*.so ./*.err ./*.map
$(RM) ./*.out.stackdump ./*.exe.stackdump
$(ECHO) 'Files removed'
You probably need to add -lmodbus to your LDADDLIBS variable:
LDADDLIBS += -lmodbus -lpthread -lrt -lm -lstdc++

I can't get "math.h" to work with eclipse kepler using "gcc arm"

I used this tutorial to setup all of my software: http://www.angstromsandalgorithms.com/free-eclipse-arm-gcc-openocd-toolchain-for-windows-part-3-eclipse-ide/
I'm using an STM32F405RGT6 arm. I'm also on windows. I have tried adding -lm everywhere in the makefile and havn't had anything work. Basically I just want to be able to #include "math.h" so I can use the math functions...I'm also assuming placing -lm in the right place is all I need to do from all the google searches I've done...I'm also thinking my makefile might be not be linking things correctly and/or i might not have things linked properly in eclipse.
Here is my makefile:
# Makefile for compiling the Getting Started project
#-------------------------------------------------------------------------------
# User-modifiable options
#-------------------------------------------------------------------------------
# Trace level used for compilation
# (can be overriden by adding TRACE_LEVEL=#number to the command-line)
# TRACE_LEVEL_DEBUG 5
# TRACE_LEVEL_INFO 4
# TRACE_LEVEL_WARNING 3
# TRACE_LEVEL_ERROR 2
# TRACE_LEVEL_FATAL 1
# TRACE_LEVEL_NO_TRACE 0
TRACE_LEVEL = 4
# Optimization level
OPTIMIZATION = -O0
# Output file basename
OUTPUT = main
# Output directories
BIN = .
OBJ = obj
# library dirs
LIBRARYSRC = ./lib/src
STARTUPFILE = ./lib/startup_stm32f4xx.s
#-------------------------------------------------------------------------------
# Tools
#-------------------------------------------------------------------------------
# Tool suffix when cross-compiling
CROSS_COMPILE = arm-none-eabi-
CC = $(CROSS_COMPILE)gcc
SIZE = $(CROSS_COMPILE)size
STRIP = $(CROSS_COMPILE)strip
OBJCOPY = $(CROSS_COMPILE)objcopy
OBJDUMP = $(CROSS_COMPILE)objdump
LD = $(CROSS_COMPILE)ld
AS = $(CROSS_COMPILE)as
#-------------------------------------------------------------------------------
# Files
#-------------------------------------------------------------------------------
# include folders
INCLUDES = -I./
INCLUDES += -I./lib/
INCLUDES += -I./lib/inc/
INCLUDES += -I./lib/inc/../../
# Objects built from C source files
C_OBJECTS = $(OBJ)/main.o
C_OBJECTS += $(OBJ)/system_stm32f4xx.o
C_OBJECTS += $(OBJ)/stm32f4xx_gpio.o
C_OBJECTS += $(OBJ)/stm32f4xx_rcc.o
C_OBJECTS += $(OBJ)/stm32f4xx_it.o
# Objects built from Assembly source files
ASM_OBJECTS = $(OBJ)/startup_stm32f4xx.o
LINKER_SCRIPT = ./lib/stm32f4xx_flash.ld
#LINKER_SCRIPT = ./lib/stm32f4xx_flash_extsram.ld
# Append OBJ and BIN directories to output filename
OUTPUT := $(BIN)/$(OUTPUT)
#-------------------------------------------------------------------------------
# Rules
#-------------------------------------------------------------------------------
# Flags
CFLAGS = -Wall -fno-common -c -g -mcpu=cortex-m3 -mthumb
CFLAGS += -g $(OPTIMIZATION) $(INCLUDES) -DTRACE_LEVEL=$(TRACE_LEVEL)
ASFLAGS = -g -mapcs-32
LDFLAGS = -g -v -nostartfiles
OBJCOPYFLAGS = -O binary
OBJDUMPFLAGS = -x --syms -S
all: $(BIN) $(OBJ) $(OUTPUT).out
$(BIN) $(OBJ):
mkdir $#
$(OUTPUT).out: $(C_OBJECTS) $(ASM_OBJECTS) $(LINKER_SCRIPT)
# echo "..linking"
$(LD) $(LDFLAGS) -Map $(OUTPUT).map -T$(LINKER_SCRIPT) -o $(OUTPUT).out $(C_OBJECTS) $(ASM_OBJECTS) libgcc.a
$(OBJCOPY) $(OBJCOPYFLAGS) $(OUTPUT).out $(OUTPUT).bin
# $(OBJDUMP) $(OBJDUMPFLAGS) $(OUTPUT).out > $(OUTPUT).lss
# echo "...completed."
$(C_OBJECTS): main.c system_stm32f4xx.c
# echo ".compiling"
$(CC) $(CFLAGS) -o $(OBJ)/main.o main.c
$(CC) $(CFLAGS) -o $(OBJ)/system_stm32f4xx.o system_stm32f4xx.c
$(CC) $(CFLAGS) -o $(OBJ)/stm32f4xx_it.o stm32f4xx_it.c
# echo ".compiling libraries"
$(CC) $(CFLAGS) -o $(OBJ)/stm32f4xx_gpio.o $(LIBRARYSRC)/stm32f4xx_gpio.c
$(CC) $(CFLAGS) -o $(OBJ)/stm32f4xx_rcc.o $(LIBRARYSRC)/stm32f4xx_rcc.c
$(ASM_OBJECTS): $(STARTUPFILE)
# echo ".assembling"
$(AS) $(ASFLAGS) -o $(OBJ)/startup_stm32f4xx.o $(STARTUPFILE)
clean:
-rm -f $(OBJ)/*.o $(BIN)/*.out $(BIN)/*.bin $(BIN)/*.dmp $(BIN)/*.map $(BIN)/*.lss

CMake output in Eclipse CDT console

Making project through command line behaves as expected and provides neat and colored output:
However, when invoking make through Eclipse - I get the following garbage:
**** Build of configuration Debug for project New2 ****
make -C debug -j all
make: Entering directory `/d/Users/Haroogan/Development/Eclipse CDT/Workspace/New2/debug'
/D/Software/CMake/bin/cmake.exe -H"/D/Users/Haroogan/Development/Eclipse CDT/Workspace/New2" -B"/D/Users/Haroogan/Development/Eclipse CDT/Workspace/New2/debug" --check-build-system CMakeFiles/Makefile.cmake 0
/D/Software/CMake/bin/cmake.exe -E cmake_progress_start "/D/Users/Haroogan/Development/Eclipse CDT/Workspace/New2/debug/CMakeFiles" "/D/Users/Haroogan/Development/Eclipse CDT/Workspace/New2/debug/CMakeFiles/progress.marks"
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/d/Users/Haroogan/Development/Eclipse CDT/Workspace/New2/debug'
make -f CMakeFiles/go.dir/build.make CMakeFiles/go.dir/depend
make[2]: Entering directory `/d/Users/Haroogan/Development/Eclipse CDT/Workspace/New2/debug'
/D/Software/CMake/bin/cmake.exe -E cmake_progress_report "/D/Users/Haroogan/Development/Eclipse CDT/Workspace/New2/debug/CMakeFiles" 8
[ 12%] [34m[1mGenerating moc_GLWidget.cxx
[0m/D/Software/Qt/4.8.0/bin/moc.exe #moc_GLWidget.cxx_parameters
/D/Software/CMake/bin/cmake.exe -E cmake_depends "MSYS Makefiles" "/D/Users/Haroogan/Development/Eclipse CDT/Workspace/New2" "/D/Users/Haroogan/Development/Eclipse CDT/Workspace/New2" "/D/Users/Haroogan/Development/Eclipse CDT/Workspace/New2/debug" "/D/Users/Haroogan/Development/Eclipse CDT/Workspace/New2/debug" "/D/Users/Haroogan/Development/Eclipse CDT/Workspace/New2/debug/CMakeFiles/go.dir/DependInfo.cmake" --color=
make[2]: Leaving directory `/d/Users/Haroogan/Development/Eclipse CDT/Workspace/New2/debug'
make -f CMakeFiles/go.dir/build.make CMakeFiles/go.dir/build
make[2]: Entering directory `/d/Users/Haroogan/Development/Eclipse CDT/Workspace/New2/debug'
/D/Software/CMake/bin/cmake.exe -E cmake_progress_report "/D/Users/Haroogan/Development/Eclipse CDT/Workspace/New2/debug/CMakeFiles" 1
/D/Software/CMake/bin/cmake.exe -E cmake_progress_report "/D/Users/Haroogan/Development/Eclipse CDT/Workspace/New2/debug/CMakeFiles" 2
/D/Software/CMake/bin/cmake.exe -E cmake_progress_report "/D/Users/Haroogan/Development/Eclipse CDT/Workspace/New2/debug/CMakeFiles" 3
/D/Software/CMake/bin/cmake.exe -E cmake_progress_report "/D/Users/Haroogan/Development/Eclipse CDT/Workspace/New2/debug/CMakeFiles" 4
/D/Software/CMake/bin/cmake.exe -E cmake_progress_report "/D/Users/Haroogan/Development/Eclipse CDT/Workspace/New2/debug/CMakeFiles" 5
/D/Software/CMake/bin/cmake.exe -E cmake_progress_report "/D/Users/Haroogan/Development/Eclipse CDT/Workspace/New2/debug/CMakeFiles" 6
/D/Software/CMake/bin/cmake.exe -E cmake_progress_report "/D/Users/Haroogan/Development/Eclipse CDT/Workspace/New2/debug/CMakeFiles" 7
[ 25%] [ 37%] [ 50%] [ 62%] [ 75%] [ 87%] [100%] [32mBuilding CXX object CMakeFiles/go.dir/Perfomance.cpp.obj
[0m[32mBuilding CXX object CMakeFiles/go.dir/Camera.cpp.obj
[0m/D/Software/MinGW/bin/g++.exe -DQT_DLL -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_DLL -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_DEBUG -fmessage-length=0 -mfpmath=sse -msse2 -msse3 -mssse3 -msse4 -fopenmp -g #CMakeFiles/go.dir/includes_CXX.rsp -o CMakeFiles/go.dir/Perfomance.cpp.obj -c "/D/Users/Haroogan/Development/Eclipse CDT/Workspace/New2/Perfomance.cpp"
[32mBuilding CXX object CMakeFiles/go.dir/main.cpp.obj
[0m[32mBuilding CXX object CMakeFiles/go.dir/moc_GLWidget.cxx.obj
[0m[32mBuilding CXX object CMakeFiles/go.dir/Milliseconds.cpp.obj
[0m[32mBuilding CXX object CMakeFiles/go.dir/Keyboard.cpp.obj
[0m[32mBuilding CXX object CMakeFiles/go.dir/Seconds.cpp.obj
[0m/D/Software/MinGW/bin/g++.exe -DQT_DLL -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_DLL -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_DEBUG -fmessage-length=0 -mfpmath=sse -msse2 -msse3 -mssse3 -msse4 -fopenmp -g #CMakeFiles/go.dir/includes_CXX.rsp -o CMakeFiles/go.dir/Camera.cpp.obj -c "/D/Users/Haroogan/Development/Eclipse CDT/Workspace/New2/Camera.cpp"
/D/Software/MinGW/bin/g++.exe -DQT_DLL -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_DLL -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_DEBUG -fmessage-length=0 -mfpmath=sse -msse2 -msse3 -mssse3 -msse4 -fopenmp -g #CMakeFiles/go.dir/includes_CXX.rsp -o CMakeFiles/go.dir/moc_GLWidget.cxx.obj -c "/D/Users/Haroogan/Development/Eclipse CDT/Workspace/New2/debug/moc_GLWidget.cxx"
/D/Software/MinGW/bin/g++.exe -DQT_DLL -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_DLL -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_DEBUG -fmessage-length=0 -mfpmath=sse -msse2 -msse3 -mssse3 -msse4 -fopenmp -g #CMakeFiles/go.dir/includes_CXX.rsp -o CMakeFiles/go.dir/Keyboard.cpp.obj -c "/D/Users/Haroogan/Development/Eclipse CDT/Workspace/New2/Keyboard.cpp"
/D/Software/MinGW/bin/g++.exe -DQT_DLL -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_DLL -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_DEBUG -fmessage-length=0 -mfpmath=sse -msse2 -msse3 -mssse3 -msse4 -fopenmp -g #CMakeFiles/go.dir/includes_CXX.rsp -o CMakeFiles/go.dir/main.cpp.obj -c "/D/Users/Haroogan/Development/Eclipse CDT/Workspace/New2/main.cpp"
/D/Software/MinGW/bin/g++.exe -DQT_DLL -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_DLL -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_DEBUG -fmessage-length=0 -mfpmath=sse -msse2 -msse3 -mssse3 -msse4 -fopenmp -g #CMakeFiles/go.dir/includes_CXX.rsp -o CMakeFiles/go.dir/Seconds.cpp.obj -c "/D/Users/Haroogan/Development/Eclipse CDT/Workspace/New2/Seconds.cpp"
/D/Software/MinGW/bin/g++.exe -DQT_DLL -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_DLL -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_DEBUG -fmessage-length=0 -mfpmath=sse -msse2 -msse3 -mssse3 -msse4 -fopenmp -g #CMakeFiles/go.dir/includes_CXX.rsp -o CMakeFiles/go.dir/Milliseconds.cpp.obj -c "/D/Users/Haroogan/Development/Eclipse CDT/Workspace/New2/Milliseconds.cpp"
[31m[1mLinking CXX executable go.exe
[0m/D/Software/CMake/bin/cmake.exe -E remove -f CMakeFiles/go.dir/objects.a
/D/Software/MinGW/bin/ar.exe cr CMakeFiles/go.dir/objects.a #CMakeFiles/go.dir/objects1.rsp
/D/Software/MinGW/bin/g++.exe -fmessage-length=0 -mfpmath=sse -msse2 -msse3 -mssse3 -msse4 -fopenmp -g -Wl,--whole-archive CMakeFiles/go.dir/objects.a -Wl,--no-whole-archive -o go.exe -Wl,--out-implib,libgo.dll.a -Wl,--major-image-version,0,--minor-image-version,0 /D/Software/Qt/4.8.0/lib/libQtOpenGLd4.a /D/Software/Qt/4.8.0/lib/libQtGuid4.a /D/Software/Qt/4.8.0/lib/libQtCored4.a -lglu32 -lopengl32 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32
make[2]: Leaving directory `/d/Users/Haroogan/Development/Eclipse CDT/Workspace/New2/debug'
/D/Software/CMake/bin/cmake.exe -E cmake_progress_report "/D/Users/Haroogan/Development/Eclipse CDT/Workspace/New2/debug/CMakeFiles" 1 2 3 4 5 6 7 8
[100%] Built target go
make[1]: Leaving directory `/d/Users/Haroogan/Development/Eclipse CDT/Workspace/New2/debug'
/D/Software/CMake/bin/cmake.exe -E cmake_progress_start "/D/Users/Haroogan/Development/Eclipse CDT/Workspace/New2/debug/CMakeFiles" 0
make: Leaving directory `/d/Users/Haroogan/Development/Eclipse CDT/Workspace/New2/debug'
**** Build Finished ****
There is no coloring, but that's understandable. However, the output structure is completely messed up and appears to be grouped in a wrong way. Furthermore, this "[0m[32" garbage is the most annoying feature :)
Any suggestions?
Try to configure/generate your project with -DCMAKE_COLOR_MAKEFILE=OFF.