How to get pthread handling right? - makefile

I'm trying to cross-compile telldus-core to be able to use a Tellstick on my Synology NAS. I start by running Cmake with this command:
bengt#bengt-VirtualBox:/usr/local/src/telldus-core-2.1.1/build$ cmake -DCMAKE_C_COMPILER=/usr/bin/arm-linux-gnueabi-gcc-4.7 -DCMAKE_CXX_COMPILER=/usr/bin/arm-linux-gnueabi-g++-4.7 -DCMAKE_INSTALL_PREFIX=/opt -pthread ..
This leads to the following output:
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
Then running make results in:
[ 98%] Building CXX object tdtool/CMakeFiles/tdtool.dir/main.cpp.o
Linking CXX executable tdtool
/usr/local/src/telldus-core-2.1.1/build/client/libtelldus-core.so: undefined reference to `pthread_create'
/usr/local/src/telldus-core-2.1.1/build/client/libtelldus-core.so: undefined reference to `pthread_join'
collect2: fel: ld returnerade avslutningsstatus 1
make[2]: *** [tdtool/tdtool] Fel 1
make[1]: *** [tdtool/CMakeFiles/tdtool.dir/all] Fel 2
make: *** [all] Fel 2
bengt#bengt-VirtualBox:/usr/local/src/telldus-core-2.1.1/build$
What should I do to solve this?

Gak! Why are you running cmake under sudo?!?! The horror.
This error is because you haven't added -lpthread (the POSIX thread library) to your link line. I don't think adding -pthread to the end of the cmake command line will do that. You'll need to modify the CMakeLists.txt file and ensure the flag is present on both the compilation and link lines.
Or I guess you could try to do it like this:
cmake -DCMAKE_C_COMPILER='/usr/bin/arm-linux-gnueabi-gcc-4.7 -pthread' \
-DCMAKE_CXX_COMPILER='/usr/bin/arm-linux-gnueabi-g++-4.7 -pthread' \
-DCMAKE_INSTALL_PREFIX=/opt ...

Managed to make it compile with following lines added to /CMakeFiles.txt /tdtool/CMakeFiles.txt and /tdadmin/CMakeFiles.txt
SET(FORCE_COMPILE_FROM_TRUNK TRUE)
SET(GCC_COVERAGE_COMPILE_FLAGS "-Wno-narrowing")
SET(GCC_COVERAGE_LINK_FLAGS "-pthread -lpthread")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}")

Related

Cmake with "undefined references" Despite Finding Boost Libs

cmake 2.8.12 correctly shows:
Boost version: 1.56.0
Found the following Boost libraries:
system
thread
log
log_setup
And the generated link.txt shows full, correct path to the .so files, but every Boost call is simply "In function...undefined reference to boost..." with no cxx11 or ABI or any other hints.
CMakeFiles/proj.dir/src/proj.cc.o: In function `proj::init()':
/code/proj/src/proj.cc:31: undefined reference to `boost::log::v2s_mt_posix::core::get()'
This is running on an old box, for example using libc-2.13.so on a 32bit processor. I compiled the boost libraries on the box yesterday and am trying to compile this on the box but am getting nowhere. I compiled cmake on the box as well.
Searching dozens of questions here has gotten me nowhere. Any suggestions on what is wrong? How to investigate the issue?
set(PROJ_NAME my-proj)
set(HEADERS
headers/proj.h
)
set(SOURCES
src/proj.cc
)
set(MAIN_FILE src/main.cc)
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)
add_executable (${PROJ_NAME} ${SOURCES}
${HEADERS} ${MAIN_FILE})
target_include_directories ( ${PROJ_NAME}
PUBLIC headers
PRIVATE .
PRIVATE /usr/local/lib/
)
set( Boost_LIBRARY_DIR /usr/local/lib )
find_package(Boost COMPONENTS system thread log log_setup REQUIRED)
link_directories(${Boost_LIBRARY_DIR})
target_link_libraries ( ${PROJ_NAME} -pthread ${Boost_LIBRARIES} )
I think that
set( Boost_LIBRARY_DIR /usr/local/lib )
is wrong and interferes badly with Find_Package. If you want to provide a hint, use e.g. BOOST_ROOT as documented:
BOOST_ROOT=~/custom/boost cmake .
Here's a fixed-up / simplified self-contained example that works:
File CMakeLists.txt
set(PROJ_NAME my-proj)
find_package(Boost 1.65.0 COMPONENTS system thread log log_setup REQUIRED)
set(HEADERS
headers/proj.h
)
set(SOURCES
src/proj.cc
)
set(MAIN_FILE src/main.cc)
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)
add_executable (${PROJ_NAME} ${SOURCES}
${HEADERS} ${MAIN_FILE})
target_include_directories ( ${PROJ_NAME}
PUBLIC headers
PRIVATE .
PRIVATE /usr/local/lib/
)
link_directories(${Boost_LIBRARY_DIR})
target_link_libraries ( ${PROJ_NAME} -pthread ${Boost_LIBRARIES} )
File headers/proj.h
File src/main.cc
int main() {
}
File src/proj.cc
#include <boost/thread.hpp>
void foo() {
boost::thread_group tg;
tg.create_thread([]{});
tg.join_all();
}
Proof of the pudding:
cmake .
CMake Warning (dev) in CMakeLists.txt:
No project() command is present. The top-level CMakeLists.txt file must
contain a literal, direct call to the project() command. Add a line of
code such as
project(ProjectName)
near the top of the file, but after cmake_minimum_required().
CMake is pretending there is a "project(Project)" command on the first
line.
This warning is for project developers. Use -Wno-dev to suppress it.
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Found Boost: /usr/include (found suitable version "1.65.1", minimum required is "1.65.0") found components: system thread log log_setup chrono date_time atomic filesystem regex
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such as
cmake_minimum_required(VERSION 3.22)
should be added at the top of the file. The version specified may be lower
if you wish to support older CMake versions for this project. For more
information run "cmake --help-policy CMP0000".
This warning is for project developers. Use -Wno-dev to suppress it.
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/q
 sehe  /  tmp  q  make
[ 66%] Building CXX object CMakeFiles/my-proj.dir/src/proj.o
[ 66%] Building CXX object CMakeFiles/my-proj.dir/src/main.o
[100%] Linking CXX executable my-proj
[100%] Built target my-proj
 sehe  /  tmp  q  ldd my-proj
linux-vdso.so.1 (0x00007ffd917e4000)
libboost_system.so.1.65.1 => /usr/lib/x86_64-linux-gnu/libboost_system.so.1.65.1 (0x00007f40c25bd000)
libboost_thread.so.1.65.1 => /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.65.1 (0x00007f40c2398000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f40c2179000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f40c1d6c000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f40c1b54000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f40c1763000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f40c155b000)
/lib64/ld-linux-x86-64.so.2 (0x00007f40c29e7000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f40c11bd000)
NOTES
Note that if you use a too-recent boost then maybe the dependencies might be incorrect:
CMake Warning at /usr/share/cmake-3.22/Modules/FindBoost.cmake:1369 (message):
New Boost version may have incorrect or missing dependencies and imported
targets
Call Stack (most recent call first):
/usr/share/cmake-3.22/Modules/FindBoost.cmake:1492 (_Boost_COMPONENT_DEPENDENCIES)
/usr/share/cmake-3.22/Modules/FindBoost.cmake:2102 (_Boost_MISSING_DEPENDENCIES)
CMakeLists.txt:5 (find_package)
On my system, e.g. in order to use Boost 1.78 successfully, I have to add Boost System manually. Linker errors:
make
[ 33%] Building CXX object CMakeFiles/my-proj.dir/src/proj.o
[ 66%] Building CXX object CMakeFiles/my-proj.dir/src/main.o
[100%] Linking CXX executable my-proj
CMakeFiles/my-proj.dir/src/proj.o: In function `__static_initialization_and_destruction_0(int, int)':
proj.cc:(.text+0x6a1): undefined reference to `boost::system::generic_category()'
proj.cc:(.text+0x6ad): undefined reference to `boost::system::generic_category()'
proj.cc:(.text+0x6b9): undefined reference to `boost::system::system_category()'
CMakeFiles/my-proj.dir/src/proj.o: In function `boost::system::error_category::std_category::equivalent(int, std::error_condition const&) const':
proj.cc:(.text._ZNK5boost6system14error_category12std_category10equivalentEiRKSt15error_condition[_ZNK5boost6system14error_category12std_category10equivalentEiRKSt15error_condition]+0xb8): undefined reference to `boost::system::generic_category()'
proj.cc:(.text._ZNK5boost6system14error_category12std_category10equivalentEiRKSt15error_condition[_ZNK5boost6system14error_category12std_category10equivalentEiRKSt15error_condition]+0xf3): undefined reference to `boost::system::generic_category()'
CMakeFiles/my-proj.dir/src/proj.o: In function `boost::system::error_category::std_category::equivalent(std::error_code const&, int) const':
proj.cc:(.text._ZNK5boost6system14error_category12std_category10equivalentERKSt10error_codei[_ZNK5boost6system14error_category12std_category10equivalentERKSt10error_codei]+0xb8): undefined reference to `boost::system::generic_category()'
proj.cc:(.text._ZNK5boost6system14error_category12std_category10equivalentERKSt10error_codei[_ZNK5boost6system14error_category12std_category10equivalentERKSt10error_codei]+0xf3): undefined reference to `boost::system::generic_category()'
proj.cc:(.text._ZNK5boost6system14error_category12std_category10equivalentERKSt10error_codei[_ZNK5boost6system14error_category12std_category10equivalentERKSt10error_codei]+0x1d2): undefined reference to `boost::system::generic_category()'
CMakeFiles/my-proj.dir/src/proj.o:proj.cc:(.text._ZN5boost16thread_exceptionC2EiPKc[_ZN5boost16thread_exceptionC5EiPKc]+0x28): more undefined references to `boost::system::generic_category()' follow
collect2: error: ld returned 1 exit status
CMakeFiles/my-proj.dir/build.make:121: recipe for target 'my-proj' failed
make[2]: *** [my-proj] Error 1
CMakeFiles/Makefile2:82: recipe for target 'CMakeFiles/my-proj.dir/all' failed
make[1]: *** [CMakeFiles/my-proj.dir/all] Error 2
Makefile:90: recipe for target 'all' failed
make: *** [all] Error 2
Fix:
target_link_libraries ( ${PROJ_NAME} boost_system )
I hope that it is not too late to drop my answer here.
TLDR: When Boost is installed using package managers such as Homebrew or macports often it is compiled using clang++. But on your project side, one might be using a different compiler, leading to undefined references in the linkage stage.
In order to use the compiler that you want to use in your project, you will have to use a version of Boost compiled with the same compiler. to achieve this you can customize Boost compilation on macos as follows:
In the Bootstrap stage use:
./bootstrap.sh --prefix=/usr/local/Cellar/boost_gcc --with-toolset=gcc --without-libraries=python,mpi
Install the headers-only part as follows:
./b2 headers
Customize the compiler to build the libraries by adding a file named user-config.jam with the following line in it:
using gcc : : /usr/local/bin/g++-11 ;
Compile and install the library as follows:
./b2 -d2 -j12 --layout=tagged-1.66 --user-config=user-config.jam install threading=multi,single link=shared,static
I hope that it helps.

make linker for pdftohtml causes compiler errors

I'm getting the error below when I run make to compile xpdf. It seems to do with papar sizes not been detected. I've not seen this kind of error before, usually its the math library that causes the compiler to complain. Is anyone experienced with this sort of error?
[ 71%] Linking CXX executable pdftohtml
CMakeFiles/xpdf_objs.dir/GlobalParams.cc.o: In function GlobalParams::GlobalParams(char const*)':
GlobalParams.cc:(.text+0xdbd): undefined reference to `paperinit'
GlobalParams.cc:(.text+0xdc2): undefined reference to `systempapername'
GlobalParams.cc:(.text+0xdde): undefined reference to `paperinfo'
GlobalParams.cc:(.text+0xdee): undefined reference to `paperpswidth'
GlobalParams.cc:(.text+0xe05): undefined reference to `paperpsheight'
GlobalParams.cc:(.text+0xe48): undefined reference to `paperdone'
collect2: error: ld returned 1 exit status
make[2]: *** [xpdf/CMakeFiles/pdftohtml.dir/build.make:219: xpdf/pdftohtml] Error 1
make[1]: *** [CMakeFiles/Makefile2:428: xpdf/CMakeFiles/pdftohtml.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
The terminal output from the cmake command is:
$ cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=/usr/bin/g++ .
-- The C compiler identification is GNU 7.3.1
-- The CXX compiler identification is GNU 7.3.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/g++
-- Check for working CXX compiler: /usr/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for mkstemp
-- Looking for mkstemp - found
-- Looking for mkstemps
-- Looking for mkstemps - found
-- Looking for popen
-- Looking for popen - found
-- Performing Test HAVE_STD_SORT
-- Performing Test HAVE_STD_SORT - Success
-- Looking for fseeko
-- Looking for fseeko - found
-- Looking for fseek64
-- Looking for fseek64 - not found
-- Looking for _fseeki64
-- Looking for _fseeki64 - not found
-- Found FreeType (old-style includes): /usr/lib64/libfreetype.so
-- Found ZLIB: /usr/lib64/libz.so (found version "1.2.11")
-- Found PNG: /usr/lib64/libpng.so (found version "1.6.31")
-- Could NOT find JPEG (missing: JPEG_LIBRARY JPEG_INCLUDE_DIR)
-- Could NOT find TIFF (missing: TIFF_LIBRARY TIFF_INCLUDE_DIR)
-- lcms2 not found
-- Qt5 found
CMake Deprecation Warning at cmake-config.txt:263 (cmake_policy):
The OLD behavior for policy CMP0020 will be removed from a future version
of CMake.
The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
Call Stack (most recent call first):
CMakeLists.txt:15 (include)
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
CMake Deprecation Warning at xpdf-qt/CMakeLists.txt:27 (cmake_policy):
The OLD behavior for policy CMP0020 will be removed from a future version
of CMake.
The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/usr/build/xpdf-4.00
The package is broken. The current available source code does not properly handle the case when libpaper is present. For a full patch set that fixes the wrong behavior properly see this entry in Bugzilla.

RedHat MultiNest: failed install, issue with CMake/BLAS/LAPACK (or pthreads)

I am trying to install MultiNest on my desktop running Enterprise Red Hat 6.6 (Santiago). I downloaded the necessary package (MultiNest_v3.9_CMake.tar.gz), and followed the installation instructions:
cd MultiNest/build
cmake ..
Although BLAS and LAPACK are installed, I get the following errors:
CMake Error at /usr/share/cmake/Modules/FindBLAS.cmake:594 (message):
A required library with BLAS API not found. Please specify library
location.
Call Stack (most recent call first):
/usr/share/cmake/Modules/FindLAPACK.cmake:142 (find_package)
src/CMakeLists.txt:31 (FIND_PACKAGE)
-- Configuring incomplete, errors occurred!
See also "/home/ianc/Downloads/MultiNest/build/CMakeFiles/CMakeOutput.log".
See also "/home/ianc/Downloads/MultiNest/build/CMakeFiles/CMakeError.log".
Any suggestions?
The output "CmakeError.log" is below, and seems to indicate that the problem instead involves something called "pthreads".
Determining if the pthread_create exist failed with the following output:
Change Dir: /home/ianc/Downloads/MultiNest/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/gmake" "cmTryCompileExec4203479411/fast"
/usr/bin/gmake -f CMakeFiles/cmTryCompileExec4203479411.dir/build.make CMakeFiles/cmTryCompileExec4203479411.dir/build
gmake[1]: Entering directory /home/ianc/Downloads/MultiNest/build/CMakeFiles/CMakeTmp'
/usr/local/bin/cmake -E cmake_progress_report /home/ianc/Downloads/MultiNest/build/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec4203479411.dir/CheckSymbolExists.c.o
/usr/local/Ureka/python/bin/gcc -o CMakeFiles/cmTryCompileExec4203479411.dir/CheckSymbolExists.c.o -c /home/ianc/Downloads/MultiNest/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c
Linking C executable cmTryCompileExec4203479411
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec4203479411.dir/link.txt --verbose=1
/usr/local/Ureka/python/bin/gcc CMakeFiles/cmTryCompileExec4203479411.dir/CheckSymbolExists.c.o -o cmTryCompileExec4203479411 -rdynamic
CMakeFiles/cmTryCompileExec4203479411.dir/CheckSymbolExists.c.o: In functionmain':
CheckSymbolExists.c:(.text+0xc): undefined reference to pthread_create'
collect2: ld returned 1 exit status
gmake[1]: Leaving directory/home/ianc/Downloads/MultiNest/build/CMakeFiles/CMakeTmp'
gmake[1]: * [cmTryCompileExec4203479411] Error 1
gmake: * [cmTryCompileExec4203479411/fast] Error 2
File /home/ianc/Downloads/MultiNest/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
include
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/ianc/Downloads/MultiNest/build/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/gmake" "cmTryCompileExec3959414027/fast"
/usr/bin/gmake -f CMakeFiles/cmTryCompileExec3959414027.dir/build.make CMakeFiles/cmTryCompileExec3959414027.dir/build
gmake[1]: Entering directory /home/ianc/Downloads/MultiNest/build/CMakeFiles/CMakeTmp'
/usr/local/bin/cmake -E cmake_progress_report /home/ianc/Downloads/MultiNest/build/CMakeFiles/CMakeTmp/CMakeFiles 1
Building C object CMakeFiles/cmTryCompileExec3959414027.dir/CheckFunctionExists.c.o
/usr/local/Ureka/python/bin/gcc -DCHECK_FUNCTION_EXISTS=pthread_create -o CMakeFiles/cmTryCompileExec3959414027.dir/CheckFunctionExists.c.o -c /usr/local/share/cmake-3.1/Modules/CheckFunctionExists.c
Linking C executable cmTryCompileExec3959414027
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec3959414027.dir/link.txt --verbose=1
/usr/local/Ureka/python/bin/gcc -DCHECK_FUNCTION_EXISTS=pthread_create CMakeFiles/cmTryCompileExec3959414027.dir/CheckFunctionExists.c.o -o cmTryCompileExec3959414027 -rdynamic -lpthreads
/usr/bin/ld: cannot find -lpthreads
collect2: ld returned 1 exit status
gmake[1]: Leaving directory/home/ianc/Downloads/MultiNest/build/CMakeFiles/CMakeTmp'
gmake[1]: * [cmTryCompileExec3959414027] Error 1
gmake: * [cmTryCompileExec3959414027/fast] Error 2
Install these libraries and their devel versions for the build headers
libblas{3,-dev} liblapack{3,-dev} libatlas{3-base,-dev} cmake build-essential gfortran
You can also try installing compat packages.
The error above indicates that the POSIX threading library, libpthreads, cannot be found on your system. This error originates from your system-provided FindLAPACK.cmake script rather than from something in the MultiNest package.
I don't know the specific library which provides this on RedHat, but you should be able to check using yum provides pthread. After this you can install it using yum install M where M is whatever library provides libpthread from the previous command.

cmake failed building project on mac

I'm trying to build a project on my new macbook which was previously built normally on linux computers.
at first when i run cmake, i get a the following:
-- The C compiler identification is Clang 5.1.0
-- The CXX compiler identification is Clang 5.1.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Performing Test HAVE_CLOCK_GETTIME
-- Performing Test HAVE_CLOCK_GETTIME - Failed
-- Boost version: 1.55.0
-- Found the following Boost libraries:
-- graph
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
-- -> doxygen not found -> api-doc will not be created
-- Configuring done
-- Generating done
-- Build files have been written to: /path/to/folder
and then when i run make, it works till around 30% and then it stop with this error:
/path/to/project/lib/helpers.cpp:555:2: error: use of undeclared identifier 'gettimeofday'
gettimeofday(&tv, NULL);
^
1 error generated.
make[2]: *** [lib/CMakeFiles/genom.dir/helpers.cpp.o] Error 1
make[1]: *** [lib/CMakeFiles/genom.dir/all] Error 2
make: *** [all] Error 2
I looked online, there was some suggestions for changing clock_gettime(CLOCK_REALTIME, &t); to clock_get_time(CLOCK_REALTIME, &t);
but they didnt work.
The error message you provided indicates that gettimeofday wasn't included. What clock_gettime has to do with it is not possible to say from the information you provided.
A quick search about this yields, that gettimeofday should be available (it's part of POSIX).
Do you have #include <sys/time.h>(Apple Docs) or #include <sys/types.h>(SO Answer)?

bigloo scheme "make test" fails for pthreads

I am trying to build from the bigloo scheme's latest source 3.8a on a Linux Mint 12 (lisa), which is Ubuntu 11 (Oneric) derivative:
Here is my "configure":
./configure --enable-pthread --enable-fthread --enable-ssl --enable-sqlite --enable-web --enable-multimedia --enable-mail --enable-calendar --enable-pkgcomp --enable-pkglib --enable-gstreamer --enable-text --enable-srfi1 --enable-srfi27 --enable-crypto --enable-openpgp --enable-phone --enable-alsa --enable-mpg123 --enable-csv --jvm=yes
** Configuration summary **
Release features:
release number.............. 3.8a
supported backends.......... native:yes JVM:yes
default backend............. native
additional APIs............. pthread fthread sqlite web multimedia mail calendar pkgcomp pkglib text srfi1 srfi27 packrat crypto openpgp phone mpg123 csv
native threads support...... yes
openssl support............. no
sqlite support.............. sqltiny + sqlite
dynamic libraries support... yes
Bee configuration:
bee support................. partial
emacs....................... emacs
emacs brand................. emacs23
Implementation details:
tuning...................... standard
cc.......................... gcc
gc.......................... custom (bigloogc-3.8a, v731)
Java version................ 1.3
bignum support.............. gmp (5.0.1)
Directories where Bigloo will be installed:
binaries.................... /usr/local/bin
libraries................... /usr/local/lib
files directory............. bigloo/3.8a
standard zip................ /usr/local/lib/bigloo/3.8a
standard dll................ /usr/local/lib/bigloo/3.8a
manual pages................ /usr/local/man/man1
info documentation.......... /usr/local/info
lisp files..................
temporary build dir......... /tmp
The "make" succeeds; however "make test" fails for pthread
*** pthread **********
make[2]: Entering directory `/home/liew/Downloads/bigloo3.8a/api/pthread/recette'
/home/liew/Downloads/bigloo3.8a/bin/bigloo -c -call/cc -O3 -fcfa-arithmetic -q recette.scm -o recette.o
/home/liew/Downloads/bigloo3.8a/bin/bigloo -O3 -fcfa-arithmetic -q recette.o -o recette
/usr/bin/ld: recette: hidden symbol `pthread_atfork' in /usr/lib/i386-linux-gnu/libpthread_nonshared.a(pthread_atfork.oS) is referenced by DSO
/usr/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status
make[2]: *** [recette] Error 1
make[2]: Leaving directory `/home/liew/Downloads/bigloo3.8a/api/pthread/recette'
make[1]: *** [c-test] Error 1
make[1]: Leaving directory `/home/liew/Downloads/bigloo3.8a'
make: *** [test] Error 2
According to this excellent post about this pthread issue, we need to rearrange the command line parameters while linking pthread library. However, I was unable to find the required Makefile code - probably because it relies on the Makefile default that links the library in a certain way.
Any help will be appreciated.
The problem is probably fixed in newer versions of bigloo.

Resources