New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compiling 1.8.1, error with pthread (glibc) #103

Closed
saultdon opened this Issue Sep 14, 2016 · 7 comments

Comments

Projects
None yet
7 participants
@saultdon

saultdon commented Sep 14, 2016

Sorry for the noise, just not experienced enough to know if this is a liblas compile error or a problem with one my systems packages like glibc or gcc. Any insight is appreciated.

I got a little farther compiling liblas 1.8.1 on ArchLinux, it stops shortly after 50%:

Scanning dependencies of target las2col
[ 51%] Building C object apps/CMakeFiles/las2col.dir/lascommon.c.o
[ 52%] Building C object apps/CMakeFiles/las2col.dir/las2col.c.o
/tmp/makepkg/liblas/src/libLAS-1.8.1/apps/las2col.c: In function ‘main’:
/tmp/makepkg/liblas/src/libLAS-1.8.1/apps/las2col.c:1048:15: warning: passing argument 1 of ‘fsync’ makes integer from pointer without a cast [-Wint-conversion]
         fsync(files_out[i]);
               ^~~~~~~~~
In file included from /tmp/makepkg/liblas/src/libLAS-1.8.1/apps/las2col.c:30:0:
/usr/include/unistd.h:958:12: note: expected ‘int’ but argument is of type ‘FILE * {aka struct _IO_FILE *}’
 extern int fsync (int __fd);
            ^~~~~
[ 53%] Linking C executable ../bin/Release/las2col
/usr/bin/ld: CMakeFiles/las2col.dir/las2col.c.o: undefined reference to symbol 'pthread_create@@GLIBC_2.2.5'
/usr/lib/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [apps/CMakeFiles/las2col.dir/build.make:136: bin/Release/las2col] Error 1
make[1]: *** [CMakeFiles/Makefile2:309: apps/CMakeFiles/las2col.dir/all] Error 2
make: *** [Makefile:161: all] Error 2
==> ERROR: A failure occurred in build().
    Aborting...

I recognise the /usr/lib/libpthread.so.0: error adding symbols: DSO missing from command line error and for other packages, could simply EXPORT LIBS+=" -lpthread" prior to building but that's not working this time.

@hobu

This comment has been minimized.

Show comment
Hide comment
@hobu

hobu Sep 14, 2016

Member

/usr/bin/ld: CMakeFiles/las2col.dir/las2col.c.o: undefined reference to symbol 'pthread_create@@GLIBC_2.2.5'

@oscarmartinezrubi it looks like las2col needs explicit linking with threads.

Member

hobu commented Sep 14, 2016

/usr/bin/ld: CMakeFiles/las2col.dir/las2col.c.o: undefined reference to symbol 'pthread_create@@GLIBC_2.2.5'

@oscarmartinezrubi it looks like las2col needs explicit linking with threads.

@romulogoncalves

This comment has been minimized.

Show comment
Hide comment
@romulogoncalves

romulogoncalves Sep 19, 2016

Hi,

las2col needs pthreads. We thought that since the check is done during the configuration.
mkdir build
cd build
cmake ../
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- 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
-- Setting libLAS build type - Release
-- Searching for Boost 1.38+ - done
-- 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

and if the option -lpthread is added the linkage should work without issues. At least in Ubuntu and Fedora systems it works without issues (that's the systems we use in our projects), we are not sure about ArcLinux.

Would it be possible to re-test the compilation by first doing:
export LDFLAGS=-pthread

We will try to get ArcLinux and test it.

romulogoncalves commented Sep 19, 2016

Hi,

las2col needs pthreads. We thought that since the check is done during the configuration.
mkdir build
cd build
cmake ../
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- 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
-- Setting libLAS build type - Release
-- Searching for Boost 1.38+ - done
-- 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

and if the option -lpthread is added the linkage should work without issues. At least in Ubuntu and Fedora systems it works without issues (that's the systems we use in our projects), we are not sure about ArcLinux.

Would it be possible to re-test the compilation by first doing:
export LDFLAGS=-pthread

We will try to get ArcLinux and test it.

@rvanharen

This comment has been minimized.

Show comment
Hide comment
@rvanharen

rvanharen Sep 19, 2016

Contributor

@romulogoncalves confirmed, compiles after exporting LDFLAGS="${LDFLAGS} -pthread" before running cmake.

Contributor

rvanharen commented Sep 19, 2016

@romulogoncalves confirmed, compiles after exporting LDFLAGS="${LDFLAGS} -pthread" before running cmake.

@czka

This comment has been minimized.

Show comment
Hide comment
@czka

czka Sep 19, 2016

I'm guessing that an actual fix should rather be making las2col's target_link_libraries aware of CMAKE_THREAD_LIBS_INIT variable status. Eg. the following diff for apps/CMakeLists.txt worked for me, on ArchLinux, CMake 3.6.1:

<     target_link_libraries(${LAS2COL} ${LIBLAS_C_LIB_NAME})
---
>     target_link_libraries(${LAS2COL} ${LIBLAS_C_LIB_NAME} ${CMAKE_THREAD_LIBS_INIT})

https://stackoverflow.com/questions/1620918/cmake-and-libpthread and https://cmake.org/cmake/help/v3.6/module/FindThreads.html?highlight=pthread should help you decide how to do it best. I'm by no means a CMake expert :).

czka commented Sep 19, 2016

I'm guessing that an actual fix should rather be making las2col's target_link_libraries aware of CMAKE_THREAD_LIBS_INIT variable status. Eg. the following diff for apps/CMakeLists.txt worked for me, on ArchLinux, CMake 3.6.1:

<     target_link_libraries(${LAS2COL} ${LIBLAS_C_LIB_NAME})
---
>     target_link_libraries(${LAS2COL} ${LIBLAS_C_LIB_NAME} ${CMAKE_THREAD_LIBS_INIT})

https://stackoverflow.com/questions/1620918/cmake-and-libpthread and https://cmake.org/cmake/help/v3.6/module/FindThreads.html?highlight=pthread should help you decide how to do it best. I'm by no means a CMake expert :).

@nine7nine

This comment has been minimized.

Show comment
Hide comment
@nine7nine

nine7nine Sep 30, 2016

Hi,

I also bumped into this issue, but I am using Intel C/C++ Compiler.

czka's solution is the proper one... While;

export LDFLAGS="${LDFLAGS} -pthread"

may work on gcc, it fails on icc.

food for thought.

@czka thanks for the solution. I was able to get libLAS building from git with icc... very appreciated!

nine7nine commented Sep 30, 2016

Hi,

I also bumped into this issue, but I am using Intel C/C++ Compiler.

czka's solution is the proper one... While;

export LDFLAGS="${LDFLAGS} -pthread"

may work on gcc, it fails on icc.

food for thought.

@czka thanks for the solution. I was able to get libLAS building from git with icc... very appreciated!

rvanharen added a commit to rvanharen/libLAS that referenced this issue Sep 30, 2016

hobu added a commit that referenced this issue Sep 30, 2016

Merge pull request #104 from rvanharen/master
link las2col against threads: #103
@hobu

This comment has been minimized.

Show comment
Hide comment
@hobu

hobu Sep 30, 2016

Member

Fixed in #104. Thanks for the PR @rvanharen!

Member

hobu commented Sep 30, 2016

Fixed in #104. Thanks for the PR @rvanharen!

@hobu hobu closed this Sep 30, 2016

foggel pushed a commit to foggel/libLAS that referenced this issue Nov 1, 2016

@houzw

This comment has been minimized.

Show comment
Hide comment
@houzw

houzw May 31, 2018

it seems not working on centos 7

houzw commented May 31, 2018

it seems not working on centos 7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment