I am using automake to build my project. My project uses pthread and libsocketcan. I have installed libsocketcan with the command
sudo apt-get install libsocketcan-dev
In eclpise I have added linker flags for pthread and libsocketcan. The code will compile and run. When I run my automake script the build fails with the error.
gcc: error: unrecognized command line option ‘-socketcan’[![enter image description here][1]][1]
My makefile.am is as follows:
AUTOMAKE_OPTIONS = foreign subdir-objects
bin_PROGRAMS = MAIN_Application
LDFLAGS = \
-pthread \
-socketcan
AM_CPPFLAGS = \
-I$(srcdir)/include \
-I$(srcdir)/include/utilities \
-I$(srcdir)/include/comms
MAIN_Application_SOURCES = \
src/main.c \
src/scheduler.c \
src/utilities/time_conversions.c \
src/utilities/ring_buffer.c \
src/utilities/logger.c \
src/comms/can.c
If I remove all code and references here to socketcan, everything works fine. I get a nice application binary that can run threads. Once I add can I can no longer build. I have tried with the LDFLAGS socketcan, libsocketcan and libsocketcan-dev.
What LDFLAG do I need in my makefile to properly include libsocketcan?
You do not need any "LDFLAG" for this. LDFLAGS is for linker flags, not for adding libraries to link to.
You can have MAIN_Application link against libsocketcan with something like:
MAIN_Application_LDADD = -lsocketcan
Related
I am adding a module apps/trace.c to be compiled into the openssl programs when building the OpenSSL library. The purpose is save a trace list of function calls using the gcc -finstrument-functions compile option, as described
here
Actually, I have succeeded by modifying the automatically generated "Makefile" by hand, adding in trace.o as follows:
apps/openssl: apps/trace.o apps/app_rand.o apps/apps.o ...
$(RM) apps/openssl
$(MAKE) -f $(SRCDIR)/Makefile.shared -e \
PERL="$(PERL)" SRCDIR=$(SRCDIR) \
APPNAME=apps/openssl OBJECTS="apps/trace.o apps/app_rand.o apps/apps.o ..." \
LIBDEPS='$(PLIB_LDFLAGS) '" -L. -lssl -L. -lcrypto"' $(EX_LIBS)' \
CC='$(CC)' CFLAGS='$(CFLAGS) $(BIN_CFLAGS)' \
LDFLAGS='$(LDFLAGS)' \
link_app.
However, then next time configure is run, the manual change will be overwritten when the Makefile is again automatically generated.
I am not quite sure how to configure the trace object file into the compilation at a higher level. That is my question.
I'm trying to put together a simple makefile example like so:
FLAGS = -std=c++14
INC= -I/usr/local/include
LI = -L/usr/local/lib
LIB = /usr/local/lib/
LIBS = $(LIB)libboost_filesystem-mt.a \
$(LIB)libboost_filesystem-mt.dylib \
$(LIB)libboost_filesystem.a \
$(LIB)libboost_filesystem.dylib \
$(LIB)libboost_system-mt.a \
$(LIB)libboost_system-mt.dylib \
$(LIB)libboost_system.a \
$(LIB)libboost_system.dylib
default:
g++ main.cpp $(FLAGS) $(INC) $(LI) $(LIBS) -o assemble
./assemble
clean:
rm assemble
Is there a way to not have to prepend $(LIB) so many times? That's the only way I can get this to work right now (the above doesn't).
If you want the linker to search the path you have to add libraries using the -l flag. So instead of adding libboost_system-mt.a to your link line, you have to add -lboost_system-mt to your link line. Then the linker will search the paths provided by -L.
I'm not sure about the dylib stuff; I don't do much with OS X.
In any event, if you're using GNU make you can do this:
LIBNAMES := filesystem-mt filesystem system-mt system
LIBS := $(foreach N,$(LIBNAMES),$(LIB)libboost_$N.a $(LIB)libboost_$N.dylib)
I'm trying to compile gdis on osx el capitan.
Downloaded the gdis version available from developer, but once i click the executable of the release version, nothing happens.
So, i've followed the developer instructions, compiling CVS and Perl (from homebrew), to get the development version, executing this from terminal:
Blockquote
cvs -d:pserver:anonymous#gdis.cvs.sourceforge.net:/cvsroot/gdis login
Hit enter at the password prompt, then type:
cvs -z3 -d:pserver:anonymous#gdis.cvs.sourceforge.net:/cvsroot/gdis co gdis
which should create a folder called gdis containing all the source files.
Enter the gdis subdirectory and run the install script, which should automatically compile gdis based on your preferences.
It should also inform you of missing libraries that must be installed.
Blockquote
running the install script, which is inside Macintosh HD/Users/nBogoni/gdis, it renders the following message:
Checking pre-requisite packages.
gtk+-2.0 [ok]
gtkglext-1.0 [ok]
Compiling [gdis] ... [failed] check install.log
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
[Process completed]
Checking the install.log file, it says:
Must specify package names on the command line
makefile:4: makefile.osx: No such file or directory
makefile:5: makefile.src: No such file or directory
makefile:18: makefile.other: No such file or directory
make: *** No rule to make target `makefile.other'. Stop.
This is what I have inside the makefile.osx, inside Macintosh HD/Users/nBogoni/gdis
# --- gdis Makefile for OS-X
CC = gcc
#CFLAGS = -O2 -no-cpp-precomp
CFLAGS = -O2
INCS := $(INCS) -I/System/Library/Frameworks/OpenGL.framework/Headers
LIBS := $(LIBS) -L/System/Library/Frameworks/OpenGL.framework/Libraries
inside the makefile.src on gdis folder, inside Macintosh HD/Users/nBogoni/gdis
# --- gdis Makefile sources
SRC = main.c model.c coords.c connect.c matrix.c task.c \
type.c measure.c parse.c edit.c elem.c select.c surface.c \
analysis.c spatial.c render.c numeric.c project.c grid.c \
molsurf.c hirshfeld.c zone.c contents.c quaternion.c zmatrix.c \
library.c geometry.c space.c sginfo.c sgclib.c sgio.c error.c \
scan.c camera.c defect.c colourlib.c mdi.c \
mesch.c mesch_core.c host.c command.c undo.c count.c \
ff.c ff_gulp.c scalar.c animate.c test.c \
file.c file_cif.c file_gulp.c file_gmf.c file_marvin.c file_xtl.c \
file_arc.c file_xyz.c file_siesta.c file_gms.c file_diff.c file_xml.c \
file_abinit.c file_pdb.c file_povray.c file_nwchem.c file_castep.c \
file_gauss.c file_rietica.c file_geomview.c file_cssr.c file_cel.c \
file_dmol.c file_dlpoly.c file_bgf.c file_cgf.c file_dlp.c \
file_gromacs.c file_meta.c file_aims.c file_gauss_cube.c \
file_pwscf.c file_xsf.c file_openmx.c file_reaxmd.c \
import.c graph.c grisu_client.c
ifeq ($(USE_GUI), YES)
SRC := $(SRC) gui_main.c gui_canvas.c gui_shorts.c \
gl_main.c gl_primitives.c gl_stereo.c gl_graph.c gl_varray.c \
gui_gulp.c gui_siesta.c gui_render.c gui_mdi.c gui_animate.c \
gui_edit.c gui_surface.c gui_analysis.c gui_defect.c gui_nwchem.c \
gui_molsurf.c gui_diffract.c gui_gms.c gui_library.c gui_setup.c \
gui_gperiodic.c gui_space.c gui_measure.c gui_symmetry.c gui_zmatrix.c \
gui_dialog.c gui_tree.c gui_task.c gui_help.c gui_job.c \
dock.c image.c gui_grid.c gui_project.c
endif
ifeq ($(USE_GRISU), YES)
SRC := $(SRC) stdsoap2.c soapC.c soapClient.c logging.c grid_certificates.c \
py_login.c
# jni_grisu.c
endif
and the makefile.other, also inside Macintosh HD/Users/nBogoni/gdis
.PHONY: clean
clean:
/bin/rm -f $(OBJ) gdis
/bin/rm -fr gdis.app
/bin/rm -f gdis.dmg
.PHONY: tgz
tgz:
tar -czvf gdis-source.tgz \
install makefile makefile.* \
README CHANGELOG TODO GPL.txt gdis.manual gdis.elements gdis.library \
*.c *.h *.xpm grisu.wsdl grisu*.nsmap;
.PHONY: zip
zip:
zip gdis-source.zip \
install makefile makefile.* \
README CHANGELOG TODO GPL.txt gdis.manual gdis.elements gdis.library \
*.c *.h *.xpm grisu.wsdl grisu*.nsmap;
.PHONY: binzip
binzip:
zip -r gdis-bin.zip \
gdis gdis.elements gdis.library gdis.manual lib/init.jar lib/sggc.jar
Could someone help me solving this, since I'm new to mac terminal.
Thanks a lot!
Well, to this problem, the solution I found was to run the following command inside the installation directory.
./install all
Than with that, the install file could locate the makefiles.
Thanks anyway, even if no one got interested in helping me.
I need to compile VASP 5.3.5 on a Cray XC MPP machine. The system has the Gnu, Intel and Cray compiling environments available. There is also a choice of Intel MKL or Cray LibSci for BLAS, LAPACK, ScaLAPCK.
Which is the best compiler to use, the best numerical library to use and the Makefile options to use?
Tests on ARCHER (http://www.archer.ac.uk) have shown that using the Intel compiler with Intel MKL and FFTW produce the best performance and the most stable build of VASP 5.3.5 on the Cray XC30 system.
Full compilation instructions can be found at:
http://www.archer.ac.uk/documentation/software/vasp/compiling_5-3-5-phase2.php
Briefly, the procedure is:
module swap PrgEnv-cray PrgEnv-intel
module load fftw
module load cray-pe-hugepages2M
Modify the library makefile to have the following options:
CPP = gcc -E -P -C $*.F >$*.f
FC=ftn
CFLAGS = -O3
FFLAGS = -O3 -unroll -ip -no-prec-div -xAVX
FREE = -free
Build the library (assuming makefile is called "makefile.cray_xc_intel.lib"):
cd vasp.5.lib
make -f makefile.cray_xc_intel.lib
Move to the main source code directory:
cd ../vasp.5.3
Setup the preprocessor options in the Makefile (this is for the multiple K-points version):
CPP = $(CPP_) -DMPI -DHOST=\"CrayXC-Intel\" \
-DNGZhalf \
-DLONGCHAR \
-Dkind8 \
-DCACHE_SIZE=2000 \
-Davoidalloc \
-DRPROMU_DGEMV \
-DMPI_BLOCK=100000 \
-Duse_collective \
-Drandom_array \
-DscaLAPACK
Set the makefile compilation options:
FC=ftn
FCL=$(FC)
CPP_ = ./preprocess <$*.F | cpp -P -C -traditional >$*$(SUFFIX)
FFLAGS = -free -march=corei7-avx -assume byterecl -m64
OFLAG = -O3 -ip -fno-alias -unroll-aggressive -opt-prefetch -use-intel-optimized-headers -no-prec-div
OFLAG_LOW = -O1 -g -ftz
OBJ_LOW = broydon.o
Set the makefile linear algebra library options for Intel MKL:
MKL_PATH = $(MKLROOT)/lib/intel64
BLAS=
LAPACK=
BLACS=
SCA=
LIB = ../vasp.5.lib/linpack_double.o -L../vasp.5.lib -ldmy \
${MKL_PATH}/libmkl_blas95_lp64.a ${MKL_PATH}/libmkl_lapack95_lp64.a \
${MKL_PATH}/libmkl_scalapack_lp64.a \
-Wl,--start-group ${MKL_PATH}/libmkl_intel_lp64.a \
${MKL_PATH}/libmkl_sequential.a ${MKL_PATH}/libmkl_core.a \
${MKL_PATH}/libmkl_blacs_intelmpi_lp64.a -Wl,--end-group -lpthread -lm
Finally, set the makefile options for linking FFTW:
FFT3D = fftmpiw.o fftmpi_map.o fftw3d.o fft3dlib.o
Now build the code (assuming makefile is called "makefile.cray_xc_intel"):
make -f makefile.cray_xc_intel
When I run 'make', in a project with autotools and libtool, the library is builded correctly, but the executable is not created in its path. This is the line generated by automake:
/bin/bash ../libtool --tag=CXX --mode=link g++ -g -O0 -o foo foo-foo.o ../libfoo/src/libfoo.la
This line doesn't print anything (even errors). There is something wrong with this Makefile.am?
bin_PROGRAMS=foo
foo_SOURCES= \
foo.cc
foo_CPPFLAGS = \
-I$(top_srcdir)/libfoo/include \
-DLOCALEDIR=\"$(localedir)\"
foo_LDADD = \
../libfoo/src/libfoo.la \
$(LIBINTL)