Skip to content
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

building with cmake - errors #104

Closed
MisterAero opened this issue Nov 22, 2022 · 3 comments
Closed

building with cmake - errors #104

MisterAero opened this issue Nov 22, 2022 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@MisterAero
Copy link

MisterAero commented Nov 22, 2022

I did the prerequisites, then cloned the repo and ran cmake as following:


~/tools/cmake/binexport/build_linux$ cmake ..     -G Ninja     -DCMAKE_BUILD_TYPE=Release     "-DCMAKE_INSTALL_PREFIX=${PWD}"     -DBINEXPORT_ENABLE_IDAPRO=ON     "-DIdaSdk_ROOT_DIR=${PWD}/../third_party/idasdk"     -DBINEXPORT_ENABLE_BINARYNINJA=ON \
>
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.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
-- Performing Test ABSL_INTERNAL_AT_LEAST_CXX17
-- Performing Test ABSL_INTERNAL_AT_LEAST_CXX17 - Success
-- 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 Python: /usr/bin/python3.8 (found version "3.8.10") found components: Interpreter


--
-- 3.21.4.0
-- Performing Test protobuf_HAVE_LD_VERSION_SCRIPT
-- Performing Test protobuf_HAVE_LD_VERSION_SCRIPT - Success
-- Performing Test protobuf_HAVE_BUILTIN_ATOMICS
-- Performing Test protobuf_HAVE_BUILTIN_ATOMICS - Success
CMake Error at build_linux/_deps/protobuf-src/third_party/utf8_range/CMakeLists.txt:26 (find_package):
  Could not find a package configuration file provided by "absl" with any of
  the following names:

    abslConfig.cmake
    absl-config.cmake

  Add the installation prefix of "absl" to CMAKE_PREFIX_PATH or set
  "absl_DIR" to a directory containing one of the above files.  If "absl"
  provides a separate development package or SDK, be sure it has been
  installed.


-- Configuring incomplete, errors occurred!
See also "/home/aero/tools/cmake/binexport/build_linux/CMakeFiles/CMakeOutput.log".
See also "/home/aero/tools/cmake/binexport/build_linux/CMakeFiles/CMakeError.log".

CMakeError.log:

