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

error building PCL with cmake_external #49

Closed
bbarnes52-zz opened this issue Aug 21, 2018 · 17 comments
Closed

error building PCL with cmake_external #49

bbarnes52-zz opened this issue Aug 21, 2018 · 17 comments

Comments

@bbarnes52-zz
Copy link

ERROR:

Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES)
-- Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES)
-- Could NOT find OpenMP (missing: OpenMP_C_FOUND OpenMP_CXX_FOUND)
-- Not found OpenMP
-- Configuring incomplete, errors occurred!
See also "/var/folders/sg/_2yjj6v54lbckvqwr3jc4zdc0007t6/T/tmp.VwfY2XEP/CMakeFiles/CMakeOutput.log".
mktemp: illegal option -- -
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-q] [-u] -t prefix
CMake Deprecation Warning at CMakeLists.txt:15 (cmake_policy):
  The OLD behavior for policy CMP0048 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.


CMake Deprecation Warning at CMakeLists.txt:19 (cmake_policy):
  The OLD behavior for policy CMP0054 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.


CMake Error at /usr/local/Cellar/cmake/3.12.0/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find Eigen (missing: EIGEN_INCLUDE_DIR)
Call Stack (most recent call first):
  /usr/local/Cellar/cmake/3.12.0/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
  cmake/Modules/FindEigen.cmake:44 (find_package_handle_standard_args)
  CMakeLists.txt:276 (find_package)

Target //roboflow/omg:pcl failed to build

System:

System info:
MacBook Pro (15-inch, 2017)
OS: High Sierra 10.13.1
Processor: 3.1 GHz Intel Core i7
Memory: 16 GB 2133 MHz LPDDR3

BUILD:

cmake_external(
        name = "pcl",
        cmake_options = ["-DBUILD_WITH_OPENMP=False"],
        headers_only = True,
        lib_source = "@pcl//:all",
)

WORKSPACE:

new_http_archive(
        name = "pcl",
        build_file_content = all_content,
        strip_prefix = "pcl-pcl-1.8.1",
        urls = ["https://github.com/PointCloudLibrary/pcl/archive/pcl-1.8.1.tar.gz"],
)
@bbarnes52-zz
Copy link
Author

Note that the use of -DBUILD_WITH_OPENMP has no effect

@irengrig
Copy link
Contributor

Hi Brian,

there was two problems with the build:

  1. my code (the part that created the shell script) worked poorly on Mac - corrected

  2. PCL library require many dependencies, which were missing.
    As for dependencies, I made an attempt and build some of them (those that I did not have already installed) - Eigen, OpenBLAS etc., but there are much more..
    Please have a look at add pcl library targets - not ready yet #59.
    I did not find a variable that you refer to - BUILD_WITH_OPENMP - in the corresponding CMakeLists.txt of the pcl library. (And as far as I see this dependency is optional, if it is not found, the build is not stopped.)
    This is the next error that stops it - Could NOT find Eigen (missing: EIGEN_INCLUDE_DIR).

