How to build a windows static library for lesson15 under windows platform? - halide

I have successful built the LLVM and Halide with Visual studio 2019 on windows platform.
I then tried to make some no_runtime objs and a halide_runtime obj and link them together.
./lesson_15_generate \
-g my_first_generator \
-f my_first_generator_basic \
-e object,c_header\
-o . \
target=x86-64-windows-no_runtime
./lesson_15_generate \
-g my_first_generator \
-f my_first_generator_sse41 \
-e object,c_header\
-o . \
target=host-x86-64-windows-sse41-no_runtime
./lesson_15_generate \
-g my_first_generator \
-f my_first_generator_avx \
-e object,c_header\
-o . \
target=host-x86-64-windows-avx-no_runtime
./lesson_15_generate \
-r halide_runtime_x86 \
-e object,c_header\
-o . \
target=x86-64-windows
The windows static library was linked as follows
prompt>link.exe /out:test.lib halide_runtime_x86.obj
my_first_generator_basic.obj my_first_generator_sse41.obj
my_first_generator_avx.obj
However, the system returned with the following error
Microsoft (R) Incremental Linker Version 14.26.28806.0
Copyright (C) Microsoft Corporation. All rights reserved.
LINK : fatal error LNK1561: entry point must be defined
Please, shed some light on how to build a static halide library on windows platform.
Problem solved by adding /lib to link.exe
prompt>link.exe /lib /out:test.lib halide_runtime_x86.obj
my_first_generator_basic.obj my_first_generator_sse41.obj
my_first_generator_avx.obj

add /lib to link.exe
prompt>link.exe /lib /out:test.lib halide_runtime_x86.obj
my_first_generator_basic.obj my_first_generator_sse41.obj
my_first_generator_avx.obj

Related

Automake LibSocketCan

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

make/gcc/clang looking for file with a blank filename, gives error

I have OSX 10.11.4, Xcode 7.3.1.
Using make -- calls gcc -- calls clang, I get this error where clang is looking for a file whose name is a space!
Make error 1: clang: error: no such file or directory: ' '.
That is a space!
I have no idea how to fix this. The makefile formatting is correct.
Here is the end of the output from make:
gcc -g -v -Wall -I/usr/local/include -I/opt/local/include -I/Users/m/BioPrep \
-o mod \
../mshell/runit0.o \
../mshell/tline.o \
../mshell/getshm.o \
../mshell/callLSODA.o \
../mshell/extras.o \
../mshell/nrutil.o \
../mshell/exten.o \
../choosedisp/choosedisp_main.o \
../choosedisp/choosedisp_cb.o \
../choosedisp/choosedisp_fm.o \
../connectdisps/connectdisps.o \
../connectdisps/opwsock.o \
Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
clang: error: no such file or directory: ' '
make: *** [mod] Error 1
======================= Here is the contents of the Makefile:
# This is Makefile with all graphics code removed so that a compilation of mod can proceed
# "MakefileA" has the graphics files present but commented (#) out
CC = gcc
CFLAGS = -g -v -Wall
INCL = -I/usr/local/include -I/opt/local/include -I/Users/prowat/BioPrep
LIBS = -L/usr/local/lib -L/opt/local/lib -lX11 -lforms
mod: model.o \
../mshell/runit0.o \
../mshell/tline.o \
../mshell/getshm.o \
../mshell/callLSODA.o \
../mshell/extras.o \
../mshell/nrutil.o \
../mshell/exten.o \
../choosedisp/choosedisp_main.o \
../choosedisp/choosedisp_cb.o \
../choosedisp/choosedisp_fm.o \
../connectdisps/connectdisps.o \
../connectdisps/opwsock.o \
../lsoda/liblsoda.a`
cd ../mshell; make objs`
cd ../choosedisp; make objs`
cd ../connectdisps; make objs`
$(CC) $(CFLAGS) $(INCL) \
-o mod \
../mshell/runit0.o \
../mshell/tline.o \
../mshell/getshm.o \
../mshell/callLSODA.o \
../mshell/extras.o \
../mshell/nrutil.o \
../mshell/exten.o \
../choosedisp/choosedisp_main.o \
../choosedisp/choosedisp_cb.o \
../choosedisp/choosedisp_fm.o \
../connectdisps/connectdisps.o \
../connectdisps/opwsock.o \
model.o \
-L../lsoda -llsoda \
$(LIBS) \
-lm
=====================
Please use proper formatting: for code blocks, indent by 4 spaces. The backticks are only used for fixed-width fonts inside normal text.
You may have looked for spaces, but you need to look again. Based on the output make has shown you versus your makefile, it's pretty clear that there is at least one space after the backslash at the end of this line:
../connectdisps/opwsock.o \
You can tell this because if there were no spaces after this backslash then it would be continuing to the next line and make whould show the rest of the compile line:
model.o \
-L../lsoda -llsoda \
$(LIBS) \
-lm
Since those lines are missing from the output make provided, you can be sure that there's something about the opwsock.o line which is preventing make from recognizing the backslash/newline at the end.