`Performing C SOURCE FILE Test CMAKE_HAVE_LIBC_PTHREAD failed with the following output:
Change Dir: /home/aero/tools/cmake/binexport/build_linux/CMakeFiles/CMakeTmp

Run Build Command(s):/home/aero/.local/bin/ninja cmTC_87eea && [1/2] Building C object CMakeFiles/cmTC_87eea.dir/src.c.o
[2/2] Linking C executable cmTC_87eea
FAILED: cmTC_87eea 
: && /usr/bin/cc   CMakeFiles/cmTC_87eea.dir/src.c.o -o cmTC_87eea   && :
/usr/bin/ld: CMakeFiles/cmTC_87eea.dir/src.c.o: in function `main':
src.c:(.text+0x46): undefined reference to `pthread_create'
/usr/bin/ld: src.c:(.text+0x52): undefined reference to `pthread_detach'
/usr/bin/ld: src.c:(.text+0x5e): undefined reference to `pthread_cancel'
/usr/bin/ld: src.c:(.text+0x6f): undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.


Source file was:
#include <pthread.h>

static void* test_func(void* data)
{
  return data;
}

int main(void)
{
  pthread_t thread;
  pthread_create(&thread, NULL, test_func, NULL);
  pthread_detach(thread);
  pthread_cancel(thread);
  pthread_join(thread, NULL);
  pthread_atfork(NULL, NULL, NULL);
  pthread_exit(NULL);

  return 0;
}

Determining if the function pthread_create exists in the pthreads failed with the following output:
Change Dir: /home/aero/tools/cmake/binexport/build_linux/CMakeFiles/CMakeTmp

Run Build Command(s):/home/aero/.local/bin/ninja cmTC_dc3e1 && [1/2] Building C object CMakeFiles/cmTC_dc3e1.dir/CheckFunctionExists.c.o
[2/2] Linking C executable cmTC_dc3e1
FAILED: cmTC_dc3e1 
: && /usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create  CMakeFiles/cmTC_dc3e1.dir/CheckFunctionExists.c.o -o cmTC_dc3e1  -lpthreads && :
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.



Performing C SOURCE FILE Test CMAKE_HAVE_LIBC_PTHREAD failed with the following output:
Change Dir: /home/aero/tools/cmake/binexport/build_linux/CMakeFiles/CMakeTmp

Run Build Command(s):/home/aero/.local/bin/ninja cmTC_5bb3b && [1/2] Building C object CMakeFiles/cmTC_5bb3b.dir/src.c.o
[2/2] Linking C executable cmTC_5bb3b
FAILED: cmTC_5bb3b 
: && /usr/bin/cc   CMakeFiles/cmTC_5bb3b.dir/src.c.o -o cmTC_5bb3b   && :
/usr/bin/ld: CMakeFiles/cmTC_5bb3b.dir/src.c.o: in function `main':
src.c:(.text+0x46): undefined reference to `pthread_create'
/usr/bin/ld: src.c:(.text+0x52): undefined reference to `pthread_detach'
/usr/bin/ld: src.c:(.text+0x5e): undefined reference to `pthread_cancel'
/usr/bin/ld: src.c:(.text+0x6f): undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.


Source file was:
#include <pthread.h>

static void* test_func(void* data)
{
  return data;
}

int main(void)
{
  pthread_t thread;
  pthread_create(&thread, NULL, test_func, NULL);
  pthread_detach(thread);
  pthread_cancel(thread);
  pthread_join(thread, NULL);
  pthread_atfork(NULL, NULL, NULL);
  pthread_exit(NULL);

  return 0;
}

Determining if the function pthread_create exists in the pthreads failed with the following output:
Change Dir: /home/aero/tools/cmake/binexport/build_linux/CMakeFiles/CMakeTmp

Run Build Command(s):/home/aero/.local/bin/ninja cmTC_d6b7f && [1/2] Building C object CMakeFiles/cmTC_d6b7f.dir/CheckFunctionExists.c.o
[2/2] Linking C executable cmTC_d6b7f
FAILED: cmTC_d6b7f 
: && /usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create  CMakeFiles/cmTC_d6b7f.dir/CheckFunctionExists.c.o -o cmTC_d6b7f  -lpthreads && :
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

`

@cblichmann cblichmann added the bug Something isn't working label Nov 22, 2022
@cblichmann
Copy link
Member

Ah yes, this is due to a new dependency in Protocol Buffers.

Updating the dependency should fix it:

diff --git a/cmake/BinExportDeps.cmake b/cmake/BinExportDeps.cmake
index 23ec90b..a0dd00a 100644
--- a/cmake/BinExportDeps.cmake
+++ b/cmake/BinExportDeps.cmake
@@ -64,7 +64,7 @@ endif()
 # Protocol Buffers
 FetchContent_Declare(protobuf
   GIT_REPOSITORY https://github.com/protocolbuffers/protobuf.git
-  GIT_TAG        3b4fdac42a6ec145412953ae578e7eb0cfcb800d # 2022-10-25
+  GIT_TAG        8809a113bc0a00b685b787a03d0698aa8c3e10e8 # 2022-11-21
 )
 set(protobuf_ABSL_PROVIDER "package" CACHE STRING "" FORCE)
 set(protobuf_BUILD_TESTS OFF CACHE BOOL "" FORCE)

I'll send a PR later today.

@cblichmann
Copy link
Member

Actually, you can run the CMake config step twice (!) and then it should work. The reason is that we set the cache variable for ABSL_ROOT_DIR before Abseil is fully available.

I have a pending internal change for this.

@cblichmann cblichmann self-assigned this Nov 22, 2022
@cblichmann
Copy link
Member

Fixed by a164ed0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants