Not understanding makefile - linux

I'm struggling with this Makefile. It bombs out on the last line. Can't figure out what I am doing wrong. Can anyone see it? Thanks!
CC = gcc
CFLAGSFUSE = `pkg-config fuse --cflags`
LLIBSFUSE = `pkg-config fuse --libs`
CFLAGS = -c -g -Wall -Wextra
LFLAGS = -g -Wall -Wextra
encfs: encfs.o log.o xattr_new.o
$(CC) $(LFLAGS) $^ -o $# $(LLIBSFUSE)
xattr_new: xattr_new.o
$(CC) $(LFLAGS) $^ -o $#
encfs.o: encfs.c log.h params.h xattr_new.c
gcc -g -Wall `pkg-config fuse --cflags` -c pa4-encfs.c
log.o : log.c log.h params.h
$(CC) $(CFLAGS) $(CFLAGSFUSE) log.c
xattr_new.o: xattr_new.c
$(CC) $(CFLAGS) $<
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation
0 has invalid symbol index 11
/usr/bin/ld:/usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation
1 has invalid symbol index 12
/usr/bin/ld:/usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation
2 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation
3 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation
4 has invalid symbol index 11
...

Related

ifort compile executable linux undefined reference to

I have the following makefile
#makefile for building Linux 64b executable
FC = ifort
MPPD = -DAUTODOUBLE -4R8 -4I8
FLAGS = -safe_cray_ptr -assume byterecl,buffered_io,protect_parens -warn nousage -zero -ftz -fp-model precise -mP2OPT_hpo_dist_factor=21 -diag-disable 10212,10010 -fimf-arch-consistency=true -traceback -pad -DLINUX -DIFORT -DNET_SECURITY -DADDR64 -DINTEL -DXEON64 -DFCC80 -DTIMER=cycle_time -DSSE2 -DOVERRIDE -DMPP -DMPICH -DHPMPI -DAUTODOUBLE -DNEWIO -DEXTENDED -DLSTCODE -DENABLE_HASH3 -DFFTW -DZMF2 -DUSES_CXX -DPFEM -DSPRNG -DUSE_SPRNG -DUSES_CPP -DPTHREADS -nodps -i8 -r8 -DSPRNG_MPI -DUSE_MPI -DINTEL -DAdd_ -xSSE2 -align array16byte -fPIC -O2
TARGET = mppdyna
MPICH_LIB = /opt/intel/impi/4.1.3.048/mic/lib/libmpi.so
MPICH_INC = /opt/intel/impi/4.1.3.048/mic/include/
FFLAGS = $(FLAGS) -I. -I$(MPICH_INC) -I/opt/ibm/platform_mpi/include/
LINKLIBS = libgcrypt.so.20 libgpg-error.so.0 libpthread.so.0 libtriboformplugin.so
OBJS = dyn21.o dyn21b.o couple2other_user.o triboform_lsdyna_plugin.o
$(TARGET): $(OBJS)
$(FC) -w -o mppdyna.out $(OBJS) $(LINKLIBS)
init_dyn21.o: init_dyn21.f nhisparm.inc
$(FC) -c $(FFLAGS) init_dyn21.f
dyn21.o: dyn21.f nhisparm.inc
$(FC) -c $(FFLAGS) dyn21.f
dyn21b.o: dyn21b.f nhisparm.inc
$(FC) -c $(FFLAGS) dyn21b.f
couple2other_user.o: couple2other_user.f
$(FC) -c $(FFLAGS) couple2other_user.f
dynrfn_user.o: dynrfn_user.f
$(FC) -c $(FFLAGS) dynrfn_user.f
triboform_lsdyna_plugin.o: triboform_lsdyna_plugin.f
$(FC) -c $(FFLAGS) triboform_lsdyna_plugin.f
clean:
-#rm mppdyna 2>/dev/null || :
rm -rf *.o
And it gives me the following error message
...
...
dyn21b.f:(.text+0x90cd2): undefined reference to `adios_'
dyn21b.o: In function `umat48c_':
dyn21b.f:(.text+0x90dc2): undefined reference to `adios_'
dyn21b.o:dyn21b.f:(.text+0x90eb2): more undefined references to `adios_' follow
dyn21b.o: In function `thumat12_':
dyn21b.f:(.text+0x961ed): undefined reference to `crvval_'
dyn21b.f:(.text+0x96260): undefined reference to `crvval_'
dyn21b.o: In function `thumat13_':
dyn21b.f:(.text+0x963bc): undefined reference to `adios_'
...
...
libtriboformplugin.so: undefined reference to `do_license_check'
libtriboformplugin.so: undefined reference to `write_processing_file'
libtriboformplugin.so: undefined reference to `strerror_s'
libtriboformplugin.so: undefined reference to `fopen_s'
libtriboformplugin.so: undefined reference to `freopen_s'
make: *** [mppdyna] Error 1
I'm relatively new with ifort, can anyone point to me where my fault is?
which ifort points to /opt/intel/composer_xe_2013_sp1.2.144/bin/intel64/ifort and I'm also using platform_mpi.
I've created libtriboformplugin.so with another makefile (succesfully) that's from a C project.

Can anyone explain me this makefile example?

# Makefile to compare sorting routines
BASE = /home/blufox/base
CC = gcc
CFLAGS = -O –Wall
EFILE = $(BASE)/bin/compare_sorts
INCLS = -I$(LOC)/include
LIBS = $(LOC)/lib/g_lib.a \
$(LOC)/lib/h_lib.a
LOC = /usr/local
OBJS = main.o another_qsort.o chk_order.o \
compare.o quicksort.o
$(EFILE): $(OBJS)
#echo “linking …”
#$(CC) $(CFLAGS) –o $# $(OBJS) $(LIBS)
$(OBJS): compare_sorts.h
$(CC) $(CFLAGS) $(INCLS) –c $*.c
# Clean intermediate files
clean:
rm *~ $(OBJS)
variables substitute to form,
gcc -O –Wall -o /home/blufox/base/bin/compare_sorts main.o another_qsort.o chk_order.o compare.o quicksort.o main.c another_qsort.c chk_order.c compare.c
for eg:
$(OBJS) = main.o another_qsort.o chk_order.o compare.o quicksort.o

undefined symbol:_ZTVN10__cxxabiv121__vmi_class_type_infoE error

When I run python eval.py, it comes to the error::
ImportError: /home/aa/EAST/lanms/adaptor.so: undefined
symbol:_ZTVN10__cxxabiv121__vmi_class_type_infoE
I uses $make clean && make but it is still give me the same error and with some warring during execute the make
This is the makefile::
CXXFLAGS = -I include -std=c++11 -O3 $(shell python3-config --cflags)
LDFLAGS = $(shell python3-config --ldflags)
DEPS = lanms.h $(shell find include -xtype f)
CXX_SOURCES = adaptor.cpp include/clipper/clipper.cpp
LIB_SO = adaptor.so
$(LIB_SO): $(CXX_SOURCES) $(DEPS)
$(CXX) -o $# $(CXXFLAGS) $(LDFLAGS) $(CXX_SOURCES) --shared -fPIC
clean:
rm -rf $(LIB_SO)
when I use make command it show these warning::
/usr/bin/gcc-7 -o adaptor.so -I include -std=c++11 -O3 -I/home/ashwaq/anaconda3/include/python3.5m -I/home/aa/anaconda3/include/python3.5m -Wno-unused-result -Wsign-compare -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O3 -pipe -flto -fuse-linker-plugin -ffat-lto-objects -DNDEBUG -fwrapv -O3 -Wall -Wstrict-prototypes -L/home/ashwaq/anaconda3/lib/python3.5/config-3.5m -L/home/ashwaq/anaconda3/lib -lpython3.5m -lpthread -ldl -lutil -lrt -lm -Xlinker -export-dynamic adaptor.cpp include/clipper/clipper.cpp --shared -fPIC
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
In file included from include/pybind11/pytypes.h:12:0,
from include/pybind11/cast.h:13,
from include/pybind11/attr.h:13,
from include/pybind11/pybind11.h:43,
from adaptor.cpp:1:
adaptor.cpp: In function ‘PyObject* PyInit_adaptor()’:
include/pybind11/common.h:232:34: warning: ‘PyObject* pybind11_init()’ is deprecated: PYBIND11_PLUGIN is deprecated, use PYBIND11_MODULE [-Wdeprecated-declarations]
return pybind11_init(); \
^
adaptor.cpp:53:1: note: in expansion of macro ‘PYBIND11_PLUGIN’
PYBIND11_PLUGIN(adaptor) {
^~~~~~~~~~~~~~~
include/pybind11/common.h:217:22: note: declared here
static PyObject *pybind11_init(); \
^
adaptor.cpp:53:1: note: in expansion of macro ‘PYBIND11_PLUGIN’
PYBIND11_PLUGIN(adaptor) {
^~~~~~~~~~~~~~~
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
include/clipper/clipper.cpp: In member function ‘void ClipperLib::Clipper::FixupFirstLefts3(ClipperLib::OutRec*, ClipperLib::OutRec*)’:
include/clipper/clipper.cpp:3665:13: warning: unused variable ‘firstLeft’ [-Wunused-variable]
OutRec* firstLeft = ParseFirstLeft(outRec->FirstLeft);
I use::
ubuntu-17.4
tensorflow-1.4.0
python-3.5
gcc-7.0.1
cuda-8.0

OS detection Makefile

Here is my makefile, until today I never try to use OS detection in it. Mine looks like this :
CC = gcc
CFLAGS = -Wall -Wextra -O1 -Wuninitialized
OUT = project.exe
ifeq ($(UNAME),Darwin) #Mac OS
echo "Darwin"
SRC = sdl_gui.c libSDLextra.c libImageProcessing.c SDLmain.m
OBJ = sdl_gui.o libSDLextra.o libImageProcessing.o SDLmain.o
LIBS = -I /Library/Frameworks/SDL.framework/Headers -framework SDL -I /Library/Frameworks/SDL_ttf.framework/Versions/A/Headers -framework SDL_ttf -framework Cocoa
endif
ifeq ($(UNAME),Linux) #Linux based systems
SRC = sdl_gui.c libSDLextra.c libImageProcessing.c
OBJ = sdl_gui.o libSDLextra.o libImageProcessing.o
LIBS = -lSDL -lSDL_ttf
endif
all : $(OUT)
$(OUT) : $(OBJ)
$(CC) $(CFLAGS) $(OBJ) -o $(OUT)
$(OBJ) : $(SRC)
$(CC) $(CFLAGS) -c $(SRC)
clean :
rm -f $(OBJ) $(OUT)
When I do make I've got this error :
gcc -Wall -Wextra -O1 -Wuninitialized -o projet.exe
clang: error: no input files
make: *** [projet.exe] Error 1
I understand the error but I don't know how to fix it.
It looks like you are missing this from (near) the top of the file:
UNAME := $(shell uname)

Compiling wmii on Fedora 15 x86_64

I'm having trouble compiling wmii v3.9.2 on Fedora 15; Here's the interesting part (things break down at the linking stage):
% bmake -de
MAKE all libbio/
MAKE all libfmt/
MAKE all libregexp/
MAKE all libutf/
MAKE all libixp/
MAKE all doc/
MAKE all man/
MAKE all cmd/
MAKE all cmd/wmii/
MAKE all cmd/menu/
LD cmd/wmii9menu.out
/usr/bin/ld: wmii/xext.o: undefined reference to symbol 'XRenderFindVisualFormat'
/usr/bin/ld: note: 'XRenderFindVisualFormat' is defined in DSO /usr/lib64/libXrender.so.1 so try adding it to the linker command line
/usr/lib64/libXrender.so.1: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
*** Failed target: wmii9menu.out
*** Failed command: ../util/link "cc" "$(pkg-config --libs 2>/dev/null) -g -L../lib -L/usr/lib64 ../lib/libregexp9.a ../lib/libbio.a ../lib/libfmt.a ../lib/libutf.a -L../lib -L/usr/lib64 ../lib/libregexp9.a ../lib/libbio.a ../lib/libfmt.a ../lib/libutf.a" wmii9menu.out wmii9menu.o clientutil.o wmii/x11.o wmii/xext.o wmii/geom.o wmii/map.o util.o ../lib/libixp.a $(pkg-config --libs xft xrandr xinerama) -lXext
*** Error code 1
Stop.
bmake: stopped in /srv/redhat/BUILD/wmii+ixp-3.9.2/cmd
*** Failed target: dall
*** Failed command: dirs="libbio libfmt libregexp libutf libixp doc man cmd libwmii_hack rc alternative_wmiircs"; set -e; targ=dall; targ=${targ#d}; for i in $dirs; do export WMII_HGVERSION=""; export BASE=$i/; if [ ! -d $i ]; then echo Skipping nonexistent directory: $i 1>&2; else echo MAKE $targ $BASE; (cd $i && bmake $targ) || exit ; fi; done
*** Error code 1
Stop.
bmake: stopped in /srv/redhat/BUILD/wmii+ixp-3.9.2
Finally, in config.mk, I have the following settings:
...
INCLUDES = -I. -I$(ROOT)/include -I$(INCLUDE) -I/usr/include
LIBS = -L$(ROOT)/lib -L/usr/lib64
...
LDFLAGS += -g $(LIBS)
SOLDFLAGS += $(LDFLAGS)
SHARED = -shared -Wl,-soname=$(SONAME)
STATIC = -static
...
With a little more manual resolution, the statement generating the error is essentially as follows:
gcc \
-o wmii9menu.out\
-L../lib -L/usr/lib $(pkg-config --libs xft xrandr xinerama xext)\
../lib/libregexp9.a ../lib/libbio.a ../lib/libfmt.a\
../lib/libutf.a ../lib/libixp.a\
wmii9menu.o clientutil.o util.o\
wmii/x11.o wmii/xext.o wmii/geom.o wmii/map.o
Here, the pkg-config resolves to the following, which by itself is perfectly correct:
-lXft -lXrandr -lXinerama -lXext
And the solution is as follows:
--- wmii+ixp-3.9.2/config.mk 2011-06-03 14:03:22.950163074 +1000
+++ wmii+ixp-3.9.2/config.mk 2011-06-03 14:03:16.086129011 +1000
## -32 +32 ##
-X11PACKAGES = xft
+X11PACKAGES = xft xext xrandr xrender xinerama

Resources