Must specify package names on the command line

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.

libtool did not generate a lo file when everything is there

I'm new to using libtool. However, this problem seems to be weird. Everything is there but the libtool said "libtool: link: 'cuda_transfer.lo' is not a valid libtool object". However, the rule for generating this lo file is right there in the Makefile. Besides, the two header files are also right in where they are supposed to be and do work. Any idea about what is going wrong?
cuda_transfer.lo: particles_cuda.h ../../include/psc_particles_cuda.h
The other two places in Makefile where cuda_transfer.lo appeared are followed
libsubdir_la_DEPENDENCIES = cuda_transfer.lo \
libsubdir_la_LIBADD = \
cuda_transfer.lo \
The .c.lo: segment is following:
.c.lo:
$(AM_V_CC)depbase=`echo $# | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
$(LTCOMPILE) -MT $# -MD -MP -MF $$depbase.Tpo -c -o $# $< &&\
$(am__mv) $$depbase.Tpo $$depbase.Plo
# $(AM_V_CC)source='$<' object='$#' libtool=yes \
# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
# $(AM_V_CC_no)$(LTCOMPILE) -c -o $# $<
How to interpret this human-unfriendly code. = =
Below is the code segment suggested by Brett.
noinst_LTLIBRARIES = libsubdir.la
libsubdir_la_SOURCES = \
psc_fields_cuda.c \
psc_particles_cuda.c \
psc_push_particles_cuda.c \
psc_push_fields_cuda.c \
psc_bnd_cuda.c \
psc_bnd_particles_cuda.c \
psc_bnd_fields_cuda.c \
b40c/kernel_utils.h \
b40c/radixsort_kernel_common.h \
b40c/radixsort_key_conversion.h \
b40c/radixsort_reduction_kernel.h \
b40c/radixsort_scanscatter_kernel.h \
b40c/radixsort_scanscatter_kernel3.h \
b40c/radixsort_scanscatter_kernel4.h \
b40c/radixsort_spine_kernel.h \
b40c/vector_types.h \
cuda_common.h \
cuda_sort2.h \
cuda_sort2_spine.h \
particles_cuda.h \
psc_bnd_cuda.h \
psc_bnd_cuda_fields.h \
psc_cuda.h
libsubdir_la_LIBADD = \
cuda_transfer.lo \
cuda_spine.lo \
cuda_sort2.lo \
cuda_sort3.lo \
cuda_exchange_particles.lo \
cuda_exclusive_scan_2.lo \
cuda_push_part_yz_1vb.lo
The only thing that looks like a generating rule about cuda_transfer.lo is
cuda_transfer.lo: particles_cuda.h ../../include/psc_particles_cuda.h
try this:
yum -y install libtool*
then make clean and restart again
Well, it's better not to read configure.ac ever :-) But if you still wish, configure.ac is a combination of m4 preprocessor code and ordinary (bourne) shell snippets. You may check info m4 and info autoconf, the docs are pretty decent.
The hard part of your question, regarding the .lo file. It seems that your makefile contains dependency chain for it, but no explicit build-rules. You may try to locate a common rule for compiling .c -> .lo, like this:
.c.lo:
$(AM_V_CC)$(LTCOMPILE) -MT $# -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $# $<
$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
...
Install latest libtool. Delete the .lo file and use 'make' again.

Problems compiling ffmpeg on windows using cygwin

I've been having a lot of trouble recently compiling ffmpeg on windows. I'm currently using the cgywin terminal to run the code. I've tried following many of the most popular tutorials on the web but I can't seem to get it to work. I'm currently using this tutorial as a guide http://www.roman10.net/how-to-build-ffmpeg-for-android/
Where I'm at:
I've created a bash script
#!/bin/bash
NDK=C:/Users/jrblain/Development/adt-bundle-windows-x86_64-20130514/android-ndk-r9
PLATFORM=$NDK/platforms/android-8/arch-arm/
PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64
function build_one
{
./configure --target-os=linux \
--prefix=$PREFIX \
--enable-cross-compile \
--extra-libs="-lgcc" \
--arch=arm \
--cc=$PREBUILT/bin/arm-linux-androideabi-gcc \
--cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \
--nm=$PREBUILT/bin/arm-linux-androideabi-nm \
--sysroot=$PLATFORM \
--extra-cflags=" -O3 -fpic -DANDROID -DHAVE_SYS_UIO_H=1 -Dipv6mr_interface=ipv6mr_ifindex -fasm -Wno-psabi -fno-short-enums -fno-strict-aliasing -finline-limit=300 $OPTIMIZE_CFLAGS " \
--disable-shared \
--enable-static \
--extra-ldflags="-Wl,-rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -nostdlib -lc -lm -ldl -llog" \
--disable-everything \
--enable-demuxer=mov \
--enable-demuxer=h264 \
--disable-ffplay \
--enable-protocol=file \
--enable-avformat \
--enable-avcodec \
--enable-decoder=rawvideo \
--enable-decoder=mjpeg \
--enable-decoder=h263 \
--enable-decoder=mpeg4 \
--enable-decoder=h264 \
--enable-parser=h264 \
--disable-network \
--enable-zlib \
--disable-avfilter \
--disable-avdevice \
$ADDITIONAL_CONFIGURE_FLAG
make clean
make -j4 install
$PREBUILT/bin/arm-linux-androideabi-ar d libavcodec/libavcodec.a inverse.o
$PREBUILT/bin/arm-linux-androideabi-ld -rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -soname libffmpeg.so -shared -nostdlib -z,noexecstack -Bsymbolic --whole-archive --no-undefined -o $PREFIX/libffmpeg.so libavcodec/libavcodec.a libavformat/libavformat.a libavutil/libavutil.a libswscale/libswscale.a -lc -lm -lz -ldl -llog --warn-once --dynamic-linker=/system/bin/linker $PREBUILT/lib/gcc/arm-linux-androideabi/4.4.3/libgcc.a
}
#arm v6
#CPU=armv6
#OPTIMIZE_CFLAGS="-marm -march=$CPU"
#PREFIX=./android/$CPU
#ADDITIONAL_CONFIGURE_FLAG=
#build_one
#arm v7vfpv3
CPU=armv7-a
OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=vfpv3-d16 -marm -march=$CPU "
PREFIX=./android/$CPU
ADDITIONAL_CONFIGURE_FLAG=
build_one
#arm v7vfp
#CPU=armv7-a
#OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=vfp -marm -march=$CPU "
#PREFIX=./android/$CPU-vfp
#ADDITIONAL_CONFIGURE_FLAG=
#build_one
#arm v7n
#CPU=armv7-a
#OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=neon -marm -march=$CPU -mtune=cortex-a8"
#PREFIX=./android/$CPU
#ADDITIONAL_CONFIGURE_FLAG=--enable-neon
#build_one
#arm v6+vfp
#CPU=armv6
#OPTIMIZE_CFLAGS="-DCMP_HAVE_VFP -mfloat-abi=softfp -mfpu=vfp -marm -march=$CPU"
#PREFIX=./android/${CPU}_vfp
#ADDITIONAL_CONFIGURE_FLAG=
#build_one
I then followed steps 4-6 of this post Does anyone find this useful? - Compiling FFMPEG on Windows with Cywin and NDK r5 which consists of
4 - Open the file 'configure' in the root of the FFMPEG directory in a text editor.
5 - Comment out lines 2073, 2074 and 2075.
6 - Below 2075, add the following line:
TMPDIR=c:/cygwin/tmp
When I ran the script in cgywin I got this result:
install prefix ./android/armv7-a
source path .
C compiler C:/Users/jrblain/Development/adt-bundle-windows-x86_64-20130514/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/arm-linux-androideabi-gcc
ARCH arm (armv7-a)
big-endian no
runtime cpu detection yes
ARMv5TE enabled yes
ARMv6 enabled yes
ARMv6T2 enabled yes
VFP enabled yes
NEON enabled yes
THUMB enabled no
debug symbols yes
strip symbols yes
optimize for size no
optimizations yes
static yes
shared no
postprocessing support no
new filter support no
network support no
threading support pthreads
safe bitstream reader yes
SDL support no
opencl enabled no
texi2html enabled no
perl enabled no
pod2man enabled no
makeinfo enabled no
External libraries:
zlib
Enabled decoders:
h263 mjpeg rawvideo
h264 mpeg4
Enabled encoders:
Enabled hwaccels:
Enabled parsers:
h263 h264 mpeg4video
Enabled demuxers:
h264 mov
Enabled muxers:
Enabled protocols:
file
Enabled filters:
Enabled bsfs:
Enabled indevs:
Enabled outdevs:
License: LGPL version 2.1 or later
Creating config.mak, config.h, and doc/config.texi...
libavutil/avconfig.h is unchanged
WARNING: C:/Users/jrblain/Development/adt-bundle-windows-x86_64-20130514/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/arm-linux-androideabi-pkg-config not found, library detection may fail.
library.mak:105: *** missing separator. Stop.
library.mak:105: *** missing separator. Stop.
C:\Users\jrblain\Development\adt-bundle-windows-x86_64-20130514\android-ndk-r9\toolchains\arm-linux-androideabi-4.6\prebuilt\windows-x86_64\bin\arm-linux-androideabi-ld.exe: ,noexecstack: unknown -z option
C:\Users\jrblain\Development\adt-bundle-windows-x86_64-20130514\android-ndk-r9\toolchains\arm-linux-androideabi-4.6\prebuilt\windows-x86_64\bin\arm-linux-androideabi-ld.exe: use the --help option for usage information
After this script runs I get some new files within my ffmpeg folder. They are .config, config(header), config.mak , config.fate. The android folder is never created like it is supposed to. I'm also not sure where the library.mak error is coming from considering that it came with ffmpeg download.
I'm not sure where this i'm going wrong in all of this. I feel like the fact that I'm using windows will make this build process different.
The first error say "WARNING: C:/.../arm-linux-androideabi-pkg-config not found, library detection may fail." So I suggest to fix the path.
'C:/' is not a POSIX path. Cygwin programs are able to translate it (with a warning).
cd 'c:' # works. cd is a built-in command
ls 'c:' # doesn't work
ls 'c:/' # works (edited)
The documentation about how the Cygwin maps POSIX- and Win32-style paths.
From my experience you have issue when you mix slashs and back-slashs or when you call Windows native command from Cygwin. Example:
javac -cp "$(cygpath -pw "$CLASSPATH")" hello.java
In my opinion, you should hardcode a POSIX path, or use the following command:
cygpath -u 'c:' # the relevant command provided by Cygwin
(cd 'c:' && pwd) # a tip, useful if you want a portable syntax
But maybe I am complety wrong. I suppose you already check the path
ls 'C:/Users/jrblain/Development/adt-bundle-windows-x86_64-20130514/android-ndk-r9/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/arm-linux-androideabi-pkg-config'
And I supppose you already check the line 105 of your mk file (tabulation and linux line feed).

Resources