Compile Linux Kernel Module - Cannot build simple kernel module - module

I'm trying to compile a kernel module driver but I get the following errors: (the operation generate some files, but not a ".ko" file)
make -C /lib/modules/5.16.0-kali7-amd64/build M=/home/z3r0/Scrivania/kernel_modules/start_stop modules
make[1]: ingresso nella directory «/usr/src/linux-headers-5.16.0-kali7-amd64»
/bin/sh: 1: /usr/src/linux-headers-5.16.0-kali7-common/scripts/pahole-flags.sh: not found
ERROR: Kernel configuration is invalid.
include/generated/autoconf.h or include/config/auto.conf are missing.
Run 'make oldconfig && make prepare' on kernel src to fix it.
make[1]: *** [/usr/src/linux-headers-5.16.0-kali7-common/Makefile:751: include/config/auto.conf] Errore 1
make[1]: uscita dalla directory «/usr/src/linux-headers-5.16.0-kali7-amd64»
make: *** [Makefile:3: all] Errore 2
When I try to execute "make oldconfig && make prepare" I get the following error:
/bin/sh: 1: /usr/src/linux-headers-5.16.0-kali7-common/scripts/pahole-flags.sh: not found
GEN Makefile
/bin/sh: 1: /usr/src/linux-headers-5.16.0-kali7-common/scripts/pahole-flags.sh: not found
/usr/src/linux-headers-5.16.0-kali7-common/scripts/Makefile.build:44: /usr/src/linux-headers-5.16.0-kali7-common/scripts/basic/Makefile: File o directory non esistente
make[1]: *** Nessuna regola per generare l'obiettivo «/usr/src/linux-headers-5.16.0-kali7-common/scripts/basic/Makefile». Arresto.
make: *** [/usr/src/linux-headers-5.16.0-kali7-common/Makefile:566: scripts_basic] Errore 2
The file is really simple (hello_world.c):
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
static int __init hello_start(void)
{
printk(KERN_INFO "Loading hello module...\n");
printk(KERN_INFO "Hello world\n");
return 0;
}
static void __exit hello_end(void)
{
printk(KERN_INFO "Goodbye Mr.\n");
}
module_init(hello_start);
module_exit(hello_end);
makefile:
obj-m = foo.o
KVERSION = $(shell uname -r)
all:
make -C /lib/modules/$(KVERSION)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(KVERSION)/build M=$(PWD) clean
Can someone explain where is the error? Thank you

Related

'Undefined reference to "WinMain#16" ' while setting up SDL2 with CMake

So I want to learn how to use CMake (specifically in CLion), and right now I'm trying to set up SDL2 with it. I got FindSDL2.cmake in my Modules folder, and this is my code:
CMakeLists.txt:
cmake_minimum_required(VERSION 3.13)
project(CLion_Tests)
set(CMAKE_CXX_STANDARD 11)
set(SDL2_PATH "C:/Users/Lerchi/Downloads/SDL/SDL2main/64")
find_package(SDL2 REQUIRED)
include_directories(${SDL2_INCLUDE_DIR})
add_executable(CLion_Tests main.cpp)
target_link_libraries(CLion_Tests ${SDL2_LIBRARY})
and main.cpp is just this:
#include <iostream>
#include <SDL.h>
int main(int argc, char* args[]) {
SDL_Init(SDL_INIT_EVERYTHING);
std::cout << "Hello, World!" << std::endl;
return 0;
}
The error I'm getting is
CMakeFiles\CLion_Tests.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x1c): undefined reference to `SDL_Init'
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libmingw32.a(main.o):(.text.startup+0xa0): undefined reference to `WinMain#16'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[2]: *** [CLion_Tests.exe] Error 1
CMakeFiles\CLion_Tests.dir\build.make:87: recipe for target 'CLion_Tests.exe' failed
mingw32-make.exe[1]: *** [CMakeFiles/CLion_Tests.dir/all] Error 2
CMakeFiles\Makefile2:71: recipe for target 'CMakeFiles/CLion_Tests.dir/all' failed
mingw32-make.exe: *** [all] Error 2
Makefile:82: recipe for target 'all' failed

Undefined references in Apache user-written module

I have some undefined reference errors in an Apache module. I've cut the source code down to a minimum that reproduced the error. Below is the source for "mod_test.c" ...
#include "httpd.h"
#include "http_config.h"
#include "http_request.h"
#include "http_protocol.h"
#include "http_core.h"
#include "http_main.h"
#include "http_log.h"
#include "ap_mpm.h"
#include "apr_strings.h"
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <netdb.h>
module AP_MODULE_DECLARE_DATA test_module;
static int test_handler(request_rec *r);
static int test_init(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s);
/* Structure containing state information for the module */
typedef struct {
} ns_mod_config;
static int ns_typematch(request_rec *r) {
ns_mod_config *ns_scfg = ap_get_module_config(r->server->module_config,
&test_module);
core_request_config *creq_cfg;
creq_cfg = ap_get_core_module_config(r->request_config);
return 0;
}
module AP_MODULE_DECLARE_DATA test_module = {
STANDARD20_MODULE_STUFF,NULL,NULL,NULL,NULL,NULL,NULL};
I am using a more-or-less standard Makefile for compiling the module (note that the install option has been removed as this is a test to demonstrate the problem.)
APXS=/usr/local/apache2/bin/apxs
APXS_OPTS=-Wc, -Wc,-DDST_CLASS=3
SRC=src/mod_test.c
OBJ=src/.libs/mod_test.so
$(OBJ): $(SRC)
#echo
$(APXS) $(APXS_OPTS) -c $(SRC)
#echo
#echo write '"make install"' to install module
#echo
clean:
rm -f src/.libs/*
rm -f src/*.o
rm -f src/*.lo
rm -f src/*.la
rm -f src/*.slo
rmdir src/.libs
The compile fails as follows:
/usr/local/apache2/bin/apxs -Wc, -Wc,-DDST_CLASS=3 -c src/mod_test.c
/usr/local/apache2/build/libtool --silent --mode=compile gcc -prefer-pic -DLINUX -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -g -O2 -pthread -I/usr/local/apache2/include -I/usr/local/apache2/include -I/usr/local/apache2/include -DDST_CLASS=3 -c -o src/mod_test.lo src/mod_test.c && touch src/mod_test.slo
src/mod_test.c: In function âns_typematchâ:
src/mod_test.c:34:3: error: unknown type name âcore_request_configâ
core_request_config *creq_cfg;
^~~~~~~~~~~~~~~~~~~
src/mod_test.c:35:14: warning: implicit declaration of function âap_get_core_module_configâ [-Wimplicit-function-declaration]
creq_cfg = ap_get_core_module_config(r->request_config);
^~~~~~~~~~~~~~~~~~~~~~~~~
src/mod_test.c:35:12: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
creq_cfg = ap_get_core_module_config(r->request_config);
^
apxs:Error: Command failed with rc=65536
.
Makefile:23: recipe for target 'src/.libs/mod_test.so' failed
make: *** [src/.libs/mod_test.so] Error 1
I am not sure how this can occur. http_core.h is present in /usr/local/apache2/include and it does include the definitions that are claimed missing by the compile. Six other modules on the same system compile without errors, though none of them use this specific reference to the core data structures.
Help will be gratefully received.
After posting to the Apache modules mailing list, it develops that the problem is in two parts.
Defining CORE_PRIVATE is required under Apache 2.2 to have access to the core data structures.
ap_get_core_module_config is an Apache 2.4 construct.

bazel build aot with cross tool failed in platform.h fatal error 'mutex' file not found

I am trying aot cross compiling with bazel.But failed in platform.h fatal error 'mutex' file not found.I can build with bazel without cross compile setting, and I can exec the binary in host.
My environment is below
x86-64 ubuntu14.04
target:arm-linux-gnueabihf
tensorflow:Head of maste cd5f3b67fca88217776522182481b0c128db5af9
bazel:0.5.4 installed by apt-get install
My test code is below.
#define EIGEN_USE_THREADS
#define EIGEN_USE_CUSTOM_THREAD_POOL
#include <iostream>
#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
#include "tensorflow/compiler/aot/tests/test_graph_tfmatmul.h" // generated
int main(int argc, char** argv) {
Eigen::ThreadPool tp(2); // Size the thread pool as appropriate.
Eigen::ThreadPoolDevice device(&tp, tp.NumThreads());
foo::bar::MatMulComp matmul;
matmul.set_thread_pool(&device);
// Set up args and run the computation.
const float args[12] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
std::copy(args + 0, args + 6, matmul.arg0_data());
std::copy(args + 6, args + 12, matmul.arg1_data());
matmul.Run();
// Check result
if (matmul.result0(0, 0) == 58) {
std::cout << "Success" << std::endl;
} else {
std::cout << "Failed. Expected value 58 at 0,0. Got:"
<< matmul.result0(0, 0) << std::endl;
}
return 0;
}
I modified the some files to compile.
add cross compile setting to WORKSPACE file
new_local_repository( name = "linaroLinuxGcc49Repo", build_file =
"compilers/linaro_linux_gcc_4.9.BUILD", path =
"compilers/gcc-linaro-4.9-2016.02-x86_64_arm-linux-gnueabihf", )
add build setting in /tensorflow/compiler/aot/tests/BUILD
cc_binary(
name = "my_binary",
srcs = [
"my_code.cc", # include test_graph_tfmatmul.h to access the generated header
],
deps = [
":test_graph_tfmatmul", # link in the generated object file
"//third_party/eigen3",
],
linkopts = [
"-lpthread",
] )
Below is the build command I did.
bazel build --copt=-Wno-c++11-narrowing --cxxopt='-std=c++11'
//tensorflow/compiler/aot/tests:my_binary
--host_crosstool_top=#bazel_tools//tools/cpp:toolchain --crosstool_top=//tools/arm_compiler:toolchain --cpu=armeabi-v7a --verbose_failures
Finally I get the error below.
(root) user-name#machine-name:repo
[master]$ bazel build --copt=-Wno-c++11-narrowing
--cxxopt='-std=c++11' //tensorflow/compiler/aot/tests:my_binary --host_crosstool_top=#bazel_tools//tools/cpp:toolchain --crosstool_top=//tools/arm_compiler:toolchain --cpu=armeabi-v7a --verbose_failures WARNING: /home/user-name/tensorflow/repo/tensorflow/core/BUILD:1772:1: in
includes attribute of cc_library rule
//tensorflow/core:framework_headers_lib: '../../external/nsync/public'
resolves to 'external/nsync/public' not below the relative path of its
package 'tensorflow/core'. This will be an error in the future. Since
this rule was created by the macro 'cc_header_only_library', the error
might have been caused by the macro implementation in
/home/user-name/tensorflow/repo/tensorflow/tensorflow.bzl:1029:30
WARNING:
/home/user-name/tensorflow/repo/tensorflow/contrib/learn/BUILD:15:1:
in py_library rule //tensorflow/contrib/learn:learn: target
'//tensorflow/contrib/learn:learn' depends on deprecated target
'//tensorflow/contrib/session_bundle:exporter': No longer supported.
Switch to SavedModel immediately. WARNING:
/home/user-name/tensorflow/repo/tensorflow/contrib/learn/BUILD:15:1:
in py_library rule //tensorflow/contrib/learn:learn: target
'//tensorflow/contrib/learn:learn' depends on deprecated target
'//tensorflow/contrib/session_bundle:gc': No longer supported. Switch
to SavedModel immediately. INFO: Analysed target
//tensorflow/compiler/aot/tests:my_binary (0 packages loaded). INFO:
Found 1 target... ERROR:
/home/user-name/.cache/bazel/_bazel_user-name/6d2eb697f6f4dfadad89ea8a861fded5/external/nsync/BUILD:397:1:
C++ compilation of rule '#nsync//:nsync_cpp' failed (Exit 1): clang
failed: error executing command (cd
/home/user-name/.cache/bazel/_bazel_user-name/6d2eb697f6f4dfadad89ea8a861fded5/execroot/org_tensorflow
&& \ exec env - \
PWD=/proc/self/cwd \
PYTHON_BIN_PATH=/home/user-name/.pyenv/versions/anaconda3-4.4.0/bin/python
\
PYTHON_LIB_PATH=/home/user-name/.pyenv/versions/anaconda3-4.4.0/lib/python3.6/site-packages
\
TF_NEED_CUDA=0 \
TF_NEED_OPENCL=0 \ tools/arm_compiler/linaro_linux_gcc/clang_bin/clang -target
armv7a-arm-linux-gnueabif
'--sysroot=external/linaroLinuxGcc49Repo/arm-linux-gnueabihf/libc'
'-mfloat-abi=hard' -nostdinc -isystem /usr/lib/clang/3.6/include
-isystem external/linaroLinuxGcc49Repo/lib/gcc/arm-linux-gnueabihf/4.9.4/include
-isystem external/linaroLinuxGcc49Repo/arm-linux-gnueabihf/libc/usr/include
-isystem external/linaroLinuxGcc49Repo/lib/gcc/arm-linux-gnueabihf/4.9.4/include-fixed
-isystem external/linaroLinuxGcc49Repo/arm-linux-gnueabihf/libc/usr/include
-isystem external/linaroLinuxGcc49Repo/include/c++/4.9.4 -U_FORTIFY_SOURCE -fstack-protector -fPIE '-fdiagnostics-color=always' -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 -DNDEBUG -ffunction-sections -fdata-sections -Wno-c++11-narrowing -MD -MF bazel-out/clang_linux_armhf-py3-opt/bin/external/nsync/_objs/nsync_cpp/external/nsync/internal/sem_wait.d
-iquote external/nsync -iquote bazel-out/clang_linux_armhf-py3-opt/genfiles/external/nsync -iquote
external/bazel_tools -iquote
bazel-out/clang_linux_armhf-py3-opt/genfiles/external/bazel_tools
-isystem external/nsync/public -isystem bazel-out/clang_linux_armhf-py3-opt/genfiles/external/nsync/public
-isystem external/bazel_tools/tools/cpp/gcc3 -x c++ '-std=c++11' -DNSYNC_ATOMIC_CPP11 -DNSYNC_USE_CPP11_TIMEPOINT -I./external/nsync//platform/c++11 -I./external/nsync//platform/gcc -I./external/nsync//platform/arm -I./external/nsync//public -I./external/nsync//internal -I./external/nsync//platform/posix '-D_POSIX_C_SOURCE=200809L' -pthread -no-canonical-prefixes
-Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c
external/nsync/internal/sem_wait.c -o
bazel-out/clang_linux_armhf-py3-opt/bin/external/nsync/_objs/nsync_cpp/external/nsync/internal/sem_wait.o)
warning: unknown warning option '-Wunused-but-set-parameter'; did you
mean '-Wunused-parameter'? [-Wunknown-warning-option] warning: unknown
warning option '-Wno-free-nonheap-object'; did you mean
'-Wno-sequence-point'? [-Wunknown-warning-option] In file included
from external/nsync/internal/sem_wait.c:16:
./external/nsync//platform/c++11/platform.h:29:10: fatal error:
'mutex' file not found
#include
^ 2 warnings and 1 error generated. Target //tensorflow/compiler/aot/tests:my_binary failed to build INFO:
Elapsed time: 0.917s, Critical Path: 0.15s FAILED: Build did NOT
complete successfully
Error occures in "C++ compilation of rule '#nsync//:nsync_cpp' failed (Exit 1):" .
Befause of "./external/nsync//platform/c++11/platform.h:29:10: fatal error: 'mutex' file not found
#include
"
The file mutex is exist in ./compilers/gcc-linaro-4.9-2016.02-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/4.9.4/mutex.
I think path above is setted in the build output line "-isystem external/linaroLinuxGcc49Repo/include/c++/4.9.4"
How could I set the path to mutex? for cross compiling nsync?
I made a mistake when I edit CROSSTOOL file.
If you know detail, please refer below.
https://github.com/bazelbuild/bazel/issues/3836
thanks!

trouble building trilininos using cmake

I am trying to build trilinos in fedora25 guest (virtualbox). Followed procedure described here:
http://iltabiai.github.io/peridynamics/fedora/tips/2016/04/20/Peridigm141-Fedora23.html
I had to adapt the build script from above link so that it could find Netcdf and HDF5 on my system.
trilinos builds with these errors in CMakeError.log :
Performing C++ SOURCE FILE Test FINITE_VALUE_HAVE_GLOBAL_ISNAN failed with the following output:
Change Dir: /home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/gmake" "cmTC_44df3/fast"
/usr/bin/gmake -f CMakeFiles/cmTC_44df3.dir/build.make CMakeFiles/cmTC_44df3.dir/build
gmake[1]: Entering directory '/home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_44df3.dir/src.cxx.o
/usr/lib64/mpich/bin/mpicxx -O2 -ansi -pedantic -ftrapv -Wall -Wno-long-long -std=c++11 -DFINITE_VALUE_HAVE_GLOBAL_ISNAN -o CMakeFiles/cmTC_44df3.dir/src.cxx.o -c /home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp/src.cxx
/home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp/src.cxx: In function ‘int main()’:
/home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp/src.cxx:6:10: error: ‘isnan’ was not declared in this scope
isnan(x);
^
/home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp/src.cxx:6:10: note: suggested alternative:
In file included from /home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp/src.cxx:2:0:
/usr/include/c++/6.3.1/cmath:662:5: note: ‘std::isnan’
isnan(_Tp __x)
^~~~~
CMakeFiles/cmTC_44df3.dir/build.make:65: recipe for target 'CMakeFiles/cmTC_44df3.dir/src.cxx.o' failed
gmake[1]: *** [CMakeFiles/cmTC_44df3.dir/src.cxx.o] Error 1
gmake[1]: Leaving directory '/home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_44df3/fast' failed
gmake: *** [cmTC_44df3/fast] Error 2
Source file was:
#include <cmath>
int main()
{
double x = 1.0;
isnan(x);
return 0;
}
Performing C++ SOURCE FILE Test FINITE_VALUE_HAVE_GLOBAL_ISINF failed with the following output:
Change Dir: /home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/gmake" "cmTC_4cb6e/fast"
/usr/bin/gmake -f CMakeFiles/cmTC_4cb6e.dir/build.make CMakeFiles/cmTC_4cb6e.dir/build
gmake[1]: Entering directory '/home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_4cb6e.dir/src.cxx.o
/usr/lib64/mpich/bin/mpicxx -O2 -ansi -pedantic -ftrapv -Wall -Wno-long-long -std=c++11 -DFINITE_VALUE_HAVE_GLOBAL_ISINF -o CMakeFiles/cmTC_4cb6e.dir/src.cxx.o -c /home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp/src.cxx
/home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp/src.cxx: In function ‘int main()’:
/home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp/src.cxx:6:10: error: ‘isinf’ was not declared in this scope
isinf(x);
^
/home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp/src.cxx:6:10: note: suggested alternative:
In file included from /home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp/src.cxx:2:0:
/usr/include/c++/6.3.1/cmath:635:5: note: ‘std::isinf’
isinf(_Tp __x)
^~~~~
CMakeFiles/cmTC_4cb6e.dir/build.make:65: recipe for target 'CMakeFiles/cmTC_4cb6e.dir/src.cxx.o' failed
gmake[1]: *** [CMakeFiles/cmTC_4cb6e.dir/src.cxx.o] Error 1
gmake[1]: Leaving directory '/home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_4cb6e/fast' failed
gmake: *** [cmTC_4cb6e/fast] Error 2
Source file was:
#include <cmath>
int main()
{
double x = 1.0;
isinf(x);
return 0;
}
Determining if the pthread_create exist failed with the following output:
Change Dir: /home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/gmake" "cmTC_78ecb/fast"
/usr/bin/gmake -f CMakeFiles/cmTC_78ecb.dir/build.make CMakeFiles/cmTC_78ecb.dir/build
gmake[1]: Entering directory '/home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_78ecb.dir/CheckSymbolExists.c.o
/usr/lib64/mpich/bin/mpicc -o CMakeFiles/cmTC_78ecb.dir/CheckSymbolExists.c.o -c /home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c
Linking C executable cmTC_78ecb
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_78ecb.dir/link.txt --verbose=1
/usr/lib64/mpich/bin/mpicc -rdynamic CMakeFiles/cmTC_78ecb.dir/CheckSymbolExists.c.o -o cmTC_78ecb
/usr/bin/ld: CMakeFiles/cmTC_78ecb.dir/CheckSymbolExists.c.o: undefined reference to symbol 'pthread_create##GLIBC_2.2.5'
/usr/lib64/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_78ecb.dir/build.make:97: recipe for target 'cmTC_78ecb' failed
gmake[1]: *** [cmTC_78ecb] Error 1
gmake[1]: Leaving directory '/home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_78ecb/fast' failed
gmake: *** [cmTC_78ecb/fast] Error 2
File /home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include <pthread.h>
int main(int argc, char** argv)
{
(void)argv;
#ifndef pthread_create
return ((int*)(&pthread_create))[argc];
#else
(void)argc;
return 0;
#endif
}
Determining if the function pthread_create exists in the pthreads failed with the following output:
Change Dir: /home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/gmake" "cmTC_5fb6c/fast"
/usr/bin/gmake -f CMakeFiles/cmTC_5fb6c.dir/build.make CMakeFiles/cmTC_5fb6c.dir/build
gmake[1]: Entering directory '/home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_5fb6c.dir/CheckFunctionExists.c.o
/usr/lib64/mpich/bin/mpicc -DCHECK_FUNCTION_EXISTS=pthread_create -o CMakeFiles/cmTC_5fb6c.dir/CheckFunctionExists.c.o -c /usr/share/cmake/Modules/CheckFunctionExists.c
Linking C executable cmTC_5fb6c
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_5fb6c.dir/link.txt --verbose=1
/usr/lib64/mpich/bin/mpicc -DCHECK_FUNCTION_EXISTS=pthread_create -rdynamic CMakeFiles/cmTC_5fb6c.dir/CheckFunctionExists.c.o -o cmTC_5fb6c -lpthreads
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_5fb6c.dir/build.make:97: recipe for target 'cmTC_5fb6c' failed
gmake[1]: *** [cmTC_5fb6c] Error 1
gmake[1]: Leaving directory '/home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_5fb6c/fast' failed
gmake: *** [cmTC_5fb6c/fast] Error 2
Performing C++ SOURCE FILE Test HAVE_TEUCHOS_LAPACKLARND failed with the following output:
Change Dir: /home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/gmake" "cmTC_93b6d/fast"
/usr/bin/gmake -f CMakeFiles/cmTC_93b6d.dir/build.make CMakeFiles/cmTC_93b6d.dir/build
gmake[1]: Entering directory '/home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_93b6d.dir/src.cxx.o
/usr/lib64/mpich/bin/mpicxx -O2 -ansi -pedantic -ftrapv -Wall -Wno-long-long -std=c++11 -DHAVE_TEUCHOS_LAPACKLARND -o CMakeFiles/cmTC_93b6d.dir/src.cxx.o -c /home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp/src.cxx
/home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp/src.cxx: In function ‘int main()’:
/home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp/src.cxx:12:38: error: narrowing conversion of ‘0.0’ from ‘double’ to ‘int’ inside { } [-Wnarrowing]
int seed[4] = { 0.0, 0.0, 0.0, 1.0 };
^
/home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp/src.cxx:12:38: error: narrowing conversion of ‘0.0’ from ‘double’ to ‘int’ inside { } [-Wnarrowing]
/home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp/src.cxx:12:38: error: narrowing conversion of ‘0.0’ from ‘double’ to ‘int’ inside { } [-Wnarrowing]
/home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp/src.cxx:12:38: error: narrowing conversion of ‘1.0e+0’ from ‘double’ to ‘int’ inside { } [-Wnarrowing]
CMakeFiles/cmTC_93b6d.dir/build.make:65: recipe for target 'CMakeFiles/cmTC_93b6d.dir/src.cxx.o' failed
gmake[1]: *** [CMakeFiles/cmTC_93b6d.dir/src.cxx.o] Error 1
gmake[1]: Leaving directory '/home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_93b6d/fast' failed
gmake: *** [cmTC_93b6d/fast] Error 2
Return value: 1
Source file was:
#define F77_BLAS_MANGLE(name,NAME) name ## _
#define DLARND_F77 F77_BLAS_MANGLE(dlarnd,DLARND)
extern "C" { double DLARND_F77(const int* idist, int* seed); }
int main()
{
const int idist = 1;
int seed[4] = { 0.0, 0.0, 0.0, 1.0 };
double val = DLARND_F77(&idist, seed);
return (val < 0.0 ? 1 : 0);
}
Performing C++ SOURCE FILE Test HAVE_CXX_PRAGMA_WEAK failed with the following output:
Change Dir: /home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/gmake" "cmTC_21bab/fast"
/usr/bin/gmake -f CMakeFiles/cmTC_21bab.dir/build.make CMakeFiles/cmTC_21bab.dir/build
gmake[1]: Entering directory '/home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_21bab.dir/src.cxx.o
/usr/lib64/mpich/bin/mpicxx -O2 -ansi -pedantic -ftrapv -Wall -Wno-long-long -std=c++11 -DHAVE_CXX_PRAGMA_WEAK -o CMakeFiles/cmTC_21bab.dir/src.cxx.o -c /home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp/src.cxx
/home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp/src.cxx: In function ‘int main()’:
/home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp/src.cxx:14:22: warning: the address of ‘void A::theFunction()’ will never be NULL [-Waddress]
if (A::theFunction != NULL) {
^
Linking CXX executable cmTC_21bab
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_21bab.dir/link.txt --verbose=1
/usr/lib64/mpich/bin/mpicxx -O2 -ansi -pedantic -ftrapv -Wall -Wno-long-long -std=c++11 -DHAVE_CXX_PRAGMA_WEAK -rdynamic CMakeFiles/cmTC_21bab.dir/src.cxx.o -o cmTC_21bab
CMakeFiles/cmTC_21bab.dir/src.cxx.o: In function `main':
src.cxx:(.text.startup+0x25): undefined reference to `A::theFunction()'
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_21bab.dir/build.make:97: recipe for target 'cmTC_21bab' failed
gmake[1]: *** [cmTC_21bab] Error 1
gmake[1]: Leaving directory '/home/peri/packages/trilinos-12.10.1-Source/build/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_21bab/fast' failed
gmake: *** [cmTC_21bab/fast] Error 2
Source file was:
#include <iostream>
namespace A {
// theFunction never gets defined, because we
// don't link with a library that defines it.
// That's OK, because it's weak linkage.
#pragma weak theFunction
extern void theFunction ();
}
int main() {
std::cout << "Hi! I am main." << std::endl;
if (A::theFunction != NULL) {
// Should never be called, since we don't link
// with a library that defines A::theFunction.
A::theFunction ();
}
return 0;
}
how can these errors be eliminated?

cmake CHECK_SYMBOL_EXISTS can't find function when cross-compiling OpenAL-Soft for ARM

Im trying to build OpenAL-Soft for an ARM machine (the 3ds) and it stops in the cmake process when CHECK_SYMBOL_EXISTS can't find nanosleep function in time.h i tried commenting the error in CMakeLists.txt to see what would happen and the cmake process works but pthread.h related functions aren't found which causes errors in compilation.
Im using the latest commit from OpenAl soft, i've tried in older versions but same problem. Building with x86 GNU linux compiler works fine.
Im using this toolchain file.
Here's the last part of the CMakeError.log:
Determining if the aligned_alloc exist failed with the following output:
Change Dir: /home/sdk/openal-soft/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_f69e3/fast"
/usr/bin/make -f CMakeFiles/cmTC_f69e3.dir/build.make CMakeFiles/cmTC_f69e3.dir/build
make[1]: se ingresa al directorio «/home/sdk/openal-soft/build/CMakeFiles/CMakeTmp»
Building C object CMakeFiles/cmTC_f69e3.dir/CheckSymbolExists.c.obj
/opt/devkitpro/devkitARM/bin/arm-none-eabi-gcc -DARM11 -D_3DS -fno-gnu89-inline -std=c11 -mword-relocations -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft -D_LARGEFILE_SOURCE -D_LARGE_FILES -o CMakeFiles/cmTC_f69e3.dir/CheckSymbolExists.c.obj -c /home/sdk/openal-soft/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c
/home/sdk/openal-soft/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c: In function 'main':
/home/sdk/openal-soft/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:8:19: error: 'aligned_alloc' undeclared (first use in this function)
return ((int*)(&aligned_alloc))[argc];
^
/home/sdk/openal-soft/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:8:19: note: each undeclared identifier is reported only once for each function it appears in
make[1]: *** [CMakeFiles/cmTC_f69e3.dir/CheckSymbolExists.c.obj] Error 1
make[1]: se sale del directorio «/home/sdk/openal-soft/build/CMakeFiles/CMakeTmp»
make: *** [cmTC_f69e3/fast] Error 2
File /home/sdk/openal-soft/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include <stdlib.h>
int main(int argc, char** argv)
{
(void)argv;
#ifndef aligned_alloc
return ((int*)(&aligned_alloc))[argc];
#else
(void)argc;
return 0;
#endif
}
Determining if the posix_memalign exist failed with the following output:
Change Dir: /home/sdk/openal-soft/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_f69e3/fast"
/usr/bin/make -f CMakeFiles/cmTC_f69e3.dir/build.make CMakeFiles/cmTC_f69e3.dir/build
make[1]: se ingresa al directorio «/home/sdk/openal-soft/build/CMakeFiles/CMakeTmp»
Building C object CMakeFiles/cmTC_f69e3.dir/CheckSymbolExists.c.obj
/opt/devkitpro/devkitARM/bin/arm-none-eabi-gcc -DARM11 -D_3DS -fno-gnu89-inline -std=c11 -mword-relocations -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft -D_LARGEFILE_SOURCE -D_LARGE_FILES -o CMakeFiles/cmTC_f69e3.dir/CheckSymbolExists.c.obj -c /home/sdk/openal-soft/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c
/home/sdk/openal-soft/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c: In function 'main':
/home/sdk/openal-soft/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:8:19: error: 'posix_memalign' undeclared (first use in this function)
return ((int*)(&posix_memalign))[argc];
^
/home/sdk/openal-soft/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:8:19: note: each undeclared identifier is reported only once for each function it appears in
make[1]: *** [CMakeFiles/cmTC_f69e3.dir/CheckSymbolExists.c.obj] Error 1
make[1]: se sale del directorio «/home/sdk/openal-soft/build/CMakeFiles/CMakeTmp»
make: *** [cmTC_f69e3/fast] Error 2
File /home/sdk/openal-soft/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include <stdlib.h>
int main(int argc, char** argv)
{
(void)argv;
#ifndef posix_memalign
return ((int*)(&posix_memalign))[argc];
#else
(void)argc;
return 0;
#endif
}
Determining if the _aligned_malloc exist failed with the following output:
Change Dir: /home/sdk/openal-soft/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_f69e3/fast"
/usr/bin/make -f CMakeFiles/cmTC_f69e3.dir/build.make CMakeFiles/cmTC_f69e3.dir/build
make[1]: se ingresa al directorio «/home/sdk/openal-soft/build/CMakeFiles/CMakeTmp»
Building C object CMakeFiles/cmTC_f69e3.dir/CheckSymbolExists.c.obj
/opt/devkitpro/devkitARM/bin/arm-none-eabi-gcc -DARM11 -D_3DS -fno-gnu89-inline -std=c11 -mword-relocations -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft -D_LARGEFILE_SOURCE -D_LARGE_FILES -o CMakeFiles/cmTC_f69e3.dir/CheckSymbolExists.c.obj -c /home/sdk/openal-soft/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c
/home/sdk/openal-soft/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c: In function 'main':
/home/sdk/openal-soft/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:8:19: error: '_aligned_malloc' undeclared (first use in this function)
return ((int*)(&_aligned_malloc))[argc];
^
/home/sdk/openal-soft/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:8:19: note: each undeclared identifier is reported only once for each function it appears in
make[1]: *** [CMakeFiles/cmTC_f69e3.dir/CheckSymbolExists.c.obj] Error 1
make[1]: se sale del directorio «/home/sdk/openal-soft/build/CMakeFiles/CMakeTmp»
make: *** [cmTC_f69e3/fast] Error 2
File /home/sdk/openal-soft/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include <malloc.h>
int main(int argc, char** argv)
{
(void)argv;
#ifndef _aligned_malloc
return ((int*)(&_aligned_malloc))[argc];
#else
(void)argc;
return 0;
#endif
}
Determining if the _controlfp exist failed with the following output:
Change Dir: /home/sdk/openal-soft/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_f69e3/fast"
/usr/bin/make -f CMakeFiles/cmTC_f69e3.dir/build.make CMakeFiles/cmTC_f69e3.dir/build
make[1]: se ingresa al directorio «/home/sdk/openal-soft/build/CMakeFiles/CMakeTmp»
Building C object CMakeFiles/cmTC_f69e3.dir/CheckSymbolExists.c.obj
/opt/devkitpro/devkitARM/bin/arm-none-eabi-gcc -DARM11 -D_3DS -fno-gnu89-inline -std=c11 -mword-relocations -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft -D_LARGEFILE_SOURCE -D_LARGE_FILES -o CMakeFiles/cmTC_f69e3.dir/CheckSymbolExists.c.obj -c /home/sdk/openal-soft/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c
/home/sdk/openal-soft/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c: In function 'main':
/home/sdk/openal-soft/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:8:19: error: '_controlfp' undeclared (first use in this function)
return ((int*)(&_controlfp))[argc];
^
/home/sdk/openal-soft/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:8:19: note: each undeclared identifier is reported only once for each function it appears in
make[1]: *** [CMakeFiles/cmTC_f69e3.dir/CheckSymbolExists.c.obj] Error 1
make[1]: se sale del directorio «/home/sdk/openal-soft/build/CMakeFiles/CMakeTmp»
make: *** [cmTC_f69e3/fast] Error 2
File /home/sdk/openal-soft/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include <float.h>
int main(int argc, char** argv)
{
(void)argv;
#ifndef _controlfp
return ((int*)(&_controlfp))[argc];
#else
(void)argc;
return 0;
#endif
}
Determining if the __control87_2 exist failed with the following output:
Change Dir: /home/sdk/openal-soft/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_f69e3/fast"
/usr/bin/make -f CMakeFiles/cmTC_f69e3.dir/build.make CMakeFiles/cmTC_f69e3.dir/build
make[1]: se ingresa al directorio «/home/sdk/openal-soft/build/CMakeFiles/CMakeTmp»
Building C object CMakeFiles/cmTC_f69e3.dir/CheckSymbolExists.c.obj
/opt/devkitpro/devkitARM/bin/arm-none-eabi-gcc -DARM11 -D_3DS -fno-gnu89-inline -std=c11 -mword-relocations -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft -D_LARGEFILE_SOURCE -D_LARGE_FILES -o CMakeFiles/cmTC_f69e3.dir/CheckSymbolExists.c.obj -c /home/sdk/openal-soft/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c
/home/sdk/openal-soft/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c: In function 'main':
/home/sdk/openal-soft/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:8:19: error: '__control87_2' undeclared (first use in this function)
return ((int*)(&__control87_2))[argc];
^
/home/sdk/openal-soft/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:8:19: note: each undeclared identifier is reported only once for each function it appears in
make[1]: *** [CMakeFiles/cmTC_f69e3.dir/CheckSymbolExists.c.obj] Error 1
make[1]: se sale del directorio «/home/sdk/openal-soft/build/CMakeFiles/CMakeTmp»
make: *** [cmTC_f69e3/fast] Error 2
File /home/sdk/openal-soft/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include <float.h>
int main(int argc, char** argv)
{
(void)argv;
#ifndef __control87_2
return ((int*)(&__control87_2))[argc];
#else
(void)argc;
return 0;
#endif
}
Determining if the include file windows.h exists failed with the following output:
Change Dir: /home/sdk/openal-soft/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_f69e4/fast"
/usr/bin/make -f CMakeFiles/cmTC_f69e4.dir/build.make CMakeFiles/cmTC_f69e4.dir/build
make[1]: se ingresa al directorio «/home/sdk/openal-soft/build/CMakeFiles/CMakeTmp»
Building C object CMakeFiles/cmTC_f69e4.dir/CheckIncludeFile.c.obj
/opt/devkitpro/devkitARM/bin/arm-none-eabi-gcc -DARM11 -D_3DS -fno-gnu89-inline -std=c11 -mword-relocations -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft -D_WIN32_WINNT=0x0502 -D_LARGEFILE_SOURCE -D_LARGE_FILES -o CMakeFiles/cmTC_f69e4.dir/CheckIncludeFile.c.obj -c /home/sdk/openal-soft/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c
/home/sdk/openal-soft/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:21: fatal error: windows.h: No such file or directory
#include <windows.h>
^
compilation terminated.
make[1]: *** [CMakeFiles/cmTC_f69e4.dir/CheckIncludeFile.c.obj] Error 1
make[1]: se sale del directorio «/home/sdk/openal-soft/build/CMakeFiles/CMakeTmp»
make: *** [cmTC_f69e4/fast] Error 2
Determining if the nanosleep exist failed with the following output:
Change Dir: /home/sdk/openal-soft/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make" "cmTC_f69e4/fast"
/usr/bin/make -f CMakeFiles/cmTC_f69e4.dir/build.make CMakeFiles/cmTC_f69e4.dir/build
make[1]: se ingresa al directorio «/home/sdk/openal-soft/build/CMakeFiles/CMakeTmp»
Building C object CMakeFiles/cmTC_f69e4.dir/CheckSymbolExists.c.obj
/opt/devkitpro/devkitARM/bin/arm-none-eabi-gcc -DARM11 -D_3DS -fno-gnu89-inline -std=c11 -mword-relocations -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft -D_LARGEFILE_SOURCE -D_LARGE_FILES -o CMakeFiles/cmTC_f69e4.dir/CheckSymbolExists.c.obj -c /home/sdk/openal-soft/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c
/home/sdk/openal-soft/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c: In function 'main':
/home/sdk/openal-soft/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:8:19: error: 'nanosleep' undeclared (first use in this function)
return ((int*)(&nanosleep))[argc];
^
/home/sdk/openal-soft/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:8:19: note: each undeclared identifier is reported only once for each function it appears in
make[1]: *** [CMakeFiles/cmTC_f69e4.dir/CheckSymbolExists.c.obj] Error 1
make[1]: se sale del directorio «/home/sdk/openal-soft/build/CMakeFiles/CMakeTmp»
make: *** [cmTC_f69e4/fast] Error 2
File /home/sdk/openal-soft/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include <time.h>
int main(int argc, char** argv)
{
(void)argv;
#ifndef nanosleep
return ((int*)(&nanosleep))[argc];
#else
(void)argc;
return 0;
#endif
}