I have been trying for some time to compile and link the OpenBLAS lib to multiply to matrices together using dgemm. I finally was able to compile the OpenBLAS after installing MSYS2 and the mingw64 packages from MSYS2 using pacman. My intention is to use the OpenBLAS as a static lib. So I wrote a simple fortran code to multiply the matrices together using dgemm. Here is the fortran code:
program gcc_fun
implicit none
! Variables
real*8 x(2,2),y(2,2),z(2,2)
x(1,1) = 3.d0
x(2,1) = 2.d0
x(1,2) = 1.d0
x(2,2) = 4.d0
y(1,1) = .5d0
y(2,1) = 1.d0
y(1,2) = 2.d0
y(2,2) = .75d0
call dgemm( 'n', 'n', 2, 2, 2, 1,x,2,y, 2, 1, z, 1)
! Body of gcc_fun
print *, 'Z = ', z
end program gcc_fun
Here is my makefile to try and link:
CCC = gcc -g -Iincludem -Iincludev -c -O0
WARN = -Wall
CCCX = x86_64-w64-mingw32-g++ -m64 -s -Iincludem -Iincludev -c -O2 -DNDEBUG
fort = x86_64-w64-mingw32-gfortran -s -Iincludem -Iincludev -fno-underscoring -c -O2 -DNDEBUG
#fort = x86_64-w64-mingw32-gfortran -s -Iincludem -Iincludev -c -O2 -DNDEBUG
OBJECTS = \
obj/gcc_fun.o
#-----------------------------------------------------------------------------------
# Make the Guidance Object Library (GNC_Lib.a) and the Executable (guideUnitTest)
#-----------------------------------------------------------------------------------
gcc_fun.exe: $(OBJECTS)
x86_64-w64-mingw32-gfortran -o gcc_fun.exe -L./ -lopenblas_haswell-r0.3.10 $(OBJECTS)
#------------------------------------------
# object file targets
#------------------------------------------
obj/gcc_fun.o: \
gcc_fun.f90
$(fort) $(WARN) -o $# gcc_fun.f90
I run the make file with make -f makefile_name and get unresolved reference to dgemm. I have tried it with and without the no-underscoring option to no avail. Here is the actual error:
$ make -f Makefile_gcc_fun.mak
x86_64-w64-mingw32-gfortran -s -Iincludem -Iincludev -fno-underscoring -c -O2 -DNDEBUG -Wall -o obj/gcc_fun.o gcc_fun.f90
f951.exe: Warning: Nonexistent include directory 'includem' [-Wmissing-include-dirs]
f951.exe: Warning: Nonexistent include directory 'includev' [-Wmissing-include-dirs]
gcc_fun.f90:27:2:
27 | x(2,1) = 2.d0
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
gcc_fun.f90:28:2:
28 | x(1,2) = 1.d0
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
gcc_fun.f90:29:2:
29 | x(2,2) = 4.d0
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
gcc_fun.f90:31:2:
31 | y(2,1) = 1.d0
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
gcc_fun.f90:32:2:
32 | y(1,2) = 2.d0
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
gcc_fun.f90:33:2:
33 | y(2,2) = .75d0
| 1
Warning: Nonconforming tab character at (1) [-Wtabs]
x86_64-w64-mingw32-gfortran -o gcc_fun.exe -L./ -lopenblas_haswell-r0.3.10 obj/gcc_fun.o
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: obj/gcc_fun.o:gcc_fun.f90:(.text+0xf5): undefined reference to `dgemm'
collect2.exe: error: ld returned 1 exit status
make: *** [Makefile_gcc_fun.mak:19: gcc_fun.exe] Error 1
When I inspect the OpenBLAS library with nm I get this:
$ nm -g libopenblas_haswell-r0.3.10.a | grep dgemm
dgemm.obj:
0000000000000000 T dgemm_
So it looks like dgemm is an external object and I should be able to call it. I am sure I am missing something easy so thanks for any help.
The subroutine is just dgemm, not dgemm_. You just call it
call dgemm()
The symbol name you see using nm can differ depending on your toolchain (compiler, operating system,...). It matters if you do interoperability of different programming languages. However, if you stay within Fortran, you do not need to worry without it.
Important:
The static library being linked should be placed after the file that uses the library in the linking command. Only then the dependecies can be resolved. If this is the actual issue, we will have some duplicates to link to.
Related
my project need cross compile for arm aarch64 on ubuntu x86_64, but failed at configure stage, below is log
log
# Execution platform: //platforms:linux_gcc9_aarch64
SUBCOMMAND: # #boost//:filesystem [action 'Linking external/boost/libfilesystem.so', configuration: fc89852de14da3c51e8226c7c5e3087929e4f56710d05ed9ab86ed21b8eb16d4, execution platform: //platforms:linux_gcc9_aarch64]
(cd /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo && \
exec env - \
PATH=/root/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/go/bin:/root/src/go/bin:/usr/local/jdk-11.0.15/bin:/root/.ft:/data/.cache/npm/global/bin \
PWD=/proc/self/cwd \
external/gcc9_arm_aarch64/bin/aarch64-none-linux-gnu-gcc -shared -o bazel-out/k8-fastbuild/bin/external/boost/libfilesystem.so bazel-out/k8-fastbuild/bin/external/boost/_objs/filesystem/codecvt_error_category.o bazel-out/k8-fastbuild/bin/external/boost/_objs/filesystem/directory.o bazel-out/k8-fastbuild/bin/external/boost/_objs/filesystem/exception.o bazel-out/k8-fastbuild/bin/external/boost/_objs/filesystem/operations.o bazel-out/k8-fastbuild/bin/external/boost/_objs/filesystem/path.o bazel-out/k8-fastbuild/bin/external/boost/_objs/filesystem/path_traits.o bazel-out/k8-fastbuild/bin/external/boost/_objs/filesystem/portability.o bazel-out/k8-fastbuild/bin/external/boost/_objs/filesystem/unique_path.o bazel-out/k8-fastbuild/bin/external/boost/_objs/filesystem/utf8_codecvt_facet.o bazel-out/k8-fastbuild/bin/external/boost/_objs/filesystem/windows_file_codecvt.o -Wl,-S -lstdc++ -lm -Wl,-no-as-needed -Wl,-z,relro,-z,now -Wall -pass-exit-codes '-fuse-ld=gold')
# Configuration: fc89852de14da3c51e8226c7c5e3087929e4f56710d05ed9ab86ed21b8eb16d4
# Execution platform: //platforms:linux_gcc9_aarch64
ERROR: /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/external/rules_foreign_cc/toolchains/BUILD.bazel:130:10: BootstrapGNUMake external/rules_foreign_cc/toolchains/make failed: (Exit 1): bash failed: error executing command
(cd /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo && \
exec env - \
PATH=/root/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/go/bin:/root/src/go/bin:/usr/local/jdk-11.0.15/bin:/root/.ft:/data/.cache/npm/global/bin \
/bin/bash -c bazel-out/k8-opt-exec-277332AD/bin/external/rules_foreign_cc/toolchains/make_tool_foreign_cc/wrapper_build_script.sh)
# Configuration: 920514b75167e08aaf5b08b6fc5ff1721a7e3be841d2c442cd3624a15e568e52
# Execution platform: //platforms:linux_gcc9_aarch64
rules_foreign_cc: Build failed!
rules_foreign_cc: Keeping temp build directory and dependencies directory for debug.
rules_foreign_cc: Please note that the directories inside a sandbox are still cleaned unless you specify --sandbox_debug Bazel command line flag.
rules_foreign_cc: Printing build logs:
_____ BEGIN BUILD LOGS _____
+ AR=/root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/external/gcc9_arm_aarch64/bin/aarch64-none-linux-gnu-gcc-ar
+ ARFLAGS=rcsD
+ CC=/root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/external/gcc9_arm_aarch64/bin/aarch64-none-linux-gnu-gcc
+ CFLAGS='-fPIC -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -march=armv8-a -g0 -O3 -DNDEBUG -D_FORTIFY_SOURCE=2 -ffunction-sections -fdata-sections -funsafe-math-optimizations -ftree-vectorize -std=c99 -no-canonical-prefixes -fno-canonical-system-headers -Wno-builtin-macro-redefined -D__DATE__=redacted -D__TIMESTAMP__=redacted -D__TIME__=redacted'
+ LD=/root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/external/gcc9_arm_aarch64/bin/aarch64-none-linux-gnu-gcc
+ LDFLAGS='-lstdc++ -lm -Wl,-no-as-needed -Wl,-z,relro,-z,now -Wall -pass-exit-codes -fuse-ld=gold -Wl,--gc-sections'
+ ./configure --without-guile --with-guile=no --disable-dependency-tracking --prefix=/root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/bazel-out/k8-opt-exec-277332AD/bin/external/rules_foreign_cc/toolchains/make
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports the include directive... yes (GNU style)
checking for gcc... /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/external/gcc9_arm_aarch64/bin/aarch64-none-linux-gnu-gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... configure: error: in `/root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/bazel-out/k8-opt-exec-277332AD/bin/external/rules_foreign_cc/toolchains/make.build_tmpdir':
config.log
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by gperftools configure 2.9.1, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/external/com_github_gperftools_gperftools/configure --prefix=/root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/bazel-out/k8-fastbuild/bin/external/com_github_gperftools_gperftools/gperftools_build.build_tmpdir/gperftools_build --enable-shared=no --enable-frame-pointers --disable-libunwind
## --------- ##
## Platform. ##
## --------- ##
hostname = ubuntu
uname -m = x86_64
uname -r = 5.4.0-109-generic
uname -s = Linux
uname -v = #123-Ubuntu SMP Fri Apr 8 09:10:54 UTC 2022
/usr/bin/uname -p = unknown
/bin/uname -X = unknown
/bin/arch = unknown
/usr/bin/arch -k = unknown
/usr/convex/getsysinfo = unknown
/usr/bin/hostinfo = unknown
/bin/machine = unknown
/usr/bin/oslevel = unknown
/bin/universe = unknown
PATH: /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/bazel-out/k8-fastbuild/bin/external/com_github_gperftools_gperftools/gperftools_build.ext_build_deps/bin
PATH: /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo
PATH: /root/.cargo/bin
PATH: /usr/local/sbin
PATH: /usr/local/bin
PATH: /usr/sbin
PATH: /usr/bin
PATH: /sbin
PATH: /bin
PATH: /usr/games
PATH: /usr/local/games
PATH: /snap/bin
PATH: /usr/local/go/bin
PATH: /root/src/go/bin
PATH: /usr/local/jdk-11.0.15/bin
PATH: /root/.ft
PATH: /data/.cache/npm/global/bin
PATH: /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/bazel-out/k8-fastbuild/bin/external/com_github_gperftools_gperftools/gperftools_build.ext_build_deps/bin/toolchains
## ----------- ##
## Core tests. ##
## ----------- ##
configure:2617: checking build system type
configure:2631: result: x86_64-pc-linux-gnu
configure:2651: checking host system type
configure:2664: result: x86_64-pc-linux-gnu
configure:2700: checking for a BSD-compatible install
configure:2768: result: /usr/bin/install -c
configure:2779: checking whether build environment is sane
configure:2834: result: yes
configure:2978: checking for a thread-safe mkdir -p
configure:3017: result: /bin/mkdir -p
configure:3024: checking for gawk
configure:3040: found /usr/bin/gawk
configure:3051: result: gawk
configure:3062: checking whether /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/bazel-out/k8-opt-exec-2B5CBBC6/bin/external/rules_foreign_cc/toolchains/make/bin/make sets $(MAKE)
configure:3084: result: yes
configure:3113: checking whether /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/bazel-out/k8-opt-exec-2B5CBBC6/bin/external/rules_foreign_cc/toolchains/make/bin/make supports nested variables
configure:3130: result: yes
configure:3260: checking whether to enable maintainer-specific portions of Makefiles
configure:3269: result: no
configure:3296: checking for git
configure:3314: found /usr/local/bin/git
configure:3327: result: /usr/local/bin/git
configure:3400: checking whether /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/bazel-out/k8-opt-exec-2B5CBBC6/bin/external/rules_foreign_cc/toolchains/make/bin/make supports the include directive
configure:3415: /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/bazel-out/k8-opt-exec-2B5CBBC6/bin/external/rules_foreign_cc/toolchains/make/bin/make -f confmf.GNU && cat confinc.out
this is the am__doit target
configure:3418: $? = 0
configure:3437: result: yes (GNU style)
configure:3507: checking for gcc
configure:3534: result: /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/external/gcc9_arm_aarch64/bin/aarch64-none-linux-gnu-gcc
configure:3763: checking for C compiler version
configure:3772: /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/external/gcc9_arm_aarch64/bin/aarch64-none-linux-gnu-gcc --version >&5
aarch64-none-linux-gnu-gcc (GNU Toolchain for the A-profile Architecture 9.2-2019.12 (arm-9.10)) 9.2.1 20191025
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
configure:3783: $? = 0
configure:3772: /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/external/gcc9_arm_aarch64/bin/aarch64-none-linux-gnu-gcc -v >&5
Using built-in specs.
COLLECT_GCC=/root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/external/gcc9_arm_aarch64/bin/aarch64-none-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/external/gcc9_arm_aarch64/bin/../libexec/gcc/aarch64-none-linux-gnu/9.2.1/lto-wrapper
Target: aarch64-none-linux-gnu
Configured with: /tmp/dgboter/bbs/rhev-vm2--rhe6x86_64/buildbot/rhe6x86_64--aarch64-none-linux-gnu/build/src/gcc/configure --target=aarch64-none-linux-gnu --prefix= --with-sysroot=/aarch64-none-linux-gnu/libc --with-build-sysroot=/tmp/dgboter/bbs/rhev-vm2--rhe6x86_64/buildbot/rhe6x86_64--aarch64-none-linux-gnu/build/build-aarch64-none-linux-gnu/install//aarch64-none-linux-gnu/libc --with-bugurl=https://bugs.linaro.org/ --enable-gnu-indirect-function --enable-shared --disable-libssp --disable-libmudflap --enable-checking=release --enable-languages=c,c++,fortran --with-gmp=/tmp/dgboter/bbs/rhev-vm2--rhe6x86_64/buildbot/rhe6x86_64--aarch64-none-linux-gnu/build/build-aarch64-none-linux-gnu/host-tools --with-mpfr=/tmp/dgboter/bbs/rhev-vm2--rhe6x86_64/buildbot/rhe6x86_64--aarch64-none-linux-gnu/build/build-aarch64-none-linux-gnu/host-tools --with-mpc=/tmp/dgboter/bbs/rhev-vm2--rhe6x86_64/buildbot/rhe6x86_64--aarch64-none-linux-gnu/build/build-aarch64-none-linux-gnu/host-tools --with-isl=/tmp/dgboter/bbs/rhev-vm2--rhe6x86_64/buildbot/rhe6x86_64--aarch64-none-linux-gnu/build/build-aarch64-none-linux-gnu/host-tools --enable-fix-cortex-a53-843419 --with-pkgversion='GNU Toolchain for the A-profile Architecture 9.2-2019.12 (arm-9.10)'
Thread model: posix
gcc version 9.2.1 20191025 (GNU Toolchain for the A-profile Architecture 9.2-2019.12 (arm-9.10))
configure:3783: $? = 0
configure:3772: /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/external/gcc9_arm_aarch64/bin/aarch64-none-linux-gnu-gcc -V >&5
aarch64-none-linux-gnu-gcc: error: unrecognized command line option '-V'
aarch64-none-linux-gnu-gcc: fatal error: no input files
compilation terminated.
configure:3783: $? = 1
configure:3772: /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/external/gcc9_arm_aarch64/bin/aarch64-none-linux-gnu-gcc -qversion >&5
aarch64-none-linux-gnu-gcc: error: unrecognized command line option '-qversion'; did you mean '--version'?
aarch64-none-linux-gnu-gcc: fatal error: no input files
compilation terminated.
configure:3783: $? = 1
configure:3803: checking whether the C compiler works
configure:3825: /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/external/gcc9_arm_aarch64/bin/aarch64-none-linux-gnu-gcc -fPIC -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -std=c99 -no-canonical-prefixes -fno-canonical-system-headers -Wno-builtin-macro-redefined -D__DATE__=redacted -D__TIMESTAMP__=redacted -D__TIME__=redacted -lstdc++ -lm -Wl,-no-as-needed -Wl,-z,relro,-z,now -Wall -pass-exit-codes -fuse-ld=gold -lpthread conftest.c >&5
configure:3829: $? = 0
configure:3877: result: yes
configure:3880: checking for C compiler default output file name
configure:3882: result: a.out
configure:3888: checking for suffix of executables
configure:3895: /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/external/gcc9_arm_aarch64/bin/aarch64-none-linux-gnu-gcc -o conftest -fPIC -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -std=c99 -no-canonical-prefixes -fno-canonical-system-headers -Wno-builtin-macro-redefined -D__DATE__=redacted -D__TIMESTAMP__=redacted -D__TIME__=redacted -lstdc++ -lm -Wl,-no-as-needed -Wl,-z,relro,-z,now -Wall -pass-exit-codes -fuse-ld=gold -lpthread conftest.c >&5
configure:3899: $? = 0
configure:3921: result:
configure:3943: checking whether we are cross compiling
configure:3951: /root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/external/gcc9_arm_aarch64/bin/aarch64-none-linux-gnu-gcc -o conftest -fPIC -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -std=c99 -no-canonical-prefixes -fno-canonical-system-headers -Wno-builtin-macro-redefined -D__DATE__=redacted -D__TIMESTAMP__=redacted -D__TIME__=redacted -lstdc++ -lm -Wl,-no-as-needed -Wl,-z,relro,-z,now -Wall -pass-exit-codes -fuse-ld=gold -lpthread conftest.c >&5
configure:3955: $? = 0
configure:3962: ./conftest
/root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/external/com_github_gperftools_gperftools/configure: line 3964: ./conftest: cannot execute binary file: Exec format error
configure:3966: $? = 126
configure:3973: error: in `/root/.cache/bazel/_bazel_root/dbf178c3b436e7b271af34e78939cab5/execroot/bazel_simple_demo/bazel-out/k8-fastbuild/bin/external/com_github_gperftools_gperftools/gperftools_build.build_tmpdir':
configure:3975: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
bazel toolchain configuration:
toolchain:
http_archive(
name = "gcc9_arm_aarch64",
build_file = "#bazel_build_file_repo//bazel:gcc_arm_aarch64.BUILD",
sha256 = "8dfe681531f0bd04fb9c53cf3c0a3368c616aa85d48938eebe2b516376e06a66",
strip_prefix = "gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu",
#urls = ["https://developer.arm.com/-/media/Files/downloads/gnu-a/9.2-2019.12/binrel/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz"],
urls = ["file:///root/src/cpp/toolchains/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz"],
)
platform config
constraint_setting(name = "gcc_version")
constraint_value(
name = "gcc_9",
constraint_setting = ":gcc_version",
)
constraint_value(
name = "gcc_10",
constraint_setting = ":gcc_version",
)
constraint_value(
name = "gcc_11",
constraint_setting = ":gcc_version",
)
platform(
name = "linux_gcc9_aarch64",
constraint_values = [
"#platforms//cpu:aarch64",
"#platforms//os:linux",
":gcc_9",
],
)
toolchain config
toolchain(
name = "gcc9_arm_aarch64_xcompile_toolchain",
exec_compatible_with = [
"#platforms//cpu:x86_64",
"#platforms//os:linux",
],
target_compatible_with = [
"#platforms//cpu:aarch64",
"#platforms//os:linux",
"//platforms:gcc_9",
],
toolchain = "#gcc9_arm_aarch64//:cc_toolchain",
toolchain_type = "#bazel_tools//tools/cpp:toolchain_type",
)
here is a very tiny demo to reproduce it:
[enter link description here][https://github.com/xiedeacc/bazel_simple_demo.git]
I have been trying for several days to install OpenCV with Conan (on Windows 10). However, the installation is failing on building the libjpeg/9d dependency.
Conan profile:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Debug
compiler=gcc
compiler.libcxx=libstdc++11
compiler.version=8
os=Windows
os_build=Windows
[options]
[build_requires]
[env]
The used command:
conan install .. --profile vslamprofile --build=missing
The part of the logs related to the error:
libjpeg/9d: configure: creating ./config.status
libjpeg/9d: config.status: creating Makefile
libjpeg/9d: config.status: creating libjpeg.pc
libjpeg/9d: config.status: creating jconfig.h
libjpeg/9d: config.status: executing depfiles commands
libjpeg/9d: config.status: error: in /c/users/username/.conan/data/libjpeg/9d/_/_/build/2e90c2fe2f69846019f521f2004427fb191035af':
libjpeg/9d: config.status: error: Something went wrong bootstrapping makefile fragments
libjpeg/9d: for automatic dependency tracking. Try re-running configure with the
libjpeg/9d: '--disable-dependency-tracking' option to at least be able to build
libjpeg/9d: the package (albeit without support for automatic dependency tracking).
libjpeg/9d: See `config.log' for more details
libjpeg/9d: configure: WARNING: cache variable lt_cv_path_LD contains a newline
libjpeg/9d:
libjpeg/9d: ERROR: Package '2e90c2fe2f69846019f521f2004427fb191035af' build failed
libjpeg/9d: WARN: Build folder C:\Users\username\.conan\data\libjpeg\9d\_\_\build\2e90c2fe2f69846019f521f2004427fb191035af
ERROR: libjpeg/9d: Error in build() method, line 100
autotools = self._configure_autotools()
while calling '_configure_autotools', line 88
self._autotools.configure(configure_dir=self._source_subfolder, args=config_args)
ConanException: Error 1 while executing /c/users/username/.conan/data/libjpeg/9d/_/_/build/2e90c2fe2f69846019f521f2004427fb191035af/source_subfolder/configure --prefix=/c/users/username/.conan/data/libjpeg/9d/_/_/package/2e90c2fe2f69846019f521f2004427fb191035af --enable-shared=no --enable-static=yes --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32
I have found several people with the similar error (not while installing OpenCV though) but I have not managed to find any solution.
## ----------- ##
## Core tests. ##
## ----------- ##
<...>
conftest.c:11:10: fatal error: ac_nonexistent.h: No such file or directory
#include <ac_nonexistent.h>
^~~~~~~~~~~~~~~~~~
compilation terminated.
configure:4415: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "libjpeg"
| #define PACKAGE_TARNAME "libjpeg"
| #define PACKAGE_VERSION "9.4.0"
| #define PACKAGE_STRING "libjpeg 9.4.0"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| #define PACKAGE "libjpeg"
| #define VERSION "9.4.0"
| /* end confdefs.h. */
| #include <ac_nonexistent.h>
configure:4440: result: x86_64-w64-mingw32-gcc -E
configure:4460: x86_64-w64-mingw32-gcc -E -DLIBJPEG_BUILDING conftest.c
configure:4460: $? = 0
configure:4474: x86_64-w64-mingw32-gcc -E -DLIBJPEG_BUILDING conftest.c
conftest.c:11:10: fatal error: ac_nonexistent.h: No such file or directory
#include <ac_nonexistent.h>
^~~~~~~~~~~~~~~~~~
compilation terminated.
configure:4474: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "libjpeg"
| #define PACKAGE_TARNAME "libjpeg"
| #define PACKAGE_VERSION "9.4.0"
| #define PACKAGE_STRING "libjpeg 9.4.0"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| #define PACKAGE "libjpeg"
| #define VERSION "9.4.0"
| /* end confdefs.h. */
| #include <ac_nonexistent.h>
configure:4503: checking whether make sets $(MAKE)
configure:4525: result: yes
configure:4534: checking whether ln -s works
configure:4541: result: no, using cp -pR
configure:4551: checking for x86_64-w64-mingw32-ar
configure:4581: result: no
configure:4551: checking for x86_64-w64-mingw32-lib
configure:4581: result: no
configure:4551: checking for x86_64-w64-mingw32-link
configure:4581: result: no
configure:4595: checking for ar
configure:4611: found /c/.conan/42de2d/1/bin/usr/bin/ar
configure:4622: result: ar
configure:4648: checking the archiver (ar) interface
configure:4664: x86_64-w64-mingw32-gcc -c -m64 -g -DLIBJPEG_BUILDING conftest.c >&5
configure:4664: $? = 0
configure:4666: ar cru libconftest.a conftest.o >&5
configure:4669: $? = 0
configure:4697: result: ar
configure:4726: checking if LD -Wl,--version-script works
configure:4750: x86_64-w64-mingw32-gcc -o conftest.exe -m64 -g -DLIBJPEG_BUILDING -m64 -Wl,--version-script=conftest.map conftest.c >&5
configure:4750: $? = 0
configure:4759: result: yes
configure:4772: checking for function prototypes
configure:4792: x86_64-w64-mingw32-gcc -c -m64 -g -DLIBJPEG_BUILDING conftest.c >&5
configure:4792: $? = 0
configure:4800: result: yes
configure:4821: checking for grep that handles long lines and -e
configure:4879: result: /c/.conan/42de2d/1/bin/usr/bin/grep
configure:4884: checking for egrep
configure:4946: result: /c/.conan/42de2d/1/bin/usr/bin/grep -E
configure:4951: checking for ANSI C header files
configure:4971: x86_64-w64-mingw32-gcc -c -m64 -g -DLIBJPEG_BUILDING conftest.c >&5
configure:4971: $? = 0
configure:5044: x86_64-w64-mingw32-gcc -o conftest.exe -m64 -g -DLIBJPEG_BUILDING -m64 conftest.c >&5
configure:5044: $? = 0
configure:5044: ./conftest.exe
configure:5044: $? = 0
configure:5055: result: yes
configure:5068: checking for sys/types.h
configure:5068: x86_64-w64-mingw32-gcc -c -m64 -g -DLIBJPEG_BUILDING conftest.c >&5
configure:5068: $? = 0
configure:5068: result: yes
configure:5068: checking for sys/stat.h
configure:5068: x86_64-w64-mingw32-gcc -c -m64 -g -DLIBJPEG_BUILDING conftest.c >&5
configure:5068: $? = 0
configure:5068: result: yes
configure:5068: checking for stdlib.h
configure:5068: x86_64-w64-mingw32-gcc -c -m64 -g -DLIBJPEG_BUILDING conftest.c >&5
configure:5068: $? = 0
configure:5068: result: yes
configure:5068: checking for string.h
configure:5068: x86_64-w64-mingw32-gcc -c -m64 -g -DLIBJPEG_BUILDING conftest.c >&5
configure:5068: $? = 0
configure:5068: result: yes
configure:5068: checking for memory.h
configure:5068: x86_64-w64-mingw32-gcc -c -m64 -g -DLIBJPEG_BUILDING conftest.c >&5
configure:5068: $? = 0
configure:5068: result: yes
configure:5068: checking for strings.h
configure:5068: x86_64-w64-mingw32-gcc -c -m64 -g -DLIBJPEG_BUILDING conftest.c >&5
configure:5068: $? = 0
configure:5068: result: yes
configure:5068: checking for inttypes.h
configure:5068: x86_64-w64-mingw32-gcc -c -m64 -g -DLIBJPEG_BUILDING conftest.c >&5
configure:5068: $? = 0
configure:5068: result: yes
configure:5068: checking for stdint.h
configure:5068: x86_64-w64-mingw32-gcc -c -m64 -g -DLIBJPEG_BUILDING conftest.c >&5
configure:5068: $? = 0
configure:5068: result: yes
configure:5068: checking for unistd.h
configure:5068: x86_64-w64-mingw32-gcc -c -m64 -g -DLIBJPEG_BUILDING conftest.c >&5
configure:5068: $? = 0
configure:5068: result: yes
configure:5083: checking stddef.h usability
configure:5083: x86_64-w64-mingw32-gcc -c -m64 -g -DLIBJPEG_BUILDING conftest.c >&5
configure:5083: $? = 0
configure:5083: result: yes
configure:5083: checking stddef.h presence
configure:5083: x86_64-w64-mingw32-gcc -E -DLIBJPEG_BUILDING conftest.c
configure:5083: $? = 0
configure:5083: result: yes
configure:5083: checking for stddef.h
configure:5083: result: yes
configure:5083: checking for stdlib.h
configure:5083: result: yes
configure:5083: checking locale.h usability
configure:5083: x86_64-w64-mingw32-gcc -c -m64 -g -DLIBJPEG_BUILDING conftest.c >&5
configure:5083: $? = 0
configure:5083: result: yes
configure:5083: checking locale.h presence
configure:5083: x86_64-w64-mingw32-gcc -E -DLIBJPEG_BUILDING conftest.c
configure:5083: $? = 0
configure:5083: result: yes
configure:5083: checking for locale.h
configure:5083: result: yes
configure:5093: checking for string.h
configure:5093: result: yes
configure:5106: checking for size_t
configure:5133: x86_64-w64-mingw32-gcc -c -m64 -g -DLIBJPEG_BUILDING conftest.c >&5
configure:5133: $? = 0
configure:5139: result: yes
configure:5175: checking for type unsigned char
configure:5188: x86_64-w64-mingw32-gcc -c -m64 -g -DLIBJPEG_BUILDING conftest.c >&5
configure:5188: $? = 0
configure:5189: result: yes
configure:5200: checking for type unsigned short
configure:5213: x86_64-w64-mingw32-gcc -c -m64 -g -DLIBJPEG_BUILDING conftest.c >&5
configure:5213: $? = 0
configure:5214: result: yes
configure:5225: checking for type void
configure:5259: x86_64-w64-mingw32-gcc -c -m64 -g -DLIBJPEG_BUILDING conftest.c >&5
configure:5259: $? = 0
configure:5260: result: yes
configure:5270: checking for an ANSI C-conforming const
configure:5336: x86_64-w64-mingw32-gcc -c -m64 -g -DLIBJPEG_BUILDING conftest.c >&5
configure:5336: $? = 0
configure:5343: result: yes
configure:5353: checking for inline
configure:5368: x86_64-w64-mingw32-gcc -c -m64 -g -DLIBJPEG_BUILDING conftest.c >&5
configure:5368: $? = 0
configure:5406: result: __inline__
configure:5415: checking for broken incomplete types
configure:5428: x86_64-w64-mingw32-gcc -c -m64 -g -DLIBJPEG_BUILDING conftest.c >&5
configure:5428: $? = 0
configure:5429: result: ok
configure:5441: checking for short external names
configure:5457: x86_64-w64-mingw32-gcc -o conftest.exe -m64 -g -DLIBJPEG_BUILDING -m64 conftest.c >&5
configure:5457: $? = 0
configure:5458: result: ok
configure:5471: checking to see if char is signed
configure:5508: x86_64-w64-mingw32-gcc -o conftest.exe -m64 -g -DLIBJPEG_BUILDING -m64 conftest.c >&5
configure:5508: $? = 0
configure:5508: ./conftest.exe
configure:5508: $? = 1
configure: program exited with status 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "libjpeg"
| #define PACKAGE_TARNAME "libjpeg"
| #define PACKAGE_VERSION "9.4.0"
| #define PACKAGE_STRING "libjpeg 9.4.0"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| #define PACKAGE "libjpeg"
| #define VERSION "9.4.0"
| #define HAVE_PROTOTYPES 1
| #define STDC_HEADERS 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_STDDEF_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_LOCALE_H 1
| #define HAVE_UNSIGNED_CHAR 1
| #define HAVE_UNSIGNED_SHORT 1
| #define INLINE __inline__
| /* end confdefs.h. */
|
| #ifdef HAVE_STDLIB_H
| #include <stdlib.h>
| #endif
| #include <stdio.h>
| #ifdef HAVE_PROTOTYPES
| int is_char_signed (int arg)
| #else
| int is_char_signed (arg)
| int arg;
| #endif
| {
| if (arg == 189) { /* expected result for unsigned char */
| return 0; /* type char is unsigned */
| }
| else if (arg != -67) { /* expected result for signed char */
| printf("Hmm, it seems 'char' is not eight bits wide on your machine.\n");
| printf("I fear the JPEG software will not work at all.\n\n");
| }
| return 1; /* assume char is signed otherwise */
| }
| char signed_char_check = (char) (-67);
| int main() {
| exit(is_char_signed((int) signed_char_check));
| }
configure:5515: result: yes
configure:5523: checking to see if right shift is signed
configure:5563: x86_64-w64-mingw32-gcc -o conftest.exe -m64 -g -DLIBJPEG_BUILDING -m64 conftest.c >&5
configure:5563: $? = 0
configure:5563: ./conftest.exe
configure:5563: $? = 1
configure: program exited with status 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "libjpeg"
| #define PACKAGE_TARNAME "libjpeg"
| #define PACKAGE_VERSION "9.4.0"
| #define PACKAGE_STRING "libjpeg 9.4.0"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| #define PACKAGE "libjpeg"
| #define VERSION "9.4.0"
| #define HAVE_PROTOTYPES 1
| #define STDC_HEADERS 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_STDDEF_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_LOCALE_H 1
| #define HAVE_UNSIGNED_CHAR 1
| #define HAVE_UNSIGNED_SHORT 1
| #define INLINE __inline__
| /* end confdefs.h. */
|
| #ifdef HAVE_STDLIB_H
| #include <stdlib.h>
| #endif
| #include <stdio.h>
| #ifdef HAVE_PROTOTYPES
| int is_shifting_signed (long arg)
| #else
| int is_shifting_signed (arg)
| long arg;
| #endif
| /* See whether right-shift on a long is signed or not. */
| {
| long res = arg >> 4;
|
| if (res == -0x7F7E80CL) { /* expected result for signed shift */
| return 1; /* right shift is signed */
| }
| /* see if unsigned-shift hack will fix it. */
| /* we can't just test exact value since it depends on width of long... */
| res |= (~0L) << (32-4);
| if (res == -0x7F7E80CL) { /* expected result now? */
| return 0; /* right shift is unsigned */
| }
| printf("Right shift isn't acting as I expect it to.\n");
| printf("I fear the JPEG software will not work at all.\n\n");
| return 0; /* try it with unsigned anyway */
| }
| int main() {
| exit(is_shifting_signed(-0x7F7E80B1L));
| }
configure:5570: result: yes
configure:5578: checking to see if fopen accepts b spec
configure:5597: x86_64-w64-mingw32-gcc -o conftest.exe -m64 -g -DLIBJPEG_BUILDING -m64 conftest.c >&5
configure:5597: $? = 0
configure:5597: ./conftest.exe
configure:5597: $? = 0
configure:5598: result: yes
configure:5620: checking for x86_64-w64-mingw32-as
configure:5650: result: no
configure:5660: checking for as
configure:5676: found /c/.conan/42de2d/1/bin/usr/bin/as
configure:5687: result: as
configure:5712: checking for x86_64-w64-mingw32-dlltool
configure:5742: result: no
configure:5752: checking for dlltool
configure:5768: found /c/.conan/42de2d/1/bin/usr/bin/dlltool
configure:5779: result: dlltool
configure:5804: checking for x86_64-w64-mingw32-objdump
configure:5834: result: no
configure:5844: checking for objdump
configure:5860: found /c/.conan/42de2d/1/bin/usr/bin/objdump
configure:5871: result: objdump
configure:5962: checking how to print strings
configure:5989: result: printf
configure:6010: checking for a sed that does not truncate output
configure:6074: result: /c/.conan/42de2d/1/bin/usr/bin/sed
configure:6092: checking for fgrep
configure:6154: result: /c/.conan/42de2d/1/bin/usr/bin/grep -F
configure:6189: checking for ld used by x86_64-w64-mingw32-gcc
configure:6256: result: C:/Program
Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/bin/ld.exe
configure:6263: checking if the linker (C:/Program
Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/bin/ld.exe) is GNU ld
configure:6278: result: no
configure:6290: checking for BSD- or MS-compatible name lister (nm)
configure:6344: result: /c/.conan/42de2d/1/bin/usr/bin/nm -B
configure:6474: checking the name lister (/c/.conan/42de2d/1/bin/usr/bin/nm -B) interface
configure:6481: x86_64-w64-mingw32-gcc -c -m64 -g -DLIBJPEG_BUILDING conftest.c >&5
configure:6484: /c/.conan/42de2d/1/bin/usr/bin/nm -B "conftest.o"
configure:6487: output
0000000000000000 b .bss
0000000000000000 d .data
0000000000000000 N .debug_abbrev
0000000000000000 N .debug_aranges
0000000000000000 N .debug_info
0000000000000000 N .debug_line
0000000000000000 r .rdata$zzz
0000000000000000 t .text
0000000000000000 B some_variable
configure:6494: result: BSD nm
configure:6498: checking the maximum length of command line arguments
configure:6629: result: 8192
configure:6677: checking how to convert x86_64-w64-mingw32 file names to x86_64-w64-mingw32 format
configure:6717: result: func_convert_file_msys_to_w32
configure:6724: checking how to convert x86_64-w64-mingw32 file names to toolchain format
configure:6744: result: func_convert_file_msys_to_w32
configure:6751: checking for C:/Program
Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/bin/ld.exe option to reload object files
configure:6758: result: -r
configure:6792: checking for x86_64-w64-mingw32-objdump
configure:6819: result: objdump
configure:6888: checking how to recognize dependent libraries
configure:7088: result: file_magic ^x86 archive import|^x86 DLL
configure:7133: checking for x86_64-w64-mingw32-dlltool
configure:7160: result: dlltool
configure:7230: checking how to associate runtime and link libraries
configure:7257: result: func_cygming_dll_for_implib
configure:7273: checking for x86_64-w64-mingw32-ar
configure:7300: result: ar
configure:7381: checking for archiver #FILE support
configure:7398: x86_64-w64-mingw32-gcc -c -m64 -g -DLIBJPEG_BUILDING conftest.c >&5
configure:7398: $? = 0
configure:7401: ar cru libconftest.a #conftest.lst >&5
configure:7404: $? = 0
configure:7409: ar cru libconftest.a #conftest.lst >&5
ar: conftest.o: No such file or directory
configure:7412: $? = 1
configure:7424: result: #
configure:7442: checking for x86_64-w64-mingw32-strip
configure:7472: result: no
configure:7482: checking for strip
configure:7498: found /c/.conan/42de2d/1/bin/usr/bin/strip
configure:7509: result: strip
configure:7541: checking for x86_64-w64-mingw32-ranlib
configure:7571: result: no
configure:7581: checking for ranlib
configure:7597: found /c/.conan/42de2d/1/bin/usr/bin/ranlib
configure:7608: result: ranlib
configure:7710: checking command to parse /c/.conan/42de2d/1/bin/usr/bin/nm -B output from x86_64-w64-mingw32-gcc object
configure:7863: x86_64-w64-mingw32-gcc -c -m64 -g -DLIBJPEG_BUILDING conftest.c >&5
configure:7866: $? = 0
configure:7870: /c/.conan/42de2d/1/bin/usr/bin/nm -B conftest.o \| sed -n -e 's/^.*[ ]\([ABCDGIRSTW][ABCDGIRSTW]*\)[ ][ ]*\([_A-Za-z][_A-Za-z0-9]*\)\{0,1\}$/\1 \2 \2/p' | sed '/ __gnu_lto/d' \> conftest.nm
configure:7873: $? = 0
configure:7939: x86_64-w64-mingw32-gcc -o conftest.exe -m64 -g -DLIBJPEG_BUILDING -m64 conftest.c conftstm.o >&5
configure:7942: $? = 0
configure:7980: result: ok
configure:8027: checking for sysroot
configure:8057: result: no
configure:8064: checking for a working dd
configure:8102: result: /c/.conan/42de2d/1/bin/usr/bin/dd
configure:8106: checking how to truncate binary pipes
configure:8121: result: /c/.conan/42de2d/1/bin/usr/bin/dd bs=4096 count=1
configure:8410: checking for x86_64-w64-mingw32-mt
configure:8440: result: no
configure:8450: checking for mt
configure:8480: result: no
configure:8500: checking if : is a manifest tool
configure:8506: : '-?'
configure:8514: result: no
configure:9188: checking for dlfcn.h
configure:9188: x86_64-w64-mingw32-gcc -c -m64 -g -DLIBJPEG_BUILDING conftest.c >&5
conftest.c:62:10: fatal error: dlfcn.h: No such file or directory
#include <dlfcn.h>
^~~~~~~~~
compilation terminated.
configure:9188: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "libjpeg"
| #define PACKAGE_TARNAME "libjpeg"
| #define PACKAGE_VERSION "9.4.0"
| #define PACKAGE_STRING "libjpeg 9.4.0"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| #define PACKAGE "libjpeg"
| #define VERSION "9.4.0"
| #define HAVE_PROTOTYPES 1
| #define STDC_HEADERS 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_STDDEF_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_LOCALE_H 1
| #define HAVE_UNSIGNED_CHAR 1
| #define HAVE_UNSIGNED_SHORT 1
| #define INLINE __inline__
| /* end confdefs.h. */
| #include <stdio.h>
| #ifdef HAVE_SYS_TYPES_H
| # include <sys/types.h>
| #endif
| #ifdef HAVE_SYS_STAT_H
| # include <sys/stat.h>
| #endif
| #ifdef STDC_HEADERS
| # include <stdlib.h>
| # include <stddef.h>
| #else
| # ifdef HAVE_STDLIB_H
| # include <stdlib.h>
| # endif
| #endif
| #ifdef HAVE_STRING_H
| # if !defined STDC_HEADERS && defined HAVE_MEMORY_H
| # include <memory.h>
| # endif
| # include <string.h>
| #endif
| #ifdef HAVE_STRINGS_H
| # include <strings.h>
| #endif
| #ifdef HAVE_INTTYPES_H
| # include <inttypes.h>
| #endif
| #ifdef HAVE_STDINT_H
| # include <stdint.h>
| #endif
| #ifdef HAVE_UNISTD_H
| # include <unistd.h>
| #endif
|
| #include <dlfcn.h>
configure:9188: result: no
configure:9442: checking for objdir
configure:9457: result: .libs
configure:9717: checking if x86_64-w64-mingw32-gcc supports -fno-rtti -fno-exceptions
configure:9735: x86_64-w64-mingw32-gcc -c -m64 -g -DLIBJPEG_BUILDING -fno-rtti -fno-exceptions conftest.c >&5
cc1.exe: warning: command line option '-fno-rtti' is valid for C++/ObjC++ but not for C
configure:9739: $? = 0
configure:9752: result: no
configure:10110: checking for x86_64-w64-mingw32-gcc option to produce PIC
configure:10117: result: -DDLL_EXPORT -DPIC
configure:10125: checking if x86_64-w64-mingw32-gcc PIC flag -DDLL_EXPORT -DPIC works
configure:10143: x86_64-w64-mingw32-gcc -c -m64 -g -DLIBJPEG_BUILDING -DDLL_EXPORT -DPIC -DPIC conftest.c >&5
configure:10147: $? = 0
configure:10160: result: yes
configure:10189: checking if x86_64-w64-mingw32-gcc static flag -static works
configure:10217: result: yes
configure:10232: checking if x86_64-w64-mingw32-gcc supports -c -o file.o
configure:10253: x86_64-w64-mingw32-gcc -c -m64 -g -DLIBJPEG_BUILDING -o out/conftest2.o conftest.c >&5
configure:10257: $? = 0
configure:10279: result: yes
configure:10287: checking if x86_64-w64-mingw32-gcc supports -c -o file.o
configure:10334: result: yes
configure:10367: checking whether the x86_64-w64-mingw32-gcc linker (C:/Program
Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/x86_64-w64-mingw32/bin/ld.exe) supports shared libraries
configure:11626: result: yes
configure:11866: checking dynamic linker characteristics
configure:12684: result: Win32 ld.exe
configure:12806: checking how to hardcode library paths into programs
configure:12831: result: immediate
configure:13379: checking whether stripping libraries is possible
configure:13384: result: yes
configure:13419: checking if libtool supports shared libraries
configure:13421: result: yes
configure:13424: checking whether to build shared libraries
configure:13449: result: no
configure:13452: checking whether to build static libraries
configure:13456: result: yes
configure:13575: checking libjpeg version number
configure:13585: result: 9.4.0
configure:13617: WARNING: cache variable lt_cv_path_LD contains a newline
configure:13699: checking that generated files are newer than configure
configure:13705: result: done
configure:13736: creating ./config.status
## ---------------------- ##
## Running config.status. ##
## ---------------------- ##
This file was extended by libjpeg config.status 9.4.0, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES =
CONFIG_HEADERS =
CONFIG_LINKS =
CONFIG_COMMANDS =
$ ./config.status
on DESKTOP-GGV5QKI
config.status:1114: creating Makefile
config.status:1114: creating libjpeg.pc
config.status:1114: creating jconfig.h
config.status:1328: executing depfiles commands
config.status:1405: cd . && sed -e '/# am--include-marker/d' Makefile | make -f - am--depfiles
/tmp/GmP09nS0:326: *** missing separator. Stop.
config.status:1410: $? = 2
config.status:1414: error: in `/c/users/username/.conan/data/libjpeg/9d/_/_/build/2e90c2fe2f69846019f521f2004427fb191035af':
config.status:1416: error: Something went wrong bootstrapping makefile fragments
for automatic dependency tracking. Try re-running configure with the
'--disable-dependency-tracking' option to at least be able to build
the package (albeit without support for automatic dependency tracking).
See `config.log' for more details
You likely made a modification to a Makefile.am that caused autoreconf and/or configure to fail. Run,
rm -f config.h* configure
to clean up, then run,
autoreconf; ./configure
to reconfigure. Of course, if you haven't undone the assumed, offending change to your Makefile.am in the meantime, you're going to end up in the same spot.
It is very possible that the libjpeg library doesn't compile with autotools and/or makefiles in the MinGW tool suite. Even if it is a gcc for Windows, it is not like all the code is fully portable between platforms, and those autotools or Makefiles might do some assumptions of platform that are not correct in Windows.
In general, the Visual Studio toolchain (MSBuild, cl.exe) is better supported in Windows platforms by the community, could be considered the default to-go, especially nowadays that the Visual Studio Community editions are completely free.
The packages in ConanCenter are also typically (and most of them, the ones created from the conan-center-index repo) built and tested with Visual Studio (several versions), so the support is expected to be much better than the one for MinGW.
I have a SConstruct that build my tool in 3 steps:
build a static library. In my case it's the antlr4 c++ runtime
generate the antlr4 cpp and h files (listener, visitor etc) of an antlr4's grammar
finally build a program using those files and linking to the antlr4 runtime library.
1 and 2 can be built in any order, even together but 3 ahs to be built when the other two have finished.
All this works perfectly when I don't use any VariantDir, however SCons fails when I try to use a variant directory, saying that it can't find the autogenerated files:
cons: *** [build/Parser/CoralBaseListener.o] Source `build/Parser/CoralBaseListener.cpp' not found, needed by target `build/Parser/CoralBaseListener.o'.
this is the whole SConstruct:
import os
import subprocess
env = Environment(
CC = "clang",
CXX = "clang++",
CXXFLAGS = ['-std=c++11', '-stdlib=libc++']
)
env.Append(ENV = {'CLASSPATH': './dependencies/antlr4/antlr-4.8-complete.jar'})
# RelWithDbgInfo
env.Append(CXXFLAGS = ['-O2', '-g', '-DNDEBUG'])
VariantDir('./build', './src')
VariantDir('./build/antlr4Runtime', './dependencies/antlr4Runtime')
#
# Builder for generating grammar files with antlr4 (the java app)
#
def auto_antlr_generated_files(prefix):
return [File(prefix + _file + ext) for _file in [
'CoralBaseListener',
'CoralBaseVisitor',
'CoralLexer',
'CoralListener',
'CoralParser',
'CoralVisitor'] for ext in ['.cpp', '.h']
]
def antlr_emitter(target, source, env):
target = auto_antlr_generated_files('src/Parser/')
return target, source
AntlrBuilder = Builder(
action='java org.antlr.v4.Tool $SOURCE -Dlanguage=Cpp -package Coral -visitor -listener -o src/Parser',
emitter=antlr_emitter
)
env.Append(BUILDERS={'Antlr': AntlrBuilder})
#
# Cloning the Environment for Antlr4 runtime
#
antlrEnv = env.Clone()
antlrEnv.Append(CXXFLAGS = [
'-Wall',
'-pedantic',
'-W',
'-Wno-overloaded-virtual',
'-Wno-dollar-in-identifier-extension',
'-Wno-four-char-constants'
])
#
# Building in 3 steps, first the antlr4 runtime library, then the parser files with Antlr then the final program
#
AntlrRuntime = antlrEnv.StaticLibrary(
'lib/antlr4-runtime',
source =
Glob('./build/antlr4Runtime/*.cpp') + \
Glob('./build/antlr4Runtime/atn/*.cpp') + \
Glob('./build/antlr4Runtime/dfa/*.cpp') + \
Glob('./build/antlr4Runtime/misc/*.cpp') + \
Glob('./build/antlr4Runtime/support/*.cpp') + \
Glob('./build/antlr4Runtime/tree/*.cpp') + \
Glob('./build/antlr4Runtime/tree/pattern/*.cpp') + \
Glob('./build/antlr4Runtime/tree/xpath/*.cpp'),
CPPPATH = './build/antlr4Runtime',
ARFLAGS = 'qc'
)
ParserFiles = env.Antlr(source='./Coral.g4')
CoralLang = env.Program(target = 'coral',
source = Glob('./build/*.cpp') + Glob('./build/Parser/*.cpp'),
CPPPATH = ['./build', './build/antlr4Runtime'],
LIBPATH = './lib',
LIBS = ['antlr4-runtime']
)
Requires(ParserFiles, AntlrRuntime)
Depends(auto_antlr_generated_files('./build/src/Parser/'), ParserFiles)
Depends(CoralLang, ParserFiles)
It is probably worth mentioning that at this point, when I have the error, the autogenerated antlr4 files are not in ./src nor in ./build, So basically the command never generated them in first place.
note that without VariantDir everything works as expected. Everything is build in the right steps without problems
import os
import subprocess
env = Environment(
CC = "clang",
CXX = "clang++",
CXXFLAGS = ['-std=c++11', '-stdlib=libc++']
)
env.Append(ENV = {'CLASSPATH': './dependencies/antlr4/antlr-4.8-complete.jar'})
# RelWithDbgInfo
env.Append(CXXFLAGS = ['-O2', '-g', '-DNDEBUG'])
#
# Builder for generating grammar files with antlr4 (the java app)
#
def auto_antlr_generated_files(prefix):
return [File(prefix + _file + ext) for _file in [
'CoralBaseListener',
'CoralBaseVisitor',
'CoralLexer',
'CoralListener',
'CoralParser',
'CoralVisitor'] for ext in ['.cpp', '.h']
]
def antlr_emitter(target, source, env):
target = auto_antlr_generated_files('src/Parser/')
return target, source
AntlrBuilder = Builder(
action='java org.antlr.v4.Tool $SOURCE -Dlanguage=Cpp -package Coral -visitor -listener -o src/Parser',
emitter=antlr_emitter
)
env.Append(BUILDERS={'Antlr': AntlrBuilder})
#
# Cloning the Environment for Antlr4 runtime
#
antlrEnv = env.Clone()
antlrEnv.Append(CXXFLAGS = [
'-Wall',
'-pedantic',
'-W',
'-Wno-overloaded-virtual',
'-Wno-dollar-in-identifier-extension',
'-Wno-four-char-constants'
])
#
# Building in 3 steps, first the antlr4 runtime library, then the parser files with Antlr then the final program
#
AntlrRuntime = antlrEnv.StaticLibrary(
'lib/antlr4-runtime',
source =
Glob('./dependencies/antlr4Runtime/*.cpp') + \
Glob('./dependencies/antlr4Runtime/atn/*.cpp') + \
Glob('./dependencies/antlr4Runtime/dfa/*.cpp') + \
Glob('./dependencies/antlr4Runtime/misc/*.cpp') + \
Glob('./dependencies/antlr4Runtime/support/*.cpp') + \
Glob('./dependencies/antlr4Runtime/tree/*.cpp') + \
Glob('./dependencies/antlr4Runtime/tree/pattern/*.cpp') + \
Glob('./dependencies/antlr4Runtime/tree/xpath/*.cpp'),
CPPPATH = './dependencies/antlr4Runtime',
ARFLAGS = 'qc'
)
ParserFiles = env.Antlr(source='./Coral.g4')
CoralLang = env.Program(target = 'coral',
source = Glob('./src/*.cpp') + Glob('./src/Parser/*.cpp'),
CPPPATH = ['./src', './dependencies/antlr4Runtime'],
LIBPATH = './lib',
LIBS = ['antlr4-runtime']
)
Requires(ParserFiles, AntlrRuntime)
Depends(CoralLang, ParserFiles)
I have the feeling that I'm doing something remarkably silly but I can't figure out what exactly.
This is what SCons output with the first SConstruct, the one that uses VariantDir:
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: *** [build/Parser/CoralBaseListener.o] Source `build/Parser/CoralBaseListener.cpp' not found, needed by target `build/Parser/CoralBaseListener.o'.
scons: building terminated because of errors.
This is really all and if I read this correctly, SCons is jumping straight to point 3 and of course at it fails because point 2 didn't create the files that point 3 needs as source.
This is instead a snippet of the output of the second SConstruct, the one that doesn't use VariantDir. (I cut off some of the similar lines where Scons create the static library, but they are all similar, as you know)
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
clang++ -o dependencies/antlr4Runtime/ANTLRErrorListener.o -c -std=c++11 -stdlib=libc++ -O2 -g -DNDEBUG -Wall -pedantic -W -Wno-overloaded-virtual -Wno-dollar-in-identifier-extension -Wno-four-char-constants -Idependencies/antlr4Runtime dependencies/antlr4Runtime/ANTLRErrorListener.cpp
...
clang++ -o dependencies/antlr4Runtime/tree/xpath/XPathWildcardElement.o -c -std=c++11 -stdlib=libc++ -O2 -g -DNDEBUG -Wall -pedantic -W -Wno-overloaded-virtual -Wno-dollar-in-identifier-extension -Wno-four-char-constants -Idependencies/antlr4Runtime dependencies/antlr4Runtime/tree/xpath/XPathWildcardElement.cpp
ar qc lib/libantlr4-runtime.a dependencies/antlr4Runtime/ANTLRErrorListener.o ... dependencies/antlr4Runtime/tree/xpath/XPathWildcardElement.o
ranlib lib/libantlr4-runtime.a
java org.antlr.v4.Tool Coral.g4 -Dlanguage=Cpp -package Coral -visitor -listener -o src/Parser
clang++ -o src/Parser/CoralListener.o -c -std=c++11 -stdlib=libc++ -O2 -g -DNDEBUG -Isrc -Idependencies/antlr4Runtime src/Parser/CoralListener.cpp
clang++ -o src/Parser/CoralBaseListener.o -c -std=c++11 -stdlib=libc++ -O2 -g -DNDEBUG -Isrc -Idependencies/antlr4Runtime src/Parser/CoralBaseListener.cpp
clang++ -o src/Parser/CoralParser.o -c -std=c++11 -stdlib=libc++ -O2 -g -DNDEBUG -Isrc -Idependencies/antlr4Runtime src/Parser/CoralParser.cpp
clang++ -o src/Parser/CoralLexer.o -c -std=c++11 -stdlib=libc++ -O2 -g -DNDEBUG -Isrc -Idependencies/antlr4Runtime src/Parser/CoralLexer.cpp
clang++ -o src/main.o -c -std=c++11 -stdlib=libc++ -O2 -g -DNDEBUG -Isrc -Idependencies/antlr4Runtime src/main.cpp
clang++ -o src/Parser/CoralVisitor.o -c -std=c++11 -stdlib=libc++ -O2 -g -DNDEBUG -Isrc -Idependencies/antlr4Runtime src/Parser/CoralVisitor.cpp
clang++ -o src/Parser/CoralBaseVisitor.o -c -std=c++11 -stdlib=libc++ -O2 -g -DNDEBUG -Isrc -Idependencies/antlr4Runtime src/Parser/CoralBaseVisitor.cpp
clang++ -o coral src/main.o src/Parser/CoralBaseListener.o src/Parser/CoralBaseVisitor.o src/Parser/CoralLexer.o src/Parser/CoralListener.o src/Parser/CoralParser.o src/Parser/CoralVisitor.o -Llib -lantlr4-runtime
scons: done building targets.
So reading this is obvious that Scons start with building the static library, then he runs antlr to generate the files needed to parse my syntax and finally, when all the dependencies are created, it build the program.
Working on a large embedded linux codebase / SDK "Not Invented Here" - invented offshore by Elbonian Code Slaves nailing various things together.
Part of the codebase is Live555 WIS-Streamer. In order to (try to) fix a niggle relating to timestamps I have inserted a couple of calls to clock_gettime(CLOCK_MONOTONIC, &ts); which then caused the compilation to fail with several undefined reference to 'clock_gettime' errors.
I've had this before and it was solved by adding -lrt to the compiler options to include librealtime, however this time round it just isn't helping. I've done a lot of googling and reading SO but I can't see any definitive answer, and the makefiles for the project are a lot more complicated than the examples found across the web.
I need some help either pointing out the blindingly obvious mistake I've made in the makefile(s), or with tracing the compiler's expectations back through the chain to see where I need to make a change.
This project is cross-compiled using a set of libraries for the given hardware, so -lrt is still required (I see it's no longer necessary in later gcc libs) and we can't update or change that stuff easily.
Here's a snippet of failed compiler output, with much verbosity. I have shortened path names just to stay below the post size limit.
make[10]: Entering directory `/ipnc_rdk/ipnc_app/network/live/testProgs'
/ipnc_rdk/../dvsdk_ipnctools/linux-devkit//bin/arm-arago-linux-gnueabi-g++ -c -I../UsageEnvironment/include -I../groupsock/include -I../liveMedia/include -I../BasicUsageEnvironment/include -I. -O3 -v -DSOCKLEN_T=socklen_t -DNO_STRSTREAM=1 -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 -Wl,--verbose -lrt -Wall -DBSD=1 testMP3Streamer.cpp
Using built-in specs.
Target: arm-arago-linux-gnueabi
Thread model: posix
gcc version 4.3.3 (GCC)
COLLECT_GCC_OPTIONS='-c' '-I../UsageEnvironment/include' '-I../groupsock/include' '-I../liveMedia/include' '-I../BasicUsageEnvironment/include' '-I.' '-O3' '-v' '-DSOCKLEN_T=socklen_t' '-DNO_STRSTREAM=1' '-D_LARGEFILE_SOURCE=1' '-D_FILE_OFFSET_BITS=64' '-Wall' '-DBSD=1' '-shared-libgcc' '-mfloat-abi=soft'
../libexec/gcc/arm-arago-linux-gnueabi/4.3.3/cc1plus -quiet -v -I../UsageEnvironment/include -I../groupsock/include -I../liveMedia/include -I../BasicUsageEnvironment/include -I. -iprefix ../lib/gcc/arm-arago-linux-gnueabi/4.3.3/ -isysroot ../arm-arago-linux-gnueabi -D_GNU_SOURCE -DSOCKLEN_T=socklen_t -DNO_STRSTREAM=1 -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 -DBSD=1 testMP3Streamer.cpp -quiet -dumpbase testMP3Streamer.cpp -mfloat-abi=soft -auxbase testMP3Streamer -O3 -Wall -version -o /tmp/cckqq421.s
ignoring duplicate directory "../lib/gcc/../../lib/gcc/arm-arago-linux-gnueabi/4.3.3/../../../../arm-arago-linux-gnueabi/include/c++/4.3.3"
ignoring duplicate directory "../lib/gcc/../../lib/gcc/arm-arago-linux-gnueabi/4.3.3/../../../../arm-arago-linux-gnueabi/include/c++/4.3.3/arm-arago-linux-gnueabi"
ignoring duplicate directory "../lib/gcc/../../lib/gcc/arm-arago-linux-gnueabi/4.3.3/../../../../arm-arago-linux-gnueabi/include/c++/4.3.3/backward"
ignoring nonexistent directory "../arm-arago-linux-gnueabi/usr/local/include"
ignoring duplicate directory "../lib/gcc/../../lib/gcc/arm-arago-linux-gnueabi/4.3.3/include"
ignoring duplicate directory "../lib/gcc/../../lib/gcc/arm-arago-linux-gnueabi/4.3.3/include-fixed"
ignoring duplicate directory "../lib/gcc/../../lib/gcc/arm-arago-linux-gnueabi/4.3.3/../../../../arm-arago-linux-gnueabi/include"
#include "..." search starts here:
#include <...> search starts here:
../UsageEnvironment/include
../groupsock/include
../liveMedia/include
../BasicUsageEnvironment/include
.
../lib/gcc/arm-arago-linux-gnueabi/4.3.3/../../../../arm-arago-linux-gnueabi/include/c++/4.3.3
../lib/gcc/arm-arago-linux-gnueabi/4.3.3/../../../../arm-arago-linux-gnueabi/include/c++/4.3.3/arm-arago-linux-gnueabi
../lib/gcc/arm-arago-linux-gnueabi/4.3.3/../../../../arm-arago-linux-gnueabi/include/c++/4.3.3/backward
../lib/gcc/arm-arago-linux-gnueabi/4.3.3/include
../lib/gcc/arm-arago-linux-gnueabi/4.3.3/include-fixed
../lib/gcc/arm-arago-linux-gnueabi/4.3.3/../../../../arm-arago-linux-gnueabi/include
../arm-arago-linux-gnueabi/usr/include
End of search list.
GNU C++ (GCC) version 4.3.3 (arm-arago-linux-gnueabi)
compiled by GNU C version 4.4.3, GMP version 4.2.4, MPFR version 3.0.0-p7.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 05177eff49440274f3899a250a52b5a7
COLLECT_GCC_OPTIONS='-c' '-I../UsageEnvironment/include' '-I../groupsock/include' '-I../liveMedia/include' '-I../BasicUsageEnvironment/include' '-I.' '-O3' '-v' '-DSOCKLEN_T=socklen_t' '-DNO_STRSTREAM=1' '-D_LARGEFILE_SOURCE=1' '-D_FILE_OFFSET_BITS=64' '-Wall' '-DBSD=1' '-shared-libgcc' '-mfloat-abi=soft'
../lib/gcc/arm-arago-linux-gnueabi/4.3.3/../../../../arm-arago-linux-gnueabi/bin/as -mfloat-abi=soft -meabi=4 -o testMP3Streamer.o /tmp/cckqq421.s
COMPILER_PATH=../libexec/gcc/arm-arago-linux-gnueabi/4.3.3/:../libexec/gcc/:../lib/gcc/arm-arago-linux-gnueabi/4.3.3/../../../../arm-arago-linux-gnueabi/bin/
LIBRARY_PATH=../lib/gcc/arm-arago-linux-gnueabi/4.3.3/:../lib/gcc/:../lib/gcc/arm-arago-linux-gnueabi/4.3.3/../../../../arm-arago-linux-gnueabi/lib/:../arm-arago-linux-gnueabi/lib/:../arm-arago-linux-gnueabi/usr/lib/
COLLECT_GCC_OPTIONS='-c' '-I../UsageEnvironment/include' '-I../groupsock/include' '-I../liveMedia/include' '-I../BasicUsageEnvironment/include' '-I.' '-O3' '-v' '-DSOCKLEN_T=socklen_t' '-DNO_STRSTREAM=1' '-D_LARGEFILE_SOURCE=1' '-D_FILE_OFFSET_BITS=64' '-Wall' '-DBSD=1' '-shared-libgcc' '-mfloat-abi=soft'
/ipnc_rdk/../dvsdk_ipnctools/linux-devkit//bin/arm-arago-linux-gnueabi-g++ -otestMP3Streamer -L. testMP3Streamer.o ../liveMedia/libliveMedia.a ../groupsock/libgroupsock.a ../BasicUsageEnvironment/libBasicUsageEnvironment.a ../UsageEnvironment/libUsageEnvironment.a
../liveMedia/libliveMedia.a: In function `RTPSink::presetNextTimestamp()':
Locale.cpp:(.text+0x3232c): undefined reference to `clock_gettime'
../liveMedia/libliveMedia.a: In function `RTCPInstance::addSR()':
Locale.cpp:(.text+0x36dd8): undefined reference to `clock_gettime'
../BasicUsageEnvironment/libBasicUsageEnvironment.a: In function `TimeNow()':
BasicHashTable.cpp:(.text+0x1edc): undefined reference to `clock_gettime'
../BasicUsageEnvironment/libBasicUsageEnvironment.a: In function `DelayQueue::DelayQueue()':
BasicHashTable.cpp:(.text+0x2378): undefined reference to `clock_gettime'
../BasicUsageEnvironment/libBasicUsageEnvironment.a: In function `DelayQueue::DelayQueue()':
BasicHashTable.cpp:(.text+0x2414): undefined reference to `clock_gettime'
../BasicUsageEnvironment/libBasicUsageEnvironment.a:BasicHashTable.cpp:(.text+0x246c): more undefined references to `clock_gettime' follow
collect2: ld returned 1 exit status
make[10]: *** [testMP3Streamer] Error 1
Unfortunately I can't attach the full output or contents of the makefile as I seem to have hit the post length limit! Here is most of one of the makefiles, I have put ...snip... where I have cut out a lot of similar entries that you can probably guess what was going on:
INCLUDES = -Iinclude -I../UsageEnvironment/include -I../groupsock/include
PREFIX = /usr/local
LIBDIR = $(PREFIX)/lib
##### Change the following for your environment:
CROSS_COMPILE= $(MVTOOL_PREFIX)
COMPILE_OPTS = $(INCLUDES) -I. -v -Wall -O3 -DSOCKLEN_T=socklen_t -DNO_STRSTREAM=1 -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 -Wl,--verbose -lrt
### JU - Added -lrt for MONOTONIC CLOCK in RTPSink.cpp
C = c
C_COMPILER = $(CROSS_COMPILE)gcc
C_FLAGS = $(COMPILE_OPTS)
CPP = cpp
CPLUSPLUS_COMPILER = $(CROSS_COMPILE)g++
CPLUSPLUS_FLAGS = $(COMPILE_OPTS) -DBSD=1
OBJ = o
LINK = $(CROSS_COMPILE)g++ -o
LINK_OPTS = -L.
CONSOLE_LINK_OPTS = $(LINK_OPTS)
LIBRARY_LINK = $(CROSS_COMPILE)ld -o
LIBRARY_LINK_OPTS = $(LINK_OPTS) -r -Bstatic
LIB_SUFFIX = a
LIBS_FOR_CONSOLE_APPLICATION =
LIBS_FOR_GUI_APPLICATION =
EXE =
##### End of variables to change
NAME = libliveMedia
LIVEMEDIA_LIB = $(NAME).$(LIB_SUFFIX)
ALL = $(LIVEMEDIA_LIB)
all: $(ALL)
.$(C).$(OBJ):
$(C_COMPILER) -c $(C_FLAGS) $<
.$(CPP).$(OBJ):
$(CPLUSPLUS_COMPILER) -c $(CPLUSPLUS_FLAGS) $<
MP3_SOURCE_OBJS = MP3FileSource.$(OBJ) ...snip... MP3InternalsHuffman.$(OBJ) MP3InternalsHuffmanTable.$(OBJ) MP3ADURTPSource.$(OBJ)
MPEG_SOURCE_OBJS = MPEG1or2Demux.$(OBJ) ...snip... ADTSAudioFileSource.$(OBJ)
H263_SOURCE_OBJS = H263plusVideoRTPSource.$(OBJ) H263plusVideoStreamFramer.$(OBJ) H263plusVideoStreamParser.$(OBJ)
AC3_SOURCE_OBJS = AC3AudioStreamFramer.$(OBJ) AC3AudioRTPSource.$(OBJ)
DV_SOURCE_OBJS = DVVideoStreamFramer.$(OBJ) DVVideoRTPSource.$(OBJ)
MP3_SINK_OBJS = MP3ADURTPSink.$(OBJ)
MPEG_SINK_OBJS = MPEG1or2AudioRTPSink.$(OBJ) $(MP3_SINK_OBJS) MPEG1or2VideoRTPSink.$(OBJ) MPEG4LATMAudioRTPSink.$(OBJ) MPEG4GenericRTPSink.$(OBJ) MPEG4ESVideoRTPSink.$(OBJ)
H263_SINK_OBJS = H263plusVideoRTPSink.$(OBJ)
H264_OR_5_SINK_OBJS = H264or5VideoRTPSink.$(OBJ) H264VideoRTPSink.$(OBJ) H265VideoRTPSink.$(OBJ)
DV_SINK_OBJS = DVVideoRTPSink.$(OBJ)
AC3_SINK_OBJS = AC3AudioRTPSink.$(OBJ)
MISC_SOURCE_OBJS = MediaSource.$(OBJ) ...snip... StreamReplicator.$(OBJ)
MISC_SINK_OBJS = MediaSink.$(OBJ) ...snip... OutputFile.$(OBJ)
MISC_FILTER_OBJS = uLawAudioFilter.$(OBJ)
TRANSPORT_STREAM_TRICK_PLAY_OBJS = MPEG2IndexFromTransportStream.$(OBJ) MPEG2TransportStreamIndexFile.$(OBJ) MPEG2TransportStreamTrickModeFilter.$(OBJ)
RTP_SOURCE_OBJS = RTPSource.$(OBJ) ...snip... VP9VideoRTPSource.$(OBJ)
RTP_SINK_OBJS = RTPSink.$(OBJ) MultiFramedRTPSink.$(OBJ) AudioRTPSink.$(OBJ) VideoRTPSink.$(OBJ) TextRTPSink.$(OBJ)
RTP_INTERFACE_OBJS = RTPInterface.$(OBJ)
RTP_OBJS = $(RTP_SOURCE_OBJS) $(RTP_SINK_OBJS) $(RTP_INTERFACE_OBJS)
RTCP_OBJS = RTCP.$(OBJ) rtcp_from_spec.$(OBJ)
GENERIC_MEDIA_SERVER_OBJS = GenericMediaServer.$(OBJ)
RTSP_OBJS = RTSPServer.$(OBJ) RTSPClient.$(OBJ) RTSPCommon.$(OBJ) RTSPServerSupportingHTTPStreaming.$(OBJ) RTSPRegisterSender.$(OBJ)
SIP_OBJS = SIPClient.$(OBJ)
SESSION_OBJS = MediaSession.$(OBJ) ...snip... ProxyServerMediaSession.$(OBJ)
QUICKTIME_OBJS = QuickTimeFileSink.$(OBJ) QuickTimeGenericRTPSource.$(OBJ)
AVI_OBJS = AVIFileSink.$(OBJ)
MATROSKA_FILE_OBJS = MatroskaFile.$(OBJ) MatroskaFileParser.$(OBJ) EBMLNumber.$(OBJ) MatroskaDemuxedTrack.$(OBJ)
MATROSKA_SERVER_MEDIA_SUBSESSION_OBJS = MatroskaFileServerMediaSubsession.$(OBJ) MP3AudioMatroskaFileServerMediaSubsession.$(OBJ)
MATROSKA_RTSP_SERVER_OBJS = MatroskaFileServerDemux.$(OBJ) $(MATROSKA_SERVER_MEDIA_SUBSESSION_OBJS)
MATROSKA_OBJS = $(MATROSKA_FILE_OBJS) $(MATROSKA_RTSP_SERVER_OBJS)
OGG_FILE_OBJS = OggFile.$(OBJ) OggFileParser.$(OBJ) OggDemuxedTrack.$(OBJ)
OGG_SERVER_MEDIA_SUBSESSION_OBJS = OggFileServerMediaSubsession.$(OBJ)
OGG_RTSP_SERVER_OBJS = OggFileServerDemux.$(OBJ) $(OGG_SERVER_MEDIA_SUBSESSION_OBJS)
OGG_OBJS = $(OGG_FILE_OBJS) $(OGG_RTSP_SERVER_OBJS)
MISC_OBJS = BitVector.$(OBJ) StreamParser.$(OBJ) DigestAuthentication.$(OBJ) ourMD5.$(OBJ) Base64.$(OBJ) Locale.$(OBJ)
LIVEMEDIA_LIB_OBJS = Media.$(OBJ) $(MISC_SOURCE_OBJS) $(MISC_SINK_OBJS) $(MISC_FILTER_OBJS) $(RTP_OBJS) $(RTCP_OBJS) $(GENERIC_MEDIA_SERVER_OBJS) $(RTSP_OBJS) $(SIP_OBJS) $(SESSION_OBJS) $(QUICKTIME_OBJS) $(AVI_OBJS) $(TRANSPORT_STREAM_TRICK_PLAY_OBJS) $(MATROSKA_OBJS) $(OGG_OBJS) $(MISC_OBJS)
$(LIVEMEDIA_LIB): $(LIVEMEDIA_LIB_OBJS) \
$(PLATFORM_SPECIFIC_LIB_OBJS)
$(LIBRARY_LINK)$# $(LIBRARY_LINK_OPTS) \
$(LIVEMEDIA_LIB_OBJS)
Media.$(CPP): include/Media.hh
include/Media.hh: include/liveMedia_version.hh
MediaSource.$(CPP): include/MediaSource.hh
include/MediaSource.hh: include/Media.hh
FramedSource.$(CPP): include/FramedSource.hh
include/FramedSource.hh: include/MediaSource.hh
...snip...
ourMD5.$(CPP): include/ourMD5.hh
Base64.$(CPP): include/Base64.hh
Locale.$(CPP): include/Locale.hh
include/liveMedia.hh:: include/MPEG1or2AudioRTPSink.hh ...snip... include/VP9VideoRTPSource.hh
include/liveMedia.hh:: include/MPEG2TransportStreamFromPESSource.hh ...snip... include/RTSPRegisterSender.hh
include/liveMedia.hh:: include/RTSPServerSupportingHTTPStreaming.hh ...snip... include/ProxyServerMediaSession.hh
clean:
-rm -rf *.$(OBJ) $(ALL) core *.core *~ include/*~
install: install1 $(INSTALL2)
install1: $(LIVEMEDIA_LIB)
install -d $(DESTDIR)$(PREFIX)/include/liveMedia $(DESTDIR)$(LIBDIR)
install -m 644 include/*.hh $(DESTDIR)$(PREFIX)/include/liveMedia
install -m 644 $(LIVEMEDIA_LIB) $(DESTDIR)$(LIBDIR)
install_shared_libraries: $(LIVEMEDIA_LIB)
ln -fs $(NAME).$(LIB_SUFFIX) $(DESTDIR)$(LIBDIR)/$(NAME).$(SHORT_LIB_SUFFIX)
ln -fs $(NAME).$(LIB_SUFFIX) $(DESTDIR)$(LIBDIR)/$(NAME).so
##### Any additional, platform-specific rules come here:
You have added -lrt - and apparently also -Wl,--verbose - to the
definition of COMPILE_OPTS. That will not work, because the $(COMPILE_OPTS)
are only passed to invocations of the compiler, and -lrt is a linker
option, which you must pass to the invocation of the linker for it have any
effect.
Remove -lrt from the definition of COMPILE_OPTS and add it to the
definition of LIBRARY_LINK_OPTS.
(The same applies to -Wl,--verbose, though you have probably only
introduced it for debugging. You clearly know that -Wl,option means
pass option through to the linker. But this instruction is addressed to
the gcc/g++ tool-driver and is effective when it is invoking the linker,
not when it is invoking the compiler. Hence you have verbose compiler output,
due to -v` option, but no verbose linker output).
I am having two problems with makefile which I can not figure out myself. Hence, some help would be appreciated.
Also, I am new to linux and makefile. So, I would appreciate if someone can guide me to relevant resources for understanding these.
Successful run: I can run this makefile successfully, if I can do the following:
A) $gcc -c tsnnls_test_DKU.c
B) then, $make
3) I can call my function successfully.
1) Unsuccessful run: However, if I do comment in following in my make file
# Here is a simple Make Macro.
LINK_TARGET = tsnnls_test_DKU
OBJS_LOC = tsnnls_test_DKU.o
tsnnls_test_DKU.o: tsnnls_test_DKU.c
gcc tsnnls_test_DKU.c
Then, then do $make, I get errors
dkumar#dkumar-Precision-WorkStation-T7500 ~/libtsnnls-2.3.3/tsnnls $ make
gcc tsnnls_test_DKU.c
/tmp/ccvbnByX.o: In function `lsqrwrapper':
tsnnls_test_DKU.c:(.text+0x598): undefined reference to `alloc_lsqr_mem'
tsnnls_test_DKU.c:(.text+0x6a8): undefined reference to `sparse_lsqr_mult'
tsnnls_test_DKU.c:(.text+0x6c7): undefined reference to `lsqr'
tsnnls_test_DKU.c:(.text+0x742): undefined reference to `free_lsqr_mem'
/tmp/ccvbnByX.o: In function `main':
tsnnls_test_DKU.c:(.text+0x9cb): undefined reference to `taucs_construct_sorted_ccs_matrix'
tsnnls_test_DKU.c:(.text+0xb15): undefined reference to `t_snnls_fallback'
tsnnls_test_DKU.c:(.text+0xb66): undefined reference to `t_snnls'
tsnnls_test_DKU.c:(.text+0xc92): undefined reference to `colvector_write_mat'
tsnnls_test_DKU.c:(.text+0xcce): undefined reference to `taucs_ccs_free'
collect2: error: ld returned 1 exit status
make: *** [tsnnls_test_DKU.o] Error 1
2) Unsuccessful run: Also, if I comment out "clean: .." part in makefile, it just cleans up and does not make when I try:
A) $gcc -c tsnnls_test_DKU.c
B) then, $make
then, I get the following output:
dkumar#dkumar-Precision-WorkStation-T7500 ~/libtsnnls-2.3.3/tsnnls $ make
rm -f tsnnls_test_DKU
echo Clean done
Clean done
Here is my makefile
# A sample Makefile
# Here is a simple Make Macro.
LINK_TARGET = tsnnls_test_DKU
OBJS_LOC = tsnnls_test_DKU.o
#tsnnls_test_DKU.o: tsnnls_test_DKU.c
# gcc tsnnls_test_DKU.c
# Here is a Make Macro that uses the backslash to extend to multiple lines.
OBJS = libtsnnls_la-taucs_malloc.o libtsnnls_la-taucs_ccs_order.o \
libtsnnls_la-taucs_ccs_ops.o libtsnnls_la-taucs_vec_base.o \
libtsnnls_la-taucs_complex.o libtsnnls_la-colamd.o \
libtsnnls_la-amdbar.o libtsnnls_la-amdexa.o \
libtsnnls_la-amdtru.o libtsnnls_la-genmmd.o \
libtsnnls_la-taucs_timer.o libtsnnls_la-taucs_sn_llt.o \
libtsnnls_la-taucs_ccs_base.o libtsnnls_la-tlsqr.o \
libtsnnls_la-tsnnls.o libtsnnls_la-lsqr.o \
$(OBJS_LOC)
REBUILDABLES = $(LINK_TARGET)
##DK COMMENTED OUT THE CLEANING PART
#clean :
# rm -f $(REBUILDABLES)
# echo Clean done
all : $(LINK_TARGET)
echo All done
#Inclusion of all libraries
RANLIB = ranlib
STATICLIB= /usr/local/lib/taucs_full/lib/linux/libtaucs.a
tsnnls_test_LDADD = $(LDADD)
LIBS = -largtable2 -llapack -lblas -lquadmath -lm
$(LINK_TARGET) : $(OBJS) $(tsnnls_test_LDADD) $(LIBS) $(STATICLIB)
gcc -g -o $# $^