skipping incompatible when searching for -lgpstk - c

I am trying "make" command on my linux to create an exe file, but I keep getting an error
/usr/bin/ld: skipping incompatible ../../../shared/gpstk/src/libgpstk.a when searching for -lgpstk
/usr/bin/ld: cannot find -lgpstk
collect2: error: ld returned 1 exit status
../../../shared/makehome/common.makefile:79: recipe for target '../../../shared/binflate/src/binflate' failed
I have tried to download libraries through search online but I can't seem to get past this error. Can someone please help me out.
Here is the makefile code:
TARGET = linux
#----------------------------------------------------------------- Directories
# Where make will put outputs and intermediate files
SVNROOTDIR = ../../..
OBJDIR = $(SVNROOTDIR)/obj
BINDIR = $(SVNROOTDIR)/shared/binflate/src
LIBDIR = $(BINDIR)
#--------------------------------------------------------------------- Outputs
# What we are trying to build:
# Note: If you want this makefile to build an EXECUTABLE, leave LIBRARY
# undefined, and vice versa if you want to build a static LIBRARY
EXECUTABLE = $(BINDIR)/binflate
LIBRARY =
#--------------------------------------------------------------------- Sources
SOURCES = $(SVNROOTDIR)/shared/core/src/basetime.cpp \
$(SVNROOTDIR)/shared/core/src/parameters.cpp \
$(SVNROOTDIR)/shared/core/src/report.cpp \
$(SVNROOTDIR)/shared/core/src/datalog.cpp \
$(SVNROOTDIR)/shared/core/src/util.cpp \
$(SVNROOTDIR)/shared/core/src/serialutil.cpp \
$(SVNROOTDIR)/shared/core/src/signaltype.cpp \
$(SVNROOTDIR)/shared/core/src/channeltype.cpp \
$(SVNROOTDIR)/shared/core/src/gridframework.cpp \
$(SVNROOTDIR)/shared/core/src/binhelper.cpp \
$(SVNROOTDIR)/shared/core/src/observables.cpp \
$(SVNROOTDIR)/shared/core/src/txid.cpp \
$(SVNROOTDIR)/shared/core/src/ReportWrapper.cpp \
$(SVNROOTDIR)/shared/binflate/src/binflate.cpp
# include directories in gcc format
INCL = -I../include \
-I$(SVNROOTDIR)/shared/core/include \
-I$(SVNROOTDIR)/shared/gpstk/include
# Libraries
LIBS = -lm -lgpstk
# Library include directories in gcc format (-Lpath/to/dir1 -Lpath/to/dir2)
INCLLIB = -L$(SVNROOTDIR)/shared/gpstk/src \
-L/usr/local/lib
# Predefine macros
PREDEFINES =
#------------------------------------ Compilers, linkers, etc. and their flags
CC = g++
CCFLAGS = -g -Wall -Wno-unknown-pragmas \
-Wno-uninitialized $(PREDEFINES)
CCINCL = $(INCL)
LIBEXE = ar
LIBFLAGS = rcs
LIBINCL =
LNKEXE = g++
LNKFLAGS =
LNKINCL =
MD = g++
MDFLAGS = -MM
MDINCL = $(INCL)
#---------------------------------------------------------- Included Makefiles
include $(SVNROOTDIR)/shared/makehome/common.makefile

Related

How can I modify my makefile to allow me to include<pthread.h>?

I am modifying an example btstack program in C. Btstack includes a makefile for porting to the raspberry pi. I need to have a timer running in the background while other things are running so I am attempting to tinker with pthreads. I've installed the library with "sudo apt-get ...." and included it in my .c file. When I attempt to compile, I get the following error (although unlike other errors it is in grey text and not red):
/usr/bin/ld: le_data_channel_server.o: undefined reference to symbol 'pthread_create##GLIBC_2.4'
/usr/bin/ld: //lib/arm-linux-gnueabihf/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [../../example/Makefile.inc:502: le_data_channel_server] Error 1
Here are the contents of the makefile as is:
# Makefile for Raspberry Pi
BTSTACK_ROOT ?= ../..
CORE += \
btstack_chipset_bcm.c \
btstack_chipset_bcm_download_firmware.c \
btstack_control_raspi.c \
btstack_link_key_db_tlv.c \
btstack_run_loop_posix.c \
btstack_tlv_posix.c \
btstack_uart_posix.c \
btstack_slip.c \
hci_dump_posix_fs.c \
hci_transport_h4.c \
hci_transport_h5.c \
le_device_db_tlv.c \
main.c \
wav_util.c \
btstack_stdin_posix.c \
raspi_get_model.c \
rijndael.c
# examples
include ${BTSTACK_ROOT}/example/Makefile.inc
# use (cross)compiler for Raspi
CC = arm-linux-gnueabihf-gcc
CFLAGS += -g -Wall -Werror \
-I$(BTSTACK_ROOT)/platform/embedded \
-I$(BTSTACK_ROOT)/platform/posix \
-I$(BTSTACK_ROOT)/chipset/bcm \
-I${BTSTACK_ROOT}/3rd-party/tinydir \
-I${BTSTACK_ROOT}/3rd-party/rijndael
# add 'real time' lib for clock_gettime
LDFLAGS += -lrt
VPATH += ${BTSTACK_ROOT}/3rd-party/rijndael
VPATH += ${BTSTACK_ROOT}/platform/posix
VPATH += ${BTSTACK_ROOT}/platform/embedded
VPATH += ${BTSTACK_ROOT}/chipset/bcm
EXAMPLES = ${EXAMPLES_GENERAL} ${EXAMPLES_CLASSIC_ONLY} ${EXAMPLES_LE_ONLY} ${EXAMPLES_DUAL_MODE}
EXAMPLES += pan_lwip_http_server
# use pkg-config for portaudio
# CFLAGS += $(shell pkg-config portaudio-2.0 --cflags) -DHAVE_PORTAUDIO
# LDFLAGS += $(shell pkg-config portaudio-2.0 --libs)
# hard coded flags for portaudio in /usr/local/lib
# CFLAGS += -I/usr/local/include -DHAVE_PORTAUDIO
# LDFLAGS += -L/sw/lib -lportaudio -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,Carbon
all: ${EXAMPLES}
Basically, what should I modify/add in the makefile that would allow me to compile the program in the rpi command line with a "make" command?
Edit: MFisherKDX's solution worked. I added
LDFLAGS += -lpthread to the makefile.

fatal error: json-c/json.h: No such file or directory Cross compiling on ubuntu x64 for raspberry pi arm

I am trying to compile my code on my Ubuntu x64 laptop for the Raspberry Pi.
I am able to compile and run the code on Ubuntu laptop without any issue. However when I try to compile it for Raspberry Pi I get the following error:
$make
/home/nmohan/Development/arm-bcm2708-linux-gnueabi/bin/arm-bcm2708-linux-gnueabi-gcc -g -Wall -Wextra -I /home/nmohan/github/NiRobot/inc -fPIC -shared -L/home/nmohan/github/NiRobot/Obj_arm -Wl,-rpath=/home/nmohan/github/NiRobot/Obj -o /home/nmohan/github/NiRobot/Obj_arm/libRSXA.so /home/nmohan/github/NiRobot/lib/RSXA.c -lNMT_stdlib -lNMT_log -ljson-c -lc -Ljson-c
/home/nmohan/github/NiRobot/lib/RSXA.c:11:25: fatal error: json-c/json.h: No such file or directory
compilation terminated.
Makefile:101: recipe for target '/home/nmohan/github/NiRobot/Obj_arm/libRSXA.so' failed
make: *** [/home/nmohan/github/NiRobot/Obj_arm/libRSXA.so] Error 1
#---------------------------------------#
# #
# Global Varibles #
# #
#---------------------------------------#
PROJ_DIR = /home/nmohan/github/NiRobot
BIN_DIR = $(PROJ_DIR)/bin
OBJ_DIR = $(PROJ_DIR)/Obj
OBJ_DIR_ARM = $(PROJ_DIR)/Obj_arm
INC_DIR = $(PROJ_DIR)/inc
LIB_DIR = $(PROJ_DIR)/lib
OUT_DIR = $(PROJ_DIR)/bld
OUT_DIR_ARM = $(PROJ_DIR)/bld_arm
CFLAGS = -g -Wall -Wextra -I $(INC_DIR)
SFLAGS = -fPIC -shared
RPATH = -L$(OBJ_DIR) -Wl,-rpath=$(OBJ_DIR)
RPATH_ARM = -L$(OBJ_DIR_ARM) -Wl,-rpath=$(OBJ_DIR)
GCC_DIR = /home/nmohan/Development/arm-bcm2708-linux-gnueabi/bin/arm-bcm2708-linux-gnueabi-gcc
#---------------------------------------#
# #
# Targets #
# #
#---------------------------------------#
OBJS = NMT_stdlib.so \
NMT_log.so \
RSXA.so \
PCA9685.so \
MTDR.so \
CAM_MOTOR_CTRL.so \
HCxSR04.so
#---------------------------------------#
# #
# Dependancies #
# #
#---------------------------------------#
NMT_STDLIB_LIBS = -lc
NMT_LOG_LIBS = -lc \
-lNMT_stdlib \
RSXA_LIBS = -lNMT_stdlib \
-lNMT_log \
-ljson-c \
-lc
PCA9685_LIBS = -lNMT_stdlib \
-lNMT_log \
-lc \
-lwiringPi \
-lcrypt \
-lm \
-lrt \
-lRSXA
MTDR_LIBS = -lNMT_stdlib \
-lNMT_log \
-lwiringPi \
-lPCA9685 \
-lcrypt \
-lm \
-lrt \
-lRSXA
CAM_MOTOR_CTRL_LIBS = -lNMT_stdlib \
-lNMT_log \
-lwiringPi \
-lMTDR \
-lPCA9685 \
-lcrypt \
-lm \
-lrt \
-lRSXA
HCxSR04_LIBS = -lNMT_log \
-lNMT_stdlib \
-lRSXA \
-lwiringPi \
-lcrypt \
-lm \
-lrt
TARGET_OBJS := $(foreach OBJ,$(OBJS),$(OBJ_DIR)/lib$(OBJ))
TARGET_OBJS_ARM := $(foreach OBJ,$(OBJS),$(OBJ_DIR_ARM)/lib$(OBJ))
all: $(TARGET_OBJS) \
$(TARGET_OBJS_ARM)
.PHONY: all
$(OBJ_DIR)/lib%.so: $(LIB_DIR)/%.c $(INC_DIR)/%.h
gcc $(CFLAGS) $(SFLAGS) $(RPATH) -o $# $< $($(*)_LIBS)
$(OBJ_DIR_ARM)/lib%.so: $(LIB_DIR)/%.c $(INC_DIR)/%.h
$(GCC_DIR) $(CFLAGS) $(SFLAGS) $(RPATH_ARM) -o $# $< $($(*)_LIBS)
$(OBJ_DIR)/lib%.so: $(LIB_DIR)/%.cpp $(INC_DIR)/%.hpp
g++ $(CFLAGS) $(SFLAGS) $(RPATH) -o $# $< $($(*)_LIBS)
It depends on json-c/json.h. You need to include these files that were not found.
Installing libjson-c-dev package.
sudo apt install libjson-c-dev
I've had a similar problem. It's because of the json.h which is not part of the, in my case, gcc-arm-10-3-2017.07...-aarch64-none-linux-gnu.
I simply cloned json-c git and compiled it with the cross-compiler, too. Then you can reference to the output, or you can inlcude the whole git into your project and compile it all in one.

Makefile doesn't find the rule

I have to do a makefile to compile something, but I got a problem : when I type the make command, I got an error message saying that there is no rules for one of the targets. The problem is about the path to the target, using an environment var.
Here is the given start of the Makefile :
CC = mipsel-unknown-elf-gcc
AS = mipsel-unknown-elf-as
LD = mipsel-unknown-elf-ld
DU = mipsel-unknown-elf-objdump
SYS_OBJS = reset.o \
giet.o \
common.o \
ctx_handler.o \
drivers.o \
exc_handler.o \
irq_handler.o \
sys_handler.o
APP_OBJS = stdio.o main.o
GIET ?= /(my path)/giet
SYS_PATH = $(GIET)/sys
APP_PATH = $(GIET)/app
SYS_CFLAGS = -Wall -ffreestanding -mno-gpopt -mips32 -I$(SYS_PATH) -I.
APP_CFLAGS = -Wall -ffreestanding -mno-gpopt -mips32 -I$(APP_PATH) -I.
all: sys.bin app.bin
(I am supposed to finish it)
What I tried to do (rule for sys.bin works fine) :
common.o: common.c
mipsel-unknown-elf-gcc $(SYS_CFLAGS) common.o $(SYS_PATH)/common.c
The command I'm using to compile myself is : mipsel-unknown-elf-gcc -ffreestanding -mno-gpopt -mips32 -I$GIET/sys -I. -c -o common.o $GIET/sys/common.c
Could you help me to fix this ?
Thanks :)
I don't see a -o (output file specifier) at the end of $(SYS_CFLAGS) or before the common.o in the command for your rule. That's the important difference between your makefile and your manual command.
Without that specifier, it will try to act on common.o rather than produce it, attempting to combine both common.o and $(SYS_PATH)/common.c into (most likely) a.out.
To fix it, change the rule to:
common.o: common.c
mipsel-unknown-elf-gcc $(SYS_CFLAGS) -o common.o $(SYS_PATH)/common.c
# ^^
# Add this bit here (but not these two comment lines).

using powf function in rtems (undefined reference to powf)

I'm trying to use powf function in an rtems application.
When I call powf(a,b); inside Init() function, it compiles ok.
But when I call powf in some other function, the compiler gives me 'undefined reference to powf' message even though I have those #include <math.h> and #include <float.h>. I event tried merging the file, but it is the same.
#define CONFIGURE_...
#define CONFIGURE_...
#include <rtems/confdefs.h>
rtems_task Init( rtems_task_argument ignored)
{
powf(a,b); // ok
}
int my_other_func()
{
powf(c,d); // undefined reference error..
}
What can be the problem?
EDIT(ADD) : I added source code and makefile below. The compiled rtems OS package is specified by shell environment variable RTEMS_MAKEFILE_PATH.
Makefile :
include ../Makefile.base
_RAM_START = 0x60000000
XCFLAGS = -qnolinkcmds -T ../../lib/linkcmds.abts3 -D_RAM_START=$(_RAM_START)
XCFLAGS += -lm -DALDEBARAN_RTEMS
../Makefile.base :
#
# RTEMS_MAKEFILE_PATH is typically set in an environment variable
#
PGM=${ARCH}/faster_rcnn.exe
# optional managers required
MANAGERS=all
# C source names
VPATH = ../src
VPATH += ../../../../abfrcnn/bare-c/lrn_layer
CSRCS = init.c
CSRCS += lrn_layer.c
CSRCS1 = $(notdir $(CSRCS))
COBJS_ = $(CSRCS1:.c=.o)
include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
include $(RTEMS_CUSTOM)
include $(PROJECT_ROOT)/make/leaf.cfg
#XCFLAGS += -I../../include
COBJS = $(COBJS_:%=${ARCH}/%)
OBJS= $(COBJS) $(CXXOBJS) $(ASOBJS)
#all: ${ARCH} $(PGM) RUNTCL
all: ${ARCH} $(PGM)
$(PGM): $(OBJS)
$(make-exe)
RUNTCL:
echo 'system_init' > run.tcl
echo 'load_image o-optimize/faster_rcnn.exe' >> run.tcl
echo 'run $(_RAM_START)' >> run.tcl
clean:
-$(RM) -r $(ARCH)
../src/init.c :
...
#include <math.h>
rtems_status Init(rtems_argument ignored)
{
...
printf(" pow(1.1,2.2) = %f\n", powf(1.1,2.2)); // <== powf compiles liks ok
//zf_coco();
}
../../../../abfrcnn/bare-c/lrn_layer/lrn_layer.c
#include <stdio.h>
#include <math.h>
int lrn_layer(... args... )
{
...
val = 1./powf((1.+a/(float)(k^2)*tmp),b); // method1
...
} // main ROI loop
The result of make command :
test -d o-optimize || mkdir o-optimize
sparc-ab-rtems-gcc --pipe -B/home/ckim/prj/abts/rtems-qt/rtems-4.10.99-kernel/build-rtems/rtems-package/sparc-ab-rtems/aldebaran2/lib/ -specs bsp_specs -qrtems -Wall -qnolinkcmds -T ../../lib/linkcmds.abts3 -D_RAM_START=0x60000000 -lm -DALDEBARAN_RTEMS -O4 -mtune=v8 -msoft-float -fcommon -DTARGET_ALDEBARAN -c -o o-optimize/init.o ../src/init.c
../src/init.c:120:2: warning: missing braces around initializer [-Wmissing-braces]
{0}, // rtems_chain_control;
^
../src/init.c:120:2: warning: (near initialization for 'ald_sd_card_driver_table[0].queue.Chain') [-Wmissing-braces]
sparc-ab-rtems-gcc --pipe -B/home/ckim/prj/abts/rtems-qt/rtems-4.10.99-kernel/build-rtems/rtems-package/sparc-ab-rtems/aldebaran2/lib/ -specs bsp_specs -qrtems -Wall -qnolinkcmds -T ../../lib/linkcmds.abts3 -D_RAM_START=0x60000000 -lm -DALDEBARAN_RTEMS -O4 -mtune=v8 -msoft-float -fcommon -DTARGET_ALDEBARAN -c -o o-optimize/lrn_layer.o ../../../../abfrcnn/bare-c/lrn_layer/lrn_layer.c
../../../../abfrcnn/bare-c/lrn_layer/lrn_layer.c: In function 'lrn_layer':
../../../../abfrcnn/bare-c/lrn_layer/lrn_layer.c:201:12: warning: 'w_idx' may be used uninitialized in this function [-Wmaybe-uninitialized]
if (w_idx == w && h_idx == h) {
^
sparc-ab-rtems-gcc --pipe -B/home/ckim/prj/abts/rtems-qt/rtems-4.10.99-kernel/build-rtems/rtems-package/sparc-ab-rtems/aldebaran2/lib/ -specs bsp_specs -qrtems -Wall -qnolinkcmds -T ../../lib/linkcmds.abts3 -D_RAM_START=0x60000000 -lm -DALDEBARAN_RTEMS -O4 -mtune=v8 -msoft-float -fcommon -DTARGET_ALDEBARAN -L/opt/abde-rtems/lib/gcc/sparc-ab-rtems/4.8.2/soft -L/opt/abde-rtems/sparc-ab-rtems/lib/soft -mtune=v8 -msoft-float -fcommon -DTARGET_ALDEBARAN -o o-optimize/faster_rcnn.exe o-optimize/init.o o-optimize/lrn_layer.o
o-optimize/lrn_layer.o: In function `lrn_layer':
lrn_layer.c:(.text+0x4a8): undefined reference to `powf'
collect2: error: ld returned 1 exit status
make: *** [o-optimize/faster_rcnn.exe] Error 1
The compile process is composed of compilation of each individual .c files and final linking. I found somehow the -lm option which was added through XCFLAGS is being applied to the compilation command but not in the linking command. So I added -lm option in the object list so that that option is naturally following the object list in the link command. (I guess the proper way is to add -lm to the XLDFLAG because I found the variable in rtems build tree : extra LD flags). I'll try later..
OBJS= $(COBJS) $(CXXOBJS) $(ASOBJS) -lm

How can I give the sourcefilepaths to gcc?

How can I give my sourcepaths to gcc?
I have my .c files in source and test directory.
How can I give gcc the path to it? Im compiling with amakefile` and always get the message
"no such file or directory test.c"
My directory structure:
make-directory|
|
|--source
|
|--Header
|
|--test
|
|--out
|
as asked:
# makefile to generate UNIT-tests
# define any directories containing header files other than /usr/include
# TODO
HEADERS = :../CUnit/headers \
CUnit/sources/Automated \
CUnit/sources/Basic \
CUnit/sources/Console \
CUnit/sources/Curses \
CUnit/sources/Framework \
CUnit/sources/Test \
CUnit/sources/Win \
CUnit/sources/wxWidget \
stub \
../source \
test
SOURCES = CUnit/headers \
CUnit/sources/Automated \
CUnit/sources/Basic \
CUnit/sources/Console \
CUnit/sources/Curses \
CUnit/sources/Framework \
CUnit/sources/Test \
CUnit/sources/Win \
CUnit/sources/wxWidget \
stub \
source \
test
# define any libraries to link into executable:
# if I want to link in libraries (libx.so or libx.a) I use the -llibname
# option, something like (this will link in libmylib.so and libm.so:
LIBS =
# TODO define the C source files
TST_SRCS = min.c max.c
SRCS = CUnit.c Automated.c Basic.c Console.c CUCurses.c CUError.c Cunit_intl.c \
MyMem.c TestDB.c TestRun.c Util.c wxWidget.c \
$(TST_SRCS)
# define the C object files
#
# This uses Suffix Replacement within a macro:
# $(name:string1=string2)
# For each word in 'name' replace 'string1' with 'string2'
#OBJ = $(SRCS:%.c=%.o)
OBJ = $(TST_SRCS:%.c=%.o)
#OBJ=$(join ($(SOURCES)), $(notdir $(SRCS:%.c=%.o)))
# define the C compiler to use
CC = gcc
# define any compile-time flags
CFLAGS = -O0 -g -Wall -fmessage-length=0 -fprofile-arcs -ftest-coverage
#TODO Linkerflags
LFLAGS = --coverage
VPATH=source
# define the executable file,
TARGET = CUnit
all:
$(CC) -I $(HEADERS) $(CFLAGS) $(OBJ) -o $(TARGET) $(LFLAGS)
You can make use of vpath or VPATH in makefile to point to the directory containing the source files.
See the online gnu make manual here.

Resources