A note on binding dependencies - different variables need to be set to help finding the prebuild libraries.
(It is very good to see in the example build in #59 )
From the good side, usually CMake reports which variables were not set, so we can try to set them.
Unfortunately, I did not find the good method of automatically forming this variables, so they need to be added manually.

@bbarnes52-zz
Copy link
Author

Thank you very much for your all your help

I'm not able to build some of the libraries in #59. For example, running

bazel build :openblas --experimental_cc_skylark_api_enabled_packages=@rules_foreign_cc//tools/build_defs,tools/build_defs

results in the following error (on Ubuntu):

export INSTALLDIR=$EXT_BUILD_ROOT/bazel-out/k8-fastbuild/genfiles/roboflow/omg/openblas
mkdir -p $INSTALLDIR
echo_vars INSTALLDIR EXT_BUILD_DEPS EXT_BUILD_ROOT PATH
pushd $TMPDIR
CC="/usr/bin/gcc" CXX="/usr/bin/gcc" CFLAGS="-U_FORTIFY_SOURCE -fstack-protector -Wall -B/usr/bin -B/usr/bin -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -fno-canonical-system-headers -Wno-builtin-macro-redefined -D__DATE__="redacted" -D__TIMESTAMP__="redacted" -D__TIME__="redacted"" CXXFLAGS="-U_FORTIFY_SOURCE -fstack-protector -Wall -B/usr/bin -B/usr/bin -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -std=c++0x -fno-canonical-system-headers -Wno-builtin-macro-redefined -D__DATE__="redacted" -D__TIMESTAMP__="redacted" -D__TIME__="redacted"" ASMFLAGS="-U_FORTIFY_SOURCE -fstack-protector -Wall -B/usr/bin -B/usr/bin -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -fno-canonical-system-headers -Wno-builtin-macro-redefined -D__DATE__="redacted" -D__TIMESTAMP__="redacted" -D__TIME__="redacted""  cmake -DCMAKE_AR="/usr/bin/ar" -DCMAKE_CXX_LINK_EXECUTABLE="/usr/bin/gcc <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>" -DCMAKE_SHARED_LINKER_FLAGS="-shared -fuse-ld=gold -Wl,-no-as-needed -Wl,-z,relro,-z,now -B/usr/bin -B/usr/bin -pass-exit-codes -lstdc++ -lm" -DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=gold -Wl,-no-as-needed -Wl,-z,relro,-z,now -B/usr/bin -B/usr/bin -pass-exit-codes -lstdc++ -lm" -DNOFORTRAN="on" -DBUILD_WITHOUT_LAPACK="no" -DCMAKE_PREFIX_PATH="$EXT_BUILD_DEPS" -DCMAKE_INSTALL_PREFIX="./openblas"  $EXT_BUILD_ROOT/external/openblas
make
make install
copy_dir_contents_to_dir $TMPDIR/./openblas $INSTALLDIR

replace_absolute_paths $INSTALLDIR $INSTALLDIR
popd
INFO: Analysed target //roboflow/omg:openblas (0 packages loaded).
INFO: Found 1 target...
[0 / 2] [-----] BazelWorkspaceStatusAction stable-status.txt
ERROR: /home/brian/git/cloud/roboflow/omg/BUILD:31:1: error executing shell command: '/bin/bash -c set -e
export EXT_BUILD_ROOT=$(pwd)
source external/foreign_cc_platform_utils/utils_unix.sh
echo "Building external library 'openblas'"
export TMPDIR=$(mktemp -d)
trap "{ rm -rf $TMPDI...' failed (Exit 127)
/bin/bash: line 23: cmake: command not found
Building external library 'openblas'
INSTALLDIR: "/home/brian/.cache/bazel/_bazel_brian/19fc196dfacab0a373352db9ae53e0f1/sandbox/processwrapper-sandbox/1/execroot/__main__/bazel-out/k8-fastbuild/genfiles/roboflow/omg/openblas"
EXT_BUILD_DEPS: "/home/brian/.cache/bazel/_bazel_brian/19fc196dfacab0a373352db9ae53e0f1/sandbox/processwrapper-sandbox/1/execroot/__main__/bazel_foreign_cc_deps"
EXT_BUILD_ROOT: "/home/brian/.cache/bazel/_bazel_brian/19fc196dfacab0a373352db9ae53e0f1/sandbox/processwrapper-sandbox/1/execroot/__main__"
PATH: "/home/brian/.cache/bazel/_bazel_brian/19fc196dfacab0a373352db9ae53e0f1/sandbox/processwrapper-sandbox/1/execroot/__main__/bazel_foreign_cc_deps/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
/tmp/tmp.0h54TPaZLI /home/brian/.cache/bazel/_bazel_brian/19fc196dfacab0a373352db9ae53e0f1/sandbox/processwrapper-sandbox/1/execroot/__main__
Target //roboflow/omg:openblas failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.705s, Critical Path: 0.51s
INFO: 0 processes.
FAILED: Build did NOT complete successfully

@bbarnes52-zz
Copy link
Author

This seems to be unrelated, building pybind11 fails with the same error (had it working recently). I imagine this is could either be from building bazel at a later commit, or from downloading rules_foreign_cc at a later commit.

@bbarnes52-zz
Copy link
Author

bbarnes52-zz commented Aug 23, 2018

So this one is actually a bit weird and seems similar to bazelbuild/bazel#3184.

When I bazel build :openblas I get the following error:

error: /Library/Developer/CommandLineTools/usr/bin/libtool: no output file specified (specify with -o output)
Usage: /Library/Developer/CommandLineTools/usr/bin/libtool -static [-] file [...] [-filelist listfile[,dirname]] [-arch_only arch] [-sacLT] [-no_warning_for_no_symbols]
Usage: /Library/Developer/CommandLineTools/usr/bin/libtool -dynamic [-] file [...] [-filelist listfile[,dirname]] [-arch_only arch] [-o output] [-install_name name] [-compatibility_version #] [-current_version #] [-seg1addr 0x#] [-segs_read_only_addr 0x#] [-segs_read_write_addr 0x#] [-seg_addr_table <filename>] [-seg_addr_table_filename <file_system_path>] [-all_load] [-noall_load]
make[2]: *** [lib/libopenblas.a] Error 1
make[1]: *** [CMakeFiles/openblas.dir/all] Error 2
make: *** [all] Error 2
Target //third_party/cmake:openblas failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 427.264s, Critical Path: 426.36s
INFO: 0 processes.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully

@irengrig
Copy link
Contributor

From the first error that you posted, you seem to be missing CMake on Ubuntu: /bin/bash: line 23: cmake: command not found.

Can not say anything about libtool error, I am not calling it directly, there must come from the script.
Could the version of libtool be incompatible?

@bbarnes52-zz
Copy link
Author

ack - I switched over to Ubuntu. added all other necessary dependencies to pcl target (I think) and am now getting the following:

[0 / 2] [-----] BazelWorkspaceStatusAction stable-status.txt
[4 / 5] CcCmakeMakeRule third_party/cmake/pcl; 1s linux-sandbox
ERROR: /home/brian/git/cloud/third_party/cmake/BUILD:47:1: error executing shell command: '/bin/bash -c set -e
export EXT_BUILD_ROOT=$(pwd)
source external/foreign_cc_platform_utils/utils_unix.sh
echo "Building external library 'pcl'"
export TMPDIR=$(mktemp -d)
trap "{ rm -rf $TMPDIR $EX...' failed (Exit 1)
CMake Error at cmake/Modules/FindEigen.cmake:29 (file):
  file failed to open for reading (No such file or directory):

    /home/brian/.cache/bazel/_bazel_brian/19fc196dfacab0a373352db9ae53e0f1/sandbox/linux-sandbox/1/execroot/__main__/bazel_foreign_cc_deps/eigen/include/Eigen/src/Core/util/Macros.h
Call Stack (most recent call first):
  CMakeLists.txt:276 (find_package)

@bbarnes52-zz
Copy link
Author

Looks like EIGEN_INCLUDE_DIR should be EIGEN_INCLUDE_DIRS (same for FLANN_INCLUDE_DIR)

after making that change, build fails later in the process, with the following:

Scanning dependencies of target pcl_openni_grabber_depth_example
[ 18%] Building CXX object io/tools/CMakeFiles/pcl_openni_grabber_depth_example.dir/openni_grabber_depth_example.cpp.o
[ 18%] Linking CXX executable ../../bin/pcl_openni_grabber_depth_example
io/tools/CMakeFiles/pcl_openni_grabber_depth_example.dir/build.make:116: recipe for target 'bin/pcl_openni_grabber_depth_example' failed
CMakeFiles/Makefile2:468: recipe for target 'io/tools/CMakeFiles/pcl_openni_grabber_depth_example.dir/all' failed
Makefile:160: recipe for target 'all' failed
Target //third_party/cmake:pcl failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 268.368s, Critical Path: 268.14s
INFO: 0 processes.

@irengrig
Copy link
Contributor

Looks like EIGEN_INCLUDE_DIR should be EIGEN_INCLUDE_DIRS (same for FLANN_INCLUDE_DIR)
Will experiment with this tomorrow, could be it is a better option. (since I have this in examples now).
Thank you for the information.

pcl_openni_grabber_depth_example
There is no actual error in the text you posted, just the statement that it failed.
Are there some more details around? Maybe in the very end of the text?
--verbose_failures might also help..

@bbarnes52-zz
Copy link
Author

I had missed one package (OPENNI). The build is not failing but has been running for ~40 minutes. I'll wait for a few hours and see if it completes.

@bbarnes52-zz
Copy link
Author

Build completely successfully in ~1 hour. The final rule looks like this:

licenses(["notice"])
cmake_external( 
        name = "pcl",
        cache_entries = {
                "WITH_LIBUSB": "no",
                "EIGEN_INCLUDE_DIRS": "$EXT_BUILD_DEPS/eigen/include",
                "FLANN_LIBRARY": "$EXT_BUILD_DEPS/flann/lib/libflann_s.a",
                "FLANN_INCLUDE_DIRS": "$EXT_BUILD_DEPS/flann/include",
                "WITH_PNG": "no",
                "WITH_QHULL": "no",
                "WITH_CUDA": "no",
                "WITH_QT": "no",
                "WITH_VTK": "no",
                "WITH_PCAP": "no",
                "WITH_OPENGL": "no",
                "WITH_OPENNI": "no",
                "WITH_OPENNI2": "no",
                "WITH_FZAPI": "no",
                "WITH_ENSENSO": "no",
                "WITH_DAVIDSDK": "no",
                "WITH_DSSDK": "no",
                "WITH_RSSDK": "no",
        },
        headers_only = True,
        lib_source = "@pcl//:all",
        deps = [
                ":eigen",
                ":flann",
        ],
)

@bbarnes52-zz
Copy link
Author

One last qq - outputs are located under:

bazel-out/k8-fastbuild/genfiles/third_party/cmake/pcl/include/pcl-1.8/pcl/common/

When they should be at

bazel-out/k8-fastbuild/genfiles/third_party/cmake/pcl/include/pcl/common/

e.g. I want to strip pcl-1.8 from the path. Would you happen to know what needs to be added to the cmake_external rule to accomplish this?

@irengrig
Copy link
Contributor

Great news! though, an hour seems to be really long.

Do you want to create a pull request to contribute this to the examples?

About the include directory - there is the attribute out_include_dir, which defines headers include directory for output C++ provider - i.e. it is an equivalent of 'includes' attribute of cc-library rule.
The default value of out_include_dir is /include.
So the client code can include the files from out_include_dir directly.

I added the example into examples/cmake_hello_world_lib/BUILD:
Header file hello.h is placed into include/version123 by the CMakeLists.txt.

In case when we do not pass the custom out_include_dir, we need to include header with #include "version123/hello.h".
In case when we build the libhello with out_include_dir = "include/version123", we can just use #include "hello.h" in client code.

@bbarnes52-zz
Copy link
Author

Thank you so very much for your help! I will submit a PR, probably on Monday.

I also got an error about not being able to find file Python.h. I resolved this by adding copts=["-I/path_to_system_python"]. Would you happen to know a way of resolving this issue without introducing local dependencies?

I now get the following error when building my cc_binary:

/usr/bin/ld.gold: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_s.a(lz4.c.o): previous definition here
/usr/bin/ld.gold: error: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_cpp_s.a(lz4.c.o): multiple definition of 'LZ4_decompress_fast_withPrefix64k'
/usr/bin/ld.gold: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_s.a(lz4.c.o): previous definition here
/usr/bin/ld.gold: error: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_cpp_s.a(lz4hc.c.o): multiple definition of 'LZ4_sizeofStateHC'
/usr/bin/ld.gold: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_s.a(lz4hc.c.o): previous definition here
/usr/bin/ld.gold: error: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_cpp_s.a(lz4hc.c.o): multiple definition of 'LZ4_compress_HC_extStateHC'
/usr/bin/ld.gold: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_s.a(lz4hc.c.o): previous definition here
/usr/bin/ld.gold: error: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_cpp_s.a(lz4hc.c.o): multiple definition of 'LZ4_compress_HC'
/usr/bin/ld.gold: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_s.a(lz4hc.c.o): previous definition here
/usr/bin/ld.gold: error: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_cpp_s.a(lz4hc.c.o): multiple definition of 'LZ4_createStreamHC'
/usr/bin/ld.gold: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_s.a(lz4hc.c.o): previous definition here
/usr/bin/ld.gold: error: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_cpp_s.a(lz4hc.c.o): multiple definition of 'LZ4_freeStreamHC'
/usr/bin/ld.gold: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_s.a(lz4hc.c.o): previous definition here
/usr/bin/ld.gold: error: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_cpp_s.a(lz4hc.c.o): multiple definition of 'LZ4_resetStreamHC'
/usr/bin/ld.gold: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_s.a(lz4hc.c.o): previous definition here
/usr/bin/ld.gold: error: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_cpp_s.a(lz4hc.c.o): multiple definition of 'LZ4_loadDictHC'
/usr/bin/ld.gold: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_s.a(lz4hc.c.o): previous definition here
/usr/bin/ld.gold: error: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_cpp_s.a(lz4hc.c.o): multiple definition of 'LZ4_compress_HC_continue'
/usr/bin/ld.gold: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_s.a(lz4hc.c.o): previous definition here
/usr/bin/ld.gold: error: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_cpp_s.a(lz4hc.c.o): multiple definition of 'LZ4_saveDictHC'
/usr/bin/ld.gold: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_s.a(lz4hc.c.o): previous definition here
/usr/bin/ld.gold: error: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_cpp_s.a(lz4hc.c.o): multiple definition of 'LZ4_compressHC'
/usr/bin/ld.gold: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_s.a(lz4hc.c.o): previous definition here
/usr/bin/ld.gold: error: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_cpp_s.a(lz4hc.c.o): multiple definition of 'LZ4_compressHC_limitedOutput'
/usr/bin/ld.gold: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_s.a(lz4hc.c.o): previous definition here
/usr/bin/ld.gold: error: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_cpp_s.a(lz4hc.c.o): multiple definition of 'LZ4_compressHC2'
/usr/bin/ld.gold: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_s.a(lz4hc.c.o): previous definition here
/usr/bin/ld.gold: error: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_cpp_s.a(lz4hc.c.o): multiple definition of 'LZ4_compressHC2_limitedOutput'
/usr/bin/ld.gold: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_s.a(lz4hc.c.o): previous definition here
/usr/bin/ld.gold: error: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_cpp_s.a(lz4hc.c.o): multiple definition of 'LZ4_compressHC_withStateHC'
/usr/bin/ld.gold: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_s.a(lz4hc.c.o): previous definition here
/usr/bin/ld.gold: error: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_cpp_s.a(lz4hc.c.o): multiple definition of 'LZ4_compressHC_limitedOutput_withStateHC'
/usr/bin/ld.gold: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_s.a(lz4hc.c.o): previous definition here
/usr/bin/ld.gold: error: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_cpp_s.a(lz4hc.c.o): multiple definition of 'LZ4_compressHC2_withStateHC'
/usr/bin/ld.gold: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_s.a(lz4hc.c.o): previous definition here
/usr/bin/ld.gold: error: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_cpp_s.a(lz4hc.c.o): multiple definition of 'LZ4_compressHC2_limitedOutput_withStateHC'
/usr/bin/ld.gold: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_s.a(lz4hc.c.o): previous definition here
/usr/bin/ld.gold: error: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_cpp_s.a(lz4hc.c.o): multiple definition of 'LZ4_compressHC_continue'
/usr/bin/ld.gold: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_s.a(lz4hc.c.o): previous definition here
/usr/bin/ld.gold: error: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_cpp_s.a(lz4hc.c.o): multiple definition of 'LZ4_compressHC_limitedOutput_continue'
/usr/bin/ld.gold: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_s.a(lz4hc.c.o): previous definition here
/usr/bin/ld.gold: error: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_cpp_s.a(lz4hc.c.o): multiple definition of 'LZ4_sizeofStreamStateHC'
/usr/bin/ld.gold: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_s.a(lz4hc.c.o): previous definition here
/usr/bin/ld.gold: error: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_cpp_s.a(lz4hc.c.o): multiple definition of 'LZ4_resetStreamStateHC'
/usr/bin/ld.gold: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_s.a(lz4hc.c.o): previous definition here
/usr/bin/ld.gold: error: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_cpp_s.a(lz4hc.c.o): multiple definition of 'LZ4_createHC'
/usr/bin/ld.gold: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_s.a(lz4hc.c.o): previous definition here
/usr/bin/ld.gold: error: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_cpp_s.a(lz4hc.c.o): multiple definition of 'LZ4_freeHC'
/usr/bin/ld.gold: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_s.a(lz4hc.c.o): previous definition here
/usr/bin/ld.gold: error: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_cpp_s.a(lz4hc.c.o): multiple definition of 'LZ4_compressHC2_continue'
/usr/bin/ld.gold: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_s.a(lz4hc.c.o): previous definition here
/usr/bin/ld.gold: error: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_cpp_s.a(lz4hc.c.o): multiple definition of 'LZ4_compressHC2_limitedOutput_continue'
/usr/bin/ld.gold: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_s.a(lz4hc.c.o): previous definition here
/usr/bin/ld.gold: error: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_cpp_s.a(lz4hc.c.o): multiple definition of 'LZ4_slideInputBufferHC'
/usr/bin/ld.gold: bazel-out/k8-fastbuild/genfiles/third_party/cmake/flann/lib/libflann_s.a(lz4hc.c.o): previous definition here

Appreciate any insight, my knowledge of building C++ is pretty minimal unfortunately.

Thanks again!

@bbarnes52-zz
Copy link
Author

I just took a guess and removed libflann_cpp_s.a from the static_libraries param of flann cmake_external target, and it worked!

I don't understand the broader implications of this change so if there's anything I am missing would very much appreciate your guidance.

Otherwise, I'll submit a PR on Monday with the full example and close this issue at the time.

Thanks again!

@irengrig
Copy link
Contributor

Ok, looking forward for a pull request!

I also got an error about not being able to find file Python.h. I resolved this by adding copts=["-I/path_to_system_python"]. Would you happen to know a way of resolving this issue without introducing local dependencies?

Well, this file should be provided since it is needed by a build.

  1. So you can add an option manually referring to the absolute paths, as you did (in my experiments, I did the similar thing: # include system headers, change this to appropriate value env_vars = { "CXXFLAGS": "-isystem=/usr/include/python2.7 -fPIC", "CFLAGS": "-isystem=/usr/include/python2.7 -fPIC", }, )
    Of course, it has a drawback of being inportable.
    A good compromise would be having a repository_rule called from WORKSPACE file, which would determine the path to the directory with Python.h on the system and provide that information further (as I am doing in workspace_definitions.bzl).
    You can do it if you can determine the location of Python.h directory automatically, or through reading the environment variable, which can be made visible for the repository_rule.
    Here is an overview about repository rules.

  2. Or you can add the header files to the project, or define a repository/local repository + cc_import for them and add imported library as deps to cmake_external.

I just took a guess and removed libflann_cpp_s.a from the static_libraries param of flann cmake_external target, and it worked!

As far as I could understand from Flann's CMake files, flann_s.a and flann_cpp_s.a are variants for C or C++. So you definitely need only one of them. (It's here)

@bbarnes52-zz
Copy link
Author

#68

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants