tdd using cpputest make errors in ubuntu 14.04 - cpputest

I am trying to learn cpputest, so went to the cpputest manual and copied the below code in my ubuntu 14.04lts laptop, and tried to make. I am new to make files, and I got a bunch of errors - how can I correct my code?
#include "CppUTest/TestHarness.h"
#include "CppUTest/TestOutput.h"
TEST_GROUP(FirstTestGroup)
{
};
TEST(FirstTestGroup, FirstTest)
{
FAIL("Fail me!");
}
TEST(FirstTestGroup, SecondTest)
{
STRCMP_EQUAL("hello", "world");
LONGS_EQUAL(1, 2);
CHECK(false);
}
That is test.cpp, and i have main like below named test_main.cpp
#include "CppUTest/CommandLineTestRunner.h"
int main(int argc, char** argv)
{
return CommandLineTestRunner::RunAllTests(argc, argv);
}
The make file is:
all: test
export CPPUTEST_HOME=/usr/share/cpputest
CPPFLAGS += -I$(CPPUTEST_HOME)/include
LD_LIBRARIES = -L$(CPPUTEST_HOME)/lib -lCppUTest -lCppUTestExt
test: test_main.o test.o
g++ -o mytest test.o test_main.o
test_main.o: test_main.cpp
g++ -c test_main.cpp $(CPPFLAGS)
test.o: test.cpp
g++ -c test.cpp $(CPPFLAGS) $(LD_LIBRARIES)
#g++ -C -o test_main.o test_main.cpp test.o test.cpp $(CPPFLAGS)
#g++ -o mytest tet_main.o test.o $(LD_LIBRARIES)
clean:
rm -f *.o mytest
When I say make
I get a bunch of errors.
Please help me in this regard

I changed the my makefile as follows: after the changes it worked
all: mytest
export CPPUTEST_HOME=/usr/local
CPPFLAGS += -I$(CPPUTEST_HOME)/include
LD_LIBRARIES = -L$(CPPUTEST_HOME)/lib -lCppUTest -lCppUTestExt
mytest: test_main.o test.o
g++ -g -o mytest test.o test_main.o $(LD_LIBRARIES)
test_main.o: test_main.cpp
g++ -g $(CPPFLAGS) -c test_main.cpp
test.o: test.cpp
g++ -g $(CPPFLAGS) -c test.cpp
clean:
rm -f *.o mytest

Related

No rule to make target '-L/usr/local/lib'

I am facing a problem while trying to link opencv to CPP project generated by Matlab Coder. In the auto generated Makefile of the project, I added pkg-config --cflags opencv to CFLAGS and pkg-config --libs opencv to LIBS (opencv 3.4), which then gives the error "No rule to make target '-L/usr/local/lib'". Any ideas how to fix ther error?
PRODUCT_NAME = runeef
MAKEFILE = runeef_rtw.mk
MATLAB_ROOT = /usr/local/Polyspace/R2020a
MATLAB_BIN = /usr/local/Polyspace/R2020a/bin
MATLAB_ARCH_BIN = $(MATLAB_BIN)/glnxa64
MASTER_ANCHOR_DIR =
START_DIR = /home/dell/Documents/purefusion/codegen/exe/runeef
TGT_FCN_LIB = ISO_C++11
SOLVER_OBJ =
CLASSIC_INTERFACE = 0
MODEL_HAS_DYNAMICALLY_LOADED_SFCNS =
RELATIVE_PATH_TO_ANCHOR = .
C_STANDARD_OPTS = -fwrapv -ansi -pedantic -Wno-long-long
CPP_STANDARD_OPTS = -fwrapv -std=c++11 -pedantic
###########################################################################
## TOOLCHAIN SPECIFICATIONS
###########################################################################
# Toolchain Name: GNU gcc/g++ | gmake (64-bit Linux)
# Supported Version(s):
# ToolchainInfo Version: 2020a
# Specification Revision: 1.0
#
#-------------------------------------------
# Macros assumed to be defined elsewhere
#-------------------------------------------
# C_STANDARD_OPTS
# CPP_STANDARD_OPTS
#-----------
# MACROS
#-----------
WARN_FLAGS = -Wall -W -Wwrite-strings -Winline -Wstrict-prototypes -Wnested-externs -Wpointer-arith -Wcast-align
WARN_FLAGS_MAX = $(WARN_FLAGS) -Wcast-qual -Wshadow
CPP_WARN_FLAGS = -Wall -W -Wwrite-strings -Winline -Wpointer-arith -Wcast-align
CPP_WARN_FLAGS_MAX = $(CPP_WARN_FLAGS) -Wcast-qual -Wshadow
TOOLCHAIN_SRCS =
TOOLCHAIN_INCS =
TOOLCHAIN_LIBS =
#------------------------
# BUILD TOOL COMMANDS
#------------------------
# C Compiler: GNU C Compiler
CC = gcc
# Linker: GNU Linker
LD = g++
# C++ Compiler: GNU C++ Compiler
CPP = g++
# C++ Linker: GNU C++ Linker
CPP_LD = g++
# Archiver: GNU Archiver
AR = ar
# MEX Tool: MEX Tool
MEX_PATH = $(MATLAB_ARCH_BIN)
MEX = "$(MEX_PATH)/mex"
# Download: Download
DOWNLOAD =
# Execute: Execute
EXECUTE = $(PRODUCT)
# Builder: GMAKE Utility
MAKE_PATH = %MATLAB%/bin/glnxa64
MAKE = "$(MAKE_PATH)/gmake"
#-------------------------
# Directives/Utilities
#-------------------------
CDEBUG = -g
C_OUTPUT_FLAG = -o
LDDEBUG = -g
OUTPUT_FLAG = -o
CPPDEBUG = -g
CPP_OUTPUT_FLAG = -o
CPPLDDEBUG = -g
OUTPUT_FLAG = -o
ARDEBUG =
STATICLIB_OUTPUT_FLAG =
MEX_DEBUG = -g
RM = #rm -f
ECHO = #echo
MV = #mv
RUN =
#--------------------------------------
# "Faster Runs" Build Configuration
#--------------------------------------
ARFLAGS = ruvs
CFLAGS = $(shell pkg-config --cflags opencv) -c $(C_STANDARD_OPTS) -fPIC \
-O3 -fno-loop-optimize -fno-aggressive-loop-optimizations
CPPFLAGS = $(shell pkg-config --cflags opencv) -c $(CPP_STANDARD_OPTS) -fPIC \
-O3 -fno-loop-optimize -fno-aggressive-loop-optimizations
CPP_LDFLAGS = -Wl,-rpath,"$(MATLAB_ARCH_BIN)",-L"$(MATLAB_ARCH_BIN)"
CPP_SHAREDLIB_LDFLAGS = -shared -Wl,-rpath,"$(MATLAB_ARCH_BIN)",-L"$(MATLAB_ARCH_BIN)" -Wl,--no-undefined
DOWNLOAD_FLAGS =
EXECUTE_FLAGS =
LDFLAGS = -Wl,-rpath,"$(MATLAB_ARCH_BIN)",-L"$(MATLAB_ARCH_BIN)"
MEX_CPPFLAGS =
MEX_CPPLDFLAGS =
MEX_CFLAGS =
MEX_LDFLAGS =
MAKE_FLAGS = -f $(MAKEFILE)
SHAREDLIB_LDFLAGS = -shared -Wl,-rpath,"$(MATLAB_ARCH_BIN)",-L"$(MATLAB_ARCH_BIN)" -Wl,--no-undefined
###########################################################################
## OUTPUT INFO
###########################################################################
PRODUCT = /home/dell/Documents/purefusion/runeef
PRODUCT_TYPE = "executable"
BUILD_TYPE = "Executable"
###########################################################################
## INCLUDE PATHS
###########################################################################
INCLUDES_BUILDINFO = -I$(START_DIR) -I/home/dell/Documents/purefusion -I$(MATLAB_ROOT)/extern/include -I$(MATLAB_ROOT)/toolbox/vision/builtins/src/ocv/include -I$(MATLAB_ROOT)/toolbox/vision/builtins/src/ocvcg/opencv/include -I/home/dell/Documents/purefusion/codegen/exe
INCLUDES = $(INCLUDES_BUILDINFO)
###########################################################################
## DEFINES
###########################################################################
DEFINES_CUSTOM =
DEFINES_STANDARD = -DMODEL=runeef
DEFINES = $(DEFINES_CUSTOM) $(DEFINES_STANDARD)
###########################################################################
## SOURCE FILES
###########################################################################
SRCS = $(START_DIR)/rt_nonfinite.cpp $(START_DIR)/rtGetNaN.cpp $(START_DIR)/rtGetInf.cpp $(MATLAB_ROOT)/toolbox/vision/builtins/src/ocv/detectFASTCore.cpp $(MATLAB_ROOT)/toolbox/vision/builtins/src/ocv/cgCommon.cpp $(MATLAB_ROOT)/toolbox/vision/builtins/src/ocv/extractFreakCore.cpp $(MATLAB_ROOT)/toolbox/vision/builtins/src/ocv/mwfreak.cpp /home/dell/Documents/purefusion/codegen/exe/main.cpp $(START_DIR)/runeef_rtwutil.cpp $(START_DIR)/runeef_data.cpp $(START_DIR)/runeef_initialize.cpp $(START_DIR)/runeef_terminate.cpp $(START_DIR)/runeef.cpp $(START_DIR)/colon.cpp $(START_DIR)/string1.cpp $(START_DIR)/rgb2gray.cpp $(START_DIR)/abs.cpp $(START_DIR)/histeq.cpp $(START_DIR)/minOrMax.cpp $(START_DIR)/sum.cpp $(START_DIR)/imhist.cpp $(START_DIR)/bsxfun.cpp $(START_DIR)/cornerPoints_cg.cpp $(START_DIR)/FeaturePointsImpl.cpp $(START_DIR)/repmat.cpp $(START_DIR)/extractFeatures.cpp $(START_DIR)/mod.cpp $(START_DIR)/eef.cpp $(START_DIR)/remapFun.cpp $(START_DIR)/prod.cpp $(START_DIR)/imfilter.cpp $(START_DIR)/padarray.cpp $(START_DIR)/multiscaleBlendingColor.cpp $(START_DIR)/gaussian_pyramid.cpp $(START_DIR)/laplacian_pyramid.cpp $(START_DIR)/upsample.cpp $(START_DIR)/reconstruct_laplacian_pyramid.cpp $(START_DIR)/robustNormalization.cpp $(START_DIR)/sort.cpp $(START_DIR)/sortIdx.cpp
ALL_SRCS = $(SRCS)
###########################################################################
## OBJECTS
###########################################################################
OBJS = rt_nonfinite.o rtGetNaN.o rtGetInf.o detectFASTCore.o cgCommon.o extractFreakCore.o mwfreak.o main.o runeef_rtwutil.o runeef_data.o runeef_initialize.o runeef_terminate.o runeef.o colon.o string1.o rgb2gray.o abs.o histeq.o minOrMax.o sum.o imhist.o bsxfun.o cornerPoints_cg.o FeaturePointsImpl.o repmat.o extractFeatures.o mod.o eef.o remapFun.o prod.o imfilter.o padarray.o multiscaleBlendingColor.o gaussian_pyramid.o laplacian_pyramid.o upsample.o reconstruct_laplacian_pyramid.o robustNormalization.o sort.o sortIdx.o
ALL_OBJS = $(OBJS)
###########################################################################
## PREBUILT OBJECT FILES
###########################################################################
PREBUILT_OBJS =
###########################################################################
## LIBRARIES
###########################################################################
LIBS = $(MATLAB_ROOT)/bin/glnxa64/libmwjpegreader.so $(MATLAB_ROOT)/bin/glnxa64/libopencv_calib3d.so.3.4 $(MATLAB_ROOT)/bin/glnxa64/libopencv_core.so.3.4 $(MATLAB_ROOT)/bin/glnxa64/libopencv_features2d.so.3.4 $(MATLAB_ROOT)/bin/glnxa64/libopencv_flann.so.3.4 $(MATLAB_ROOT)/bin/glnxa64/libopencv_imgproc.so.3.4 $(MATLAB_ROOT)/bin/glnxa64/libopencv_ml.so.3.4 $(MATLAB_ROOT)/bin/glnxa64/libopencv_objdetect.so.3.4 $(MATLAB_ROOT)/bin/glnxa64/libopencv_video.so.3.4 $(MATLAB_ROOT)/bin/glnxa64/libopencv_cudaarithm.so.3.4 $(MATLAB_ROOT)/bin/glnxa64/libopencv_cudabgsegm.so.3.4 $(MATLAB_ROOT)/bin/glnxa64/libopencv_cudafeatures2d.so.3.4 $(MATLAB_ROOT)/bin/glnxa64/libopencv_cudafilters.so.3.4 $(MATLAB_ROOT)/bin/glnxa64/libopencv_cudaimgproc.so.3.4 $(MATLAB_ROOT)/bin/glnxa64/libopencv_cudalegacy.so.3.4 $(MATLAB_ROOT)/bin/glnxa64/libopencv_cudaobjdetect.so.3.4 $(MATLAB_ROOT)/bin/glnxa64/libopencv_cudaoptflow.so.3.4 $(MATLAB_ROOT)/bin/glnxa64/libopencv_cudastereo.so.3.4 $(MATLAB_ROOT)/bin/glnxa64/libopencv_cudawarping.so.3.4 $(MATLAB_ROOT)/bin/glnxa64/libopencv_cudev.so.3.4 $(shell pkg-config --libs opencv)
#/usr/local/lib/libopencv_core.so.4.5.1 /usr/local/lib/libopencv_imgcodecs.so.4.5.1 /usr/local/lib/libopencv_highgui.so.4.5.1
###########################################################################
## SYSTEM LIBRARIES
###########################################################################
SYSTEM_LIBS = -L"$(MATLAB_ROOT)/bin/glnxa64" -lmwrgb2gray_tbb -lmwgetnumcores -lmwtbbhist -lmwgrayxform_tbb -lmwgrayto8 -lmwippfilter -lmwipp -lmwimfilter -lmwnhood -lm -lstdc++
###########################################################################
## ADDITIONAL TOOLCHAIN FLAGS
###########################################################################
#---------------
# C Compiler
#---------------
CFLAGS_ = -Wno-variadic-macros -Wno-variadic-macros
CFLAGS_BASIC = $(DEFINES) $(INCLUDES)
CFLAGS += $(CFLAGS_) $(CFLAGS_BASIC)
#-----------------
# C++ Compiler
#-----------------
CPPFLAGS_ = -Wno-variadic-macros -Wno-variadic-macros
CPPFLAGS_BASIC = $(DEFINES) $(INCLUDES)
CPPFLAGS += $(CPPFLAGS_) $(CPPFLAGS_BASIC)
###########################################################################
## INLINED COMMANDS
###########################################################################
###########################################################################
## PHONY TARGETS
###########################################################################
.PHONY : all build buildobj clean info prebuild download execute
all : build
#echo "### Successfully generated all binary outputs."
build : prebuild $(PRODUCT)
buildobj : prebuild $(OBJS) $(PREBUILT_OBJS) $(LIBS)
#echo "### Successfully generated all binary outputs."
prebuild :
download : $(PRODUCT)
execute : download
#echo "### Invoking postbuild tool "Execute" ..."
$(EXECUTE) $(EXECUTE_FLAGS)
#echo "### Done invoking postbuild tool."
###########################################################################
## FINAL TARGET
###########################################################################
#-------------------------------------------
# Create a standalone executable
#-------------------------------------------
$(PRODUCT) : $(OBJS) $(PREBUILT_OBJS) $(LIBS)
#echo "### Creating standalone executable "$(PRODUCT)" ..."
$(CPP_LD) $(CPP_LDFLAGS) -o $(PRODUCT) $(OBJS) -Wl,--start-group $(LIBS) -Wl,--end-group $(SYSTEM_LIBS) $(TOOLCHAIN_LIBS)
#echo "### Created: $(PRODUCT)"
###########################################################################
## INTERMEDIATE TARGETS
###########################################################################
#---------------------
# SOURCE-TO-OBJECT
#---------------------
%.o : %.c
$(CC) $(CFLAGS) -o "$#" "$<"
%.o : %.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
%.o : $(RELATIVE_PATH_TO_ANCHOR)/%.c
$(CC) $(CFLAGS) -o "$#" "$<"
%.o : $(RELATIVE_PATH_TO_ANCHOR)/%.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
%.o : $(START_DIR)/%.c
$(CC) $(CFLAGS) -o "$#" "$<"
%.o : $(START_DIR)/%.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
%.o : /home/dell/Documents/purefusion/%.c
$(CC) $(CFLAGS) -o "$#" "$<"
%.o : /home/dell/Documents/purefusion/%.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
%.o : $(MATLAB_ROOT)/toolbox/vision/builtins/src/ocv/%.c
$(CC) $(CFLAGS) -o "$#" "$<"
%.o : $(MATLAB_ROOT)/toolbox/vision/builtins/src/ocv/%.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
%.o : /home/dell/Documents/purefusion/codegen/exe/%.c
$(CC) $(CFLAGS) -o "$#" "$<"
%.o : /home/dell/Documents/purefusion/codegen/exe/%.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
rt_nonfinite.o : $(START_DIR)/rt_nonfinite.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
rtGetNaN.o : $(START_DIR)/rtGetNaN.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
rtGetInf.o : $(START_DIR)/rtGetInf.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
detectFASTCore.o : $(MATLAB_ROOT)/toolbox/vision/builtins/src/ocv/detectFASTCore.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
cgCommon.o : $(MATLAB_ROOT)/toolbox/vision/builtins/src/ocv/cgCommon.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
extractFreakCore.o : $(MATLAB_ROOT)/toolbox/vision/builtins/src/ocv/extractFreakCore.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
mwfreak.o : $(MATLAB_ROOT)/toolbox/vision/builtins/src/ocv/mwfreak.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
main.o : /home/dell/Documents/purefusion/codegen/exe/main.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
runeef_rtwutil.o : $(START_DIR)/runeef_rtwutil.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
runeef_data.o : $(START_DIR)/runeef_data.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
runeef_initialize.o : $(START_DIR)/runeef_initialize.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
runeef_terminate.o : $(START_DIR)/runeef_terminate.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
runeef.o : $(START_DIR)/runeef.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
colon.o : $(START_DIR)/colon.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
string1.o : $(START_DIR)/string1.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
rgb2gray.o : $(START_DIR)/rgb2gray.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
abs.o : $(START_DIR)/abs.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
histeq.o : $(START_DIR)/histeq.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
minOrMax.o : $(START_DIR)/minOrMax.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
sum.o : $(START_DIR)/sum.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
imhist.o : $(START_DIR)/imhist.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
bsxfun.o : $(START_DIR)/bsxfun.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
cornerPoints_cg.o : $(START_DIR)/cornerPoints_cg.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
FeaturePointsImpl.o : $(START_DIR)/FeaturePointsImpl.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
repmat.o : $(START_DIR)/repmat.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
extractFeatures.o : $(START_DIR)/extractFeatures.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
mod.o : $(START_DIR)/mod.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
eef.o : $(START_DIR)/eef.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
remapFun.o : $(START_DIR)/remapFun.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
prod.o : $(START_DIR)/prod.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
imfilter.o : $(START_DIR)/imfilter.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
padarray.o : $(START_DIR)/padarray.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
multiscaleBlendingColor.o : $(START_DIR)/multiscaleBlendingColor.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
gaussian_pyramid.o : $(START_DIR)/gaussian_pyramid.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
laplacian_pyramid.o : $(START_DIR)/laplacian_pyramid.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
upsample.o : $(START_DIR)/upsample.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
reconstruct_laplacian_pyramid.o : $(START_DIR)/reconstruct_laplacian_pyramid.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
robustNormalization.o : $(START_DIR)/robustNormalization.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
sort.o : $(START_DIR)/sort.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
sortIdx.o : $(START_DIR)/sortIdx.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
###########################################################################
## DEPENDENCIES
###########################################################################
$(ALL_OBJS) : rtw_proj.tmw $(MAKEFILE)
clean :
$(ECHO) "### Deleting all derived files..."
$(RM) $(PRODUCT)
$(RM) $(ALL_OBJS)
$(ECHO) "### Deleted all derived files."
And a part of the corresponding messages after make command.
g++ -I/usr/local/include/opencv -I/usr/local/include -c -fwrapv -std=c++11 -pedantic -fPIC -O3 -fno-loop-optimize -fno-aggressive-loop-optimizations -Wno-variadic-macros -Wno-variadic-macros -DMODEL=runeef -I/home/dell/Documents/purefusion/codegen/exe/runeef -I/home/dell/Documents/purefusion -I/usr/local/Polyspace/R2020a/extern/include -I/usr/local/Polyspace/R2020a/toolbox/vision/builtins/src/ocv/include -I/usr/local/Polyspace/R2020a/toolbox/vision/builtins/src/ocvcg/opencv/include -I/home/dell/Documents/purefusion/codegen/exe -o "reconstruct_laplacian_pyramid.o" "/home/dell/Documents/purefusion/codegen/exe/runeef/reconstruct_laplacian_pyramid.cpp"
g++ -I/usr/local/include/opencv -I/usr/local/include -c -fwrapv -std=c++11 -pedantic -fPIC -O3 -fno-loop-optimize -fno-aggressive-loop-optimizations -Wno-variadic-macros -Wno-variadic-macros -DMODEL=runeef -I/home/dell/Documents/purefusion/codegen/exe/runeef -I/home/dell/Documents/purefusion -I/usr/local/Polyspace/R2020a/extern/include -I/usr/local/Polyspace/R2020a/toolbox/vision/builtins/src/ocv/include -I/usr/local/Polyspace/R2020a/toolbox/vision/builtins/src/ocvcg/opencv/include -I/home/dell/Documents/purefusion/codegen/exe -o "robustNormalization.o" "/home/dell/Documents/purefusion/codegen/exe/runeef/robustNormalization.cpp"
g++ -I/usr/local/include/opencv -I/usr/local/include -c -fwrapv -std=c++11 -pedantic -fPIC -O3 -fno-loop-optimize -fno-aggressive-loop-optimizations -Wno-variadic-macros -Wno-variadic-macros -DMODEL=runeef -I/home/dell/Documents/purefusion/codegen/exe/runeef -I/home/dell/Documents/purefusion -I/usr/local/Polyspace/R2020a/extern/include -I/usr/local/Polyspace/R2020a/toolbox/vision/builtins/src/ocv/include -I/usr/local/Polyspace/R2020a/toolbox/vision/builtins/src/ocvcg/opencv/include -I/home/dell/Documents/purefusion/codegen/exe -o "sort.o" "/home/dell/Documents/purefusion/codegen/exe/runeef/sort.cpp"
g++ -I/usr/local/include/opencv -I/usr/local/include -c -fwrapv -std=c++11 -pedantic -fPIC -O3 -fno-loop-optimize -fno-aggressive-loop-optimizations -Wno-variadic-macros -Wno-variadic-macros -DMODEL=runeef -I/home/dell/Documents/purefusion/codegen/exe/runeef -I/home/dell/Documents/purefusion -I/usr/local/Polyspace/R2020a/extern/include -I/usr/local/Polyspace/R2020a/toolbox/vision/builtins/src/ocv/include -I/usr/local/Polyspace/R2020a/toolbox/vision/builtins/src/ocvcg/opencv/include -I/home/dell/Documents/purefusion/codegen/exe -o "sortIdx.o" "/home/dell/Documents/purefusion/codegen/exe/runeef/sortIdx.cpp"
make: *** No rule to make target '-L/usr/local/lib', needed by '/home/dell/Documents/purefusion/runeef'. Stop.
Also, the error message when I am removing $LIBS from
$(PRODUCT) : $(OBJS) $(PREBUILT_OBJS) $(LIBS)
#echo "### Creating standalone executable "$(PRODUCT)" ..."
$(CPP_LD) $(CPP_LDFLAGS) -o $(PRODUCT) $(OBJS) -Wl,--start-group $(LIBS) -Wl,--end-group $(SYSTEM_LIBS) $(TOOLCHAIN_LIBS)
#echo "### Created: $(PRODUCT)"
Last few lines of messages
g++ -I/usr/local/include/opencv -I/usr/local/include -c -fwrapv -std=c++11 -pedantic -fPIC -O3 -fno-loop-optimize -fno-aggressive-loop-optimizations -Wno-variadic-macros -Wno-variadic-macros -DMODEL=runeef -I/home/dell/Documents/purefusion/codegen/exe/runeef -I/home/dell/Documents/purefusion -I/usr/local/Polyspace/R2020a/extern/include -I/usr/local/Polyspace/R2020a/toolbox/vision/builtins/src/ocv/include -I/usr/local/Polyspace/R2020a/toolbox/vision/builtins/src/ocvcg/opencv/include -I/home/dell/Documents/purefusion/codegen/exe -o "sortIdx.o" "/home/dell/Documents/purefusion/codegen/exe/runeef/sortIdx.cpp"
### Creating standalone executable /home/dell/Documents/purefusion/runeef ...
g++ -Wl,-rpath,"/usr/local/Polyspace/R2020a/bin/glnxa64",-L"/usr/local/Polyspace/R2020a/bin/glnxa64" -o /home/dell/Documents/purefusion/runeef rt_nonfinite.o rtGetNaN.o rtGetInf.o detectFASTCore.o cgCommon.o extractFreakCore.o mwfreak.o main.o runeef_rtwutil.o runeef_data.o runeef_initialize.o runeef_terminate.o runeef.o colon.o string1.o rgb2gray.o abs.o histeq.o minOrMax.o sum.o imhist.o bsxfun.o cornerPoints_cg.o FeaturePointsImpl.o repmat.o extractFeatures.o mod.o eef.o remapFun.o prod.o imfilter.o padarray.o multiscaleBlendingColor.o gaussian_pyramid.o laplacian_pyramid.o upsample.o reconstruct_laplacian_pyramid.o robustNormalization.o sort.o sortIdx.o -Wl,--start-group /usr/local/Polyspace/R2020a/bin/glnxa64/libmwjpegreader.so /usr/local/Polyspace/R2020a/bin/glnxa64/libopencv_calib3d.so.3.4 /usr/local/Polyspace/R2020a/bin/glnxa64/libopencv_core.so.3.4 /usr/local/Polyspace/R2020a/bin/glnxa64/libopencv_features2d.so.3.4 /usr/local/Polyspace/R2020a/bin/glnxa64/libopencv_flann.so.3.4 /usr/local/Polyspace/R2020a/bin/glnxa64/libopencv_imgproc.so.3.4 /usr/local/Polyspace/R2020a/bin/glnxa64/libopencv_ml.so.3.4 /usr/local/Polyspace/R2020a/bin/glnxa64/libopencv_objdetect.so.3.4 /usr/local/Polyspace/R2020a/bin/glnxa64/libopencv_video.so.3.4 /usr/local/Polyspace/R2020a/bin/glnxa64/libopencv_cudaarithm.so.3.4 /usr/local/Polyspace/R2020a/bin/glnxa64/libopencv_cudabgsegm.so.3.4 /usr/local/Polyspace/R2020a/bin/glnxa64/libopencv_cudafeatures2d.so.3.4 /usr/local/Polyspace/R2020a/bin/glnxa64/libopencv_cudafilters.so.3.4 /usr/local/Polyspace/R2020a/bin/glnxa64/libopencv_cudaimgproc.so.3.4 /usr/local/Polyspace/R2020a/bin/glnxa64/libopencv_cudalegacy.so.3.4 /usr/local/Polyspace/R2020a/bin/glnxa64/libopencv_cudaobjdetect.so.3.4 /usr/local/Polyspace/R2020a/bin/glnxa64/libopencv_cudaoptflow.so.3.4 /usr/local/Polyspace/R2020a/bin/glnxa64/libopencv_cudastereo.so.3.4 /usr/local/Polyspace/R2020a/bin/glnxa64/libopencv_cudawarping.so.3.4 /usr/local/Polyspace/R2020a/bin/glnxa64/libopencv_cudev.so.3.4 -L/usr/local/lib -lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dpm -lopencv_highgui -lopencv_videoio -lopencv_face -lopencv_freetype -lopencv_fuzzy -lopencv_hfs -lopencv_img_hash -lopencv_line_descriptor -lopencv_optflow -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_dnn -lopencv_plot -lopencv_xfeatures2d -lopencv_shape -lopencv_video -lopencv_ml -lopencv_ximgproc -lopencv_xobjdetect -lopencv_objdetect -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_flann -lopencv_xphoto -lopencv_photo -lopencv_imgproc -lopencv_core -Wl,--end-group -L"/usr/local/Polyspace/R2020a/bin/glnxa64" -lmwrgb2gray_tbb -lmwgetnumcores -lmwtbbhist -lmwgrayxform_tbb -lmwgrayto8 -lmwippfilter -lmwipp -lmwimfilter -lmwnhood -lm -lstdc++
/usr/bin/ld: /usr/local/lib/libopencv_imgcodecs.so: undefined reference to `cv::Mat::Mat()'
/usr/bin/ld: /usr/local/lib/libopencv_imgcodecs.so: undefined reference to `cv::detail::check_failed_auto(int, cv::detail::CheckContext const&)'
/usr/bin/ld: /usr/local/lib/libopencv_imgcodecs.so: undefined reference to `cv::Mat::Mat(int, int, int)'
/usr/bin/ld: /usr/local/lib/libopencv_imgcodecs.so: undefined reference to `cv::detail::check_failed_MatType(int, cv::detail::CheckContext const&)'
/usr/bin/ld: /usr/local/lib/libopencv_imgcodecs.so: undefined reference to `cv::detail::check_failed_MatType(int, int, cv::detail::CheckContext const&)'
/usr/bin/ld: /usr/local/lib/libopencv_imgcodecs.so: undefined reference to `cv::detail::check_failed_MatDepth(int, int, cv::detail::CheckContext const&)'
/usr/bin/ld: /usr/local/lib/libopencv_imgcodecs.so: undefined reference to `cv::detail::check_failed_auto(int, int, cv::detail::CheckContext const&)'
/usr/bin/ld: /usr/local/lib/libopencv_imgcodecs.so: undefined reference to `cv::Mat::total() const'
/usr/bin/ld: /usr/local/lib/libopencv_imgcodecs.so: undefined reference to `cv::detail::check_failed_auto(unsigned long, unsigned long, cv::detail::CheckContext const&)'
collect2: error: ld returned 1 exit status
make: *** [runeef_rtw.mk:270: /home/dell/Documents/purefusion/runeef] Error 1
Your makefile has the variable assignment (edited for brevity)...
LIBS = $(MATLAB_ROOT)/bin/glnxa64/libmwjpegreader.so ... $(shell pkg-config --libs opencv)
Where the $(shell pkg-config --libs opencv) component will expand to something like...
-L/usr/local/lib -lopencv
But you then use $(LIBS) as a dependency for several targets, e.g...
$(PRODUCT) : $(OBJS) $(PREBUILT_OBJS) $(LIBS)
which expands to (again, edited for brevity)...
$(PRODUCT) : $(OBJS) $(PREBUILT_OBJS) -L/usr/local/lib -lopencv
Hence, when make attempts to process the target $(PRODUCT) it will see that the target seemingly depends on -L/usr/local/lib and act accordingly.
It's difficult to provide a more complete answer without more context but $(LIBS) probably shouldn't be listed as a dependency for this or any other targets.

How to compile ".c" file for "aarch64" with "cfi" enabled using "clang"?

I'm building "main.c" file:
int sum(int x, int y) {
return x + y;
}
int dbl(int x) {
return x + x;
}
void call_fn(int (*fn)(int)) {
(*fn)(42);
}
void erase_type(void *fn) {
call_fn(fn);
}
int main() {
erase_type(sum);
return 0;
}
for the host "x86" platform with enabled "cfi" sanitizer feature using following command:
./clang-8 \
-fsanitize=cfi \
-fvisibility=hidden \
-fno-sanitize-trap=all \
-fuse-ld=gold \
-flto \
main.c \
-o \
main
Now I need to compile this file for the "aarch64" processor.
I know how to simply compile this file (with disabled cfi feature).
rm -f main.o && \
./clang-8 \
-cc1 \
-triple \
aarch64-funnyos-unknown-gnueabi \
-emit-obj \
-target-cpu \
generic \
-O2 \
-Wall \
-o \
main.o \
-x \
c \
main.c \
&& \
file main.o
But I don't know how to compile "main.c" file for "aarch64" with "cfi" enabled.
Does anybody know how to do it?
UPD. Let suppose, that CPU is of ARMv8 type and Linux is running, for example, on QEMU emulator. Let suppose, host is x86 and run on Linux. I need to cross compile code on host x86 Linux for the ARMv8 target (which is run on QEMU, Linux).
Your x86 and AArch64 commands are very different. The first one runs compiler driver which supports compiler flags (-fsanitize=cfi in particular).
You second command though runs compiler proper (as indicated by -cc1 switch). This is an internal mode: it's run by compiler driver under the hood so it does not support normal compiler flags and is not meant to be run by ordinary users. You should switch to using compiler driver on AArch64.
At first, we need to compile main.c by clang's compiler into llvm's intermediate code:
./clang-8 \
--target=\
aarch64-funnyos-unknown-gnueabi \
-c \
-flto \
-fsanitize=cfi \
-fvisibility=default \
main.c \
-o \
main.o
Next step is to translate/link this code into binary file by means of gold linker (for example, from AndroidNDK) using gold plugin (from LLVM project), telling linker the emulation mode (-m option, which means for which architecture the binary should be generated):
/PATH/TO/aarch64-linux-android-4.9/prebuilt/linux-x86_64/aarch64-linux-android/bin/ld.gold \
-pie \
-m \
aarch64_elf64_le_vec \
-o \
main \
-plugin \
/PATH/TO/llvm-project/build/lib/LLVMgold.so \
-plugin-opt=mcpu=generic \
-plugin-opt=O2 \
-plugin-opt=-debugger-tune=gdb \
main.o
P.S. Thanks to #yugr for assistance and help!

Using hyperledger-fabric v1.0.0 make docker got an error

Because of the need of the project, we have changed the core/chaincode/shim of fabric1.0.0. The tree structure of shim is:
shim
├── chaincode.go
├── handler.go
├── inprocstream.go
├── interfaces.go
├── java
│ └── ···
├── mockstub.go
├── mockstub_test.go
├── response.go
├── myxxxutil.go
├── shim_test.go
└── myxxx.go
Some of these functions require cgo, which is writen in c++, there is some code snippet:
//myxxx.go
package shim
/*
#cgo CFLAGS: -I/opt/xxxsrc
#cgo LDFLAGS: -L/usr/lib -lmyxxx
#include "interface.hpp"
#include <stdlib.h>
*/
import "C"
func SomeFucn(){
··· //the C++ source code is in /opt/xxxsrc folder,so is interface.hpp file,the libmyxxx.so file is in /usr/lib folder
}
The, I used the make docker command to create a peer image based on hyperledger/fabric-baseimage:x86_64-0.3.1 under fabric directory. This hyperledger/fabric-baseimage:x86_64-0.3.1 has been modified by me. I put the libmyxxx. so file into /usr/lib folder of this "baseimage", and put the c++ soure code into /opt/xxxsrc, Then the execution log is:
Building build/docker/bin/peer
(the docker command line is:
docker run -i --rm --user=0 -v /home/my/gopath/src/github.com/hyperledger/fabric:/opt/gopath/src/github.com/hyperledger/fabric -w /opt/gopath/src/github.com/hyperledger/fabric -v /home/my/gopath/src/github.com/hyperledger/fabric/build/docker/bin:/opt/gopath/bin -v /home/my/gopath/src/github.com/hyperledger/fabric/build/docker/peer/pkg:/opt/gopath/pkg hyperledger/fabric-baseimage:x86_64-0.3.1
go install -ldflags "-X github.com/hyperledger/fabric/common/metadata.Version=1.0.0 -X github.com/hyperledger/fabric/common/metadata.BaseVersion=0.3.1 -X github.com/hyperledger/fabric/common/metadata.BaseDockerLabel=org.hyperledger.fabric -X github.com/hyperledger/fabric/common/metadata.DockerNamespace=hyperledger -X github.com/hyperledger/fabric/common/metadata.BaseDockerNamespace=hyperledger -linkmode external -extldflags -static -lpthread" github.com/hyperledger/fabric/peer
)
github.com/hyperledger/fabric/core/chaincode/shim
mkdir -p $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/
cd /opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/shim
CGO_LDFLAGS="-g" "-O2" "-L/usr/lib" "-lmyxxx" "-L/usr/lib" "-lmyxxx" /opt/go/pkg/tool/linux_amd64/cgo -objdir $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/ -importpath github.com/hyperledger/fabric/core/chaincode/shim – -I $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/ -I/opt/xxxsrc -I/opt/xxxsrc myxxxutil.go myxxx.go
cd /opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/shim
gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/ -g -O2 -I/opt/xxxsrc -I/opt/xxxsrc -o $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/_cgo_main.o -c $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/_cgo_main.c
cd /opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/shim
gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/ -g -O2 -I/opt/xxxsrc -I/opt/xxxsrc -o $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/_cgo_export.o -c $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/_cgo_export.c
gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/ -g -O2 -I/opt/xxxsrc -I/opt/xxxsrc -o $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/myxxxutil.cgo2.o -c $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/myxxxutil.cgo2.c
gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/ -g -O2 -I/opt/xxxsrc -I/opt/xxxsrc -o $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/xxx.cgo2.o -c $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/xxx.cgo2.c
cd /opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/shim
gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -o $WORK/github.com/hyperledger/fabric/core/chaincode/shim/obj/_cgo.o $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/_cgo_main.o $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/_cgo_export.o $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/myxxxutil.cgo2.o $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/myxxx.cgo2.o -g -O2 -L/usr/lib -lmyxxx -L/usr/lib -lmyxxx
cd /opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/shim
/opt/go/pkg/tool/linux_amd64/cgo -objdir $WORK/github.com/hyperledger/fabric/core/chaincode/shim/obj/ -dynpackage shim -dynimport $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/_cgo.o -dynout $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/_cgo_import.go
gcc I . -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -o $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/_all.o $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/_cgo_export.o $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/myxxxutil.cgo2.o $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/myxxx.cgo2.o -g -O2 -L/usr/lib -L/usr/lib -Wl,-r -nostdlib -no-pie -Wl,-build-id=none
/opt/go/pkg/tool/linux_amd64/compile -o $WORK/github.com/hyperledger/fabric/core/chaincode/shim.a -trimpath $WORK -p github.com/hyperledger/fabric/core/chaincode/shim -buildid 2ee9889b3f3fdd6fc02e5029d94e8c287f977ccb -importmap github.com/golang/protobuf/proto=github.com/hyperledger/fabric/vendor/github.com/golang/protobuf/proto -importmap github.com/golang/protobuf/ptypes/timestamp=github.com/hyperledger/fabric/vendor/github.com/golang/protobuf/ptypes/timestamp -importmap github.com/looplab/fsm=github.com/hyperledger/fabric/vendor/github.com/looplab/fsm -importmap github.com/op/go-logging=github.com/hyperledger/fabric/vendor/github.com/op/go-logging -importmap github.com/spf13/viper=github.com/hyperledger/fabric/vendor/github.com/spf13/viper -importmap golang.org/x/net/context=github.com/hyperledger/fabric/vendor/golang.org/x/net/context -importmap google.golang.org/grpc=github.com/hyperledger/fabric/vendor/google.golang.org/grpc -D _/opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/shim -I $WORK -I /opt/gopath/pkg/linux_amd64 -pack ./chaincode.go ./fileIO.go ./handler.go ./inprocstream.go ./interfaces.go ./mockstub.go ./response.go $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/_cgo_gotypes.go $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/myxxxutil.cgo1.go $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/myxxx.cgo1.go $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/_cgo_import.go
cd /opt/gopath/src/github.com/hyperledger/fabric/core/chaincode/shim
pack r $WORK/github.com/hyperledger/fabric/core/chaincode/shim.a $WORK/github.com/hyperledger/fabric/core/chaincode/shim/_obj/_all.o # internal
cp $WORK/github.com/hyperledger/fabric/core/chaincode/shim.a /opt/gopath/pkg/linux_amd64/github.com/hyperledger/fabric/core/chaincode/shim.a
/opt/go/pkg/tool/linux_amd64/link -o $WORK/github.com/hyperledger/fabric/peer/_obj/exe/a.out -L $WORK -L /opt/gopath/pkg/linux_amd64 -extld=gcc -buildmode=exe -buildid=c7ee3188106eddcbae7255ad032536402bc38b29 -X github.com/hyperledger/fabric/common/metadata.Version=1.0.0 -X github.com/hyperledger/fabric/common/metadata.BaseVersion=0.3.1 -X github.com/hyperledger/fabric/common/metadata.BaseDockerLabel=org.hyperledger.fabric -X github.com/hyperledger/fabric/common/metadata.DockerNamespace=hyperledger -X github.com/hyperledger/fabric/common/metadata.BaseDockerNamespace=hyperledger -linkmode external -extldflags "-static -lpthread" $WORK/github.com/hyperledger/fabric/peer.a
github.com/hyperledger/fabric/peer
/opt/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: cannot find -lmyxxx
/usr/bin/ld: cannot find -lmyxxx
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libltdl.a(dlopen.o): In function `vm_open':
(.text+0x5e): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/tmp/go-link-940349017/000001.o: In function `_cgo_7a2d42f1a351_C2func_getaddrinfo':
/tmp/workdir/go/src/net/cgo_unix.go:66: warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
collect2: error: ld returned 1 exit status
Makefile:197: recipe for target 'build/docker/bin/peer' failed
make: *** [build/docker/bin/peer] Error 2
I already tried to add path (/usr/lib) in /etc/ld.so.conf file, and executed "ldconfig", and also tried to add path to environment variables LD_LIBRARY_PATH and LIBRARY_PATH, the problem still reappears, so I would like to ask if there is any solution to the problem, thank you

clang error invalid version number in -miphoneos-version-min=.sd

When i compile librtmp for ios, the script shows below:
#!/bin/sh
# OS X Yosemite, Xcode 6.1
set -ex
DEVELOPER="/Applications/Xcode.app/Contents/Developer"
DEVICE_SDK="$DEVELOPER/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk"
SIMULATOR_SDK="$DEVELOPER/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk"
CURRPATH=`pwd`
SOURCE="rtmpdump"
DSTDIR="librtmp"
LIBSSL=`cd ../OpenSSL/libssl;pwd`
ARCHS="i386 x86_64 armv7 armv7s arm64"
rm -rf $DSTDIR
mkdir $DSTDIR
if [ ! -d $SOURCE ]; then
git clone git://git.ffmpeg.org/rtmpdump $SOURCE
else
cd $SOURCE
git fetch
cd ..
fi
cd $SOURCE/librtmp
for ARCH in $ARCHS; do
mkdir -p ../$DSTDIR/$ARCH
if [[ $ARCH == arm* ]]; then
SDK=$DEVICE_SDK
else
SDK=$SIMULATOR_SDK
fi
perl -i -pe 's|^AR=\$\(CROSS_COMPILE\)ar|AR=xcrun ar|' Makefile
CROSS_COMPILE="$DEVELOPER/usr/bin/" \
XCFLAGS="-O0 -isysroot $SDK -I$LIBSSL/include -arch $ARCH " \
XLDFLAGS="-isysroot $SDK -L$LIBSSL/lib -arch $ARCH -miphoneos-version-min=7.0 " \
make SYS=darwin
make SYS=darwin prefix="$CURRPATH/$DSTDIR/$ARCH" install
make clean
done
mkdir -p $CURRPATH/$DSTDIR/lib
cd $CURRPATH/$DSTDIR/$ARCH/lib
LIBS=`ls *.a`
cd $CURRPATH
for LIB in $LIBS; do
lipo -create `find $DSTDIR -name $LIB` -output $DSTDIR/lib/$LIB
done
cp -rf $DSTDIR/$ARCH/include $DSTDIR
for ARCH in $ARCHS; do
rm -rf $DSTDIR/$ARCH
done
when statement make SYS=darwin runs, error shows:
/Applications/Xcode.app/Contents/Developer/usr/bin/gcc -Wall -O0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -I/Users/Smeegol/Desktop/AVCodecs2/OpenSSL/libssl/include -arch armv7 -DRTMPDUMP_VERSION=\"v2.4\" -DUSE_OPENSSL -O2 -fPIC -c -o rtmp.o rtmp.c
clang: error: invalid version number in '-miphoneos-version-min=.sd'
make: *** [rtmp.o] Error 1
Why? I have set XLDFLAGS="-isysroot $SDK -L$LIBSSL/lib -arch $ARCH -miphoneos-version-min=7.0 " and why invalid version number in '-miphoneos-version-min=.sd' occurs?
I had the same problem and resolved it by changing the -isysroot argument from:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk
to:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk
Note that the latter is a symlink to the former on my system.
It appears that clang is implicitly setting -miphoneos-version-min= from the iPhoneOSXXX.sdk directory name. Using the link with the version number in it seems to fix the compilation issue.

issue in installing Sphinx on mac

Compiling the code using :-
LDFLAGS="-arch x86_64" ./configure --prefix=/usr/local --with-mysql=/usr/local/mysql-5.5.9-osx10.6-x86_64
O/p for the compilation.
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating libstemmer_c/Makefile
config.status: creating sphinx.conf.dist
config.status: creating sphinx-min.conf.dist
config.status: creating config/config.h
config.status: executing depfiles commands
configuration done
------------------
You can now run 'make' to build Sphinx binaries,
and then run 'make install' to install them.
O/p for make:--
g++ -DHAVE_CONFIG_H -I. -I../config -DSYSCONFDIR="\"/usr/local/etc\"" -I/usr/local/include -I/usr/local/mysql-5.5.9-osx10.6-x86_64/include -Os -g -fno-common -fno-strict-aliasing -arch x86_64 -Wall -g -D_FILE_OFFSET_BITS=64 -O3 -DNDEBUG -MT tests.o -MD -MP -MF .deps/tests.Tpo -c -o tests.o tests.cpp
mv -f .deps/tests.Tpo .deps/tests.Po
g++ -Wall -g -D_FILE_OFFSET_BITS=64 -O3 -DNDEBUG -arch x86_64 -o tests tests.o libsphinx.a -L/usr/local/mysql-5.5.9-osx10.6-x86_64/lib -lmysqlclient -lpthread -lodbc -lz -lexpat -L/usr/local/lib -lpthread
Making all in test
make[1]: Nothing to be done for `all'.
make[1]: Nothing to be done for `all-am'.
O/p for make install:--
Making install in src
if test -d ../.svn; then svn info .. --xml | perl svnxrev.pl; fi;
make install-am
test -z "/usr/local/bin" || ../config/install-sh -c -d "/usr/local/bin"
/usr/bin/install -c 'indexer' '/usr/local/bin/indexer'
/usr/bin/install -c 'searchd' '/usr/local/bin/searchd'
/usr/bin/install -c 'search' '/usr/local/bin/search'
/usr/bin/install -c 'spelldump' '/usr/local/bin/spelldump'
/usr/bin/install -c 'indextool' '/usr/local/bin/indextool'
make[3]: Nothing to be done for `install-data-am'.
Making install in test
make[1]: Nothing to be done for `install'.
test -z "/usr/local/etc" || config/install-sh -c -d "/usr/local/etc"
/usr/bin/install -c -m 644 'sphinx.conf.dist' '/usr/local/etc/sphinx.conf.dist'
/usr/bin/install -c -m 644 'sphinx-min.conf.dist' '/usr/local/etc/sphinx-min.conf.dist'
/usr/bin/install -c -m 644 'example.sql' '/usr/local/etc/example.sql'
make install-data-hook
mkdir -p /usr/local/var/data && mkdir -p /usr/local/var/log
If I try to run thinking sphinx server:-
rake thinking_sphinx:index
(in /Users/mohit/projects/urbanAdda)
sh: line 1: 26356 Trace/BPT trap indexer 2>&1
sh: line 1: 26359 Trace/BPT trap indexer 2>&1
Sphinx cannot be found on your system. You may need to configure the following
settings in your config/sphinx.yml file:
* bin_path
* searchd_binary_name
* indexer_binary_name
For more information, read the documentation:
http://freelancing-god.github.com/ts/en/advanced_config.html
sh: line 1: 26361 Trace/BPT trap indexer 2>&1
Generating Configuration to /Users/mohit/projects/urbanAdda/config/development.sphinx.conf
dyld: Library not loaded: libmysqlclient.16.dylib
Referenced from: /usr/local/bin/indexer
Reason: image not found
sudo install_name_tool -change libmysqlclient.16.dylib /usr/local/mysql-5.5.9-osx10.6-x86_64//lib/libmysqlclient.16.dylib /usr/local/bin/indexer
and
sudo install_name_tool -change libmysqlclient.16.dylib /usr/local/mysql-5.5.9-osx10.6-x86_64//lib/libmysqlclient.16.dylib /usr/local/bin/searchd
solved my problem
The dynamic linker cannot find the mysqlclient library.
Try to add the path where it's installed to the DYLD_LIBRARY_PATH environment variable.
And when/if you plan to rebuild it, add "-Wl,-rpath /path/to/lib" to LDFLAGS.

Resources