I'm trying to build a hello_world cc_grpc_library using bazel 6.0.0 on Ubuntu 22.04, but I'm unable to do so.
Source tree:
WORKSPACE
MODULE.bazel
BUILD
helloworld.proto
.bazelrc
.bazelversion
My WORKSPACE file is empty. WORKSPACE.bzlmod does not exist.
MODULE.bazel contains:
module(name = "helloworld", version = "1.0")
bazel_dep(name = "grpc", version = "1.47.0", repo_name = "com_github_grpc_grpc")
BUILD contains:
load("#rules_proto//proto:defs.bzl", "proto_library")
load("#com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
load("#com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")
load("#com_github_grpc_grpc//bazel:cc_grpc_library.bzl", "cc_grpc_library")
grpc_deps()
grpc_extra_deps()
proto_library(
name = "helloworld_proto",
srcs = ["helloworld.proto"],
)
cc_proto_library(
name = "helloworld_cc_proto",
deps = [":helloworld_proto"],
)
cc_grpc_library(
name = "helloworld_cc_grpc",
srcs = [":helloworld_proto"],
grpc_only = True,
deps = [":helloworld_cc_proto"],
)
helloworld.proto is a copy of gRPC's helloworld.proto
When I type bazel build :helloworld_cc_grpc I get the following error and don't know how to solve it:
...external/grpc~1.47.0/bazel/grpc_deps.bzl", line 23, column 11, in grpc_bind_deps
native.bind(
Error: no native function or rule 'bind'
Available attributes: aar_import, action_listener, alias, android_binary, android_device, android_device_script_fixture, android_host_service_fixture, android_instrumentation_test, android_library, android_local_test, android_sdk, android_tools_defaults_jar, apple_cc_toolchain, available_xcodes, cc_binary, cc_host_toolchain_alias, cc_import, cc_libc_top_alias, cc_library, cc_proto_library, cc_shared_library, cc_shared_library_permissions, cc_test, cc_toolchain, cc_toolchain_alias, cc_toolchain_suite, config_feature_flag, config_setting, constraint_setting, constraint_value, environment, existing_rule, existing_rules, exports_files, extra_action, fdo_prefetch_hints, fdo_profile, filegroup, genquery, genrule, glob, j2objc_library, java_binary, java_import, java_library, java_lite_proto_library, java_package_configuration, java_plugin, java_plugins_flag_alias, java_proto_library, java_runtime, java_test, java_toolchain, label_flag, label_setting, objc_import, objc_library, package, package_group, package_name, platform, propeller_optimize, proto_lang_toolchain, proto_library, py_binary, py_library, py_runtime, py_test, repository_name, sh_binary, sh_library, sh_test, subpackages, test_suite, toolchain, toolchain_type, xcode_config, xcode_config_alias, xcode_version
bazel version output:
Bazelisk version: v1.15.0
Build label: 6.0.0
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Mon Dec 19 15:52:35 2022 (1671465155)
Build timestamp: 1671465155
Build timestamp as int: 1671465155
I've also found this gRPC github issue but I'm not sure what to do with it.
How to build gRPC's hello world example using bzlmod to manage external dependencies?
I've tried building it with bazel's cc_grpc_library but that wraps actual dependency (gRPC) into yet another layer as it is visible from the comment on the provided link. Either way it wasn't building but I don't recall actual error.
gRPC doesn't yet support Bazel module so it can break but in your case, it looks weird to call grpc_deps() and grpc_extra_deps() functions in BUILD file because those are expected to be called in WORKSPACE file. If it turns out that module doesn't work yet, you may want to use it without module. Please take a look at this example.
I'm trying to solve the problem, but nothing works. I don't understand why gcc looks for "-llib/cmocka.dll" when it should look for "cmocka.dll". Cmocka downloaded and showed the path to it. I tried to find a solution to the problem on the forums, but the same problem was described there on linux, and I have windows.I would appreciate any help as I don't know what to do anymore.
program structure:
root CMakeLists:
cmake_minimum_required(VERSION 3.7)
project(tests LANGUAGES C ASM)
set(CMAKE_C_STANDARD 99)
add_subdirectory(src)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules")
# cmocka
find_package(CMocka CONFIG)
if (CMocka_FOUND)
message("cmocka found")
include(AddCMockaTest)
include(AddMockedTest)
add_subdirectory(test)
enable_testing()
endif(CMocka_FOUND)
AddCMockaTest:
enable_testing()
include(CTest)
if (CMAKE_CROSSCOMPILING)
if (WIN32)
find_program(WINE_EXECUTABLE
NAMES wine)
set(TARGET_SYSTEM_EMULATOR ${WINE_EXECUTABLE} CACHE INTERNAL "")
endif()
endif()
function(ADD_CMOCKA_TEST _TARGET_NAME)
set(one_value_arguments
)
set(multi_value_arguments
SOURCES
COMPILE_OPTIONS
COMPILE_DEFINITION
LINK_LIBRARIES
LINK_OPTIONS
)
cmake_parse_arguments(_add_cmocka_test
""
"${one_value_arguments}"
"${multi_value_arguments}"
${ARGN}
)
if (NOT DEFINED _add_cmocka_test_SOURCES)
message(FATAL_ERROR "No sources provided for target ${_TARGET_NAME}")
endif()
add_executable(${_TARGET_NAME} ${_add_cmocka_test_SOURCES})
if (DEFINED _add_cmocka_test_COMPILE_OPTIONS)
target_compile_options(${_TARGET_NAME}
PRIVATE ${_add_cmocka_test_COMPILE_OPTIONS}
)
endif()
if (DEFINED _add_cmocka_test_LINK_LIBRARIES)
target_link_libraries(${_TARGET_NAME}
PRIVATE ${_add_cmocka_test_LINK_LIBRARIES}
)
endif()
if (DEFINED _add_cmocka_test_LINK_OPTIONS)
set_target_properties(${_TARGET_NAME}
PROPERTIES LINK_FLAGS
${_add_cmocka_test_LINK_OPTIONS}
)
endif()
add_test(${_TARGET_NAME}
${TARGET_SYSTEM_EMULATOR} ${_TARGET_NAME}
)
endfunction (ADD_CMOCKA_TEST)
AddMockedTest:
function(add_mocked_test name)
# parse arguments passed to the function
set(options )
set(oneValueArgs )
set(multiValueArgs SOURCES MOCKS COMPILE_OPTIONS LINK_LIBRARIES LINK_OPTIONS)
cmake_parse_arguments(ADD_MOCKED_TEST "${options}" "${oneValueArgs}"
"${multiValueArgs}" ${ARGN} )
# create link flags for mocks
set(link_flags "")
foreach (mock ${ADD_MOCKED_TEST_MOCKS})
set(link_flags "${link_flags} -Wl,--wrap=${mock}")
endforeach(mock)
# define test
add_cmocka_test(test_${name}
SOURCES test_${name}.c ${ADD_MOCKED_TEST_SOURCES}
COMPILE_OPTIONS ${DEFAULT_C_COMPILE_FLAGS}
${ADD_MOCKED_TEST_COMPILE_OPTIONS}
LINK_LIBRARIES ${CMOCKA_LIBRARIES}
${ADD_MOCKED_TEST_LINK_LIBRARIES}
LINK_OPTIONS ${link_flags} ${ADD_MOCKED_TEST_LINK_OPTIONS})
# allow using includes from src/ directory
target_include_directories(test_${name} PRIVATE ${CMAKE_SOURCE_DIR}/src)
endfunction(add_mocked_test)
I have built an API using Rocket, Diesel and SQLite. It runs fine locally.
Now I want to deploy my API it to Heroku. I'm going off this example. I've followed the included instructions as close as I can. However, the build step returns the following error:
error: linking with `cc` failed: exit code: 1
|
= note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-Wl,--eh-frame-hdr" "-L" "/tmp/codon/tmp/cache/multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/tmp/codon/tmp/cache/target/release/deps/cardbox_api-1b33053639456c47.cardbox_api.2391d6uc-cgu.0.rcgu.o" "/tmp/codon/tmp/cache/target/release/deps/cardbox_api-1b33053639456c47.cardbox_api.2391d6uc-cgu.1.rcgu.o" "/tmp/codon/tmp/cache/target/release/deps/cardbox_api-1b33053639456c47.cardbox_api.2391d6uc-cgu.10.rcgu.o" "/tmp/codon/tmp/cache/target/release/deps/cardbox_api-1b33053639456c47.cardbox_api.2391d6uc-cgu.11.rcgu.o" "/tmp/codon/tmp/cache/target/release/deps/cardbox_api-1b33053639456c47.cardbox_api.2391d6uc-cgu.12.rcgu.o" "/tmp/codon/tmp/cache/target/release/deps/cardbox_api-1b33053639456c47.cardbox_api.2391d6uc-cgu.13.rcgu.o" "/tmp/codon/tmp/cache/target/release/deps/cardbox_api-1b33053639456c47.cardbox_api.2391d6uc-cgu.14.rcgu.o" "/tmp/codon/tmp/cache/target/release/deps/cardbox_api-1b33053639456c47.cardbox_api.2391d6uc-cgu.15.rcgu.o" "/tmp/codon/tmp/cache/target/release/deps/cardbox_api-1b33053639456c47.cardbox_api.2391d6uc-cgu.2.rcgu.o" "/tmp/codon/tmp/cache/target/release/deps/cardbox_api-1b33053639456c47.cardbox_api.2391d6uc-cgu.3.rcgu.o" "/tmp/codon/tmp/cache/target/release/deps/cardbox_api-1b33053639456c47.cardbox_api.2391d6uc-cgu.4.rcgu.o" "/tmp/codon/tmp/cache/target/release/deps/cardbox_api-1b33053639456c47.cardbox_api.2391d6uc-cgu.5.rcgu.o" "/tmp/codon/tmp/cache/target/release/deps/cardbox_api-1b33053639456c47.cardbox_api.2391d6uc-cgu.6.rcgu.o" "/tmp/codon/tmp/cache/target/release/deps/cardbox_api-1b33053639456c47.cardbox_api.2391d6uc-cgu.7.rcgu.o" "/tmp/codon/tmp/cache/target/release/deps/cardbox_api-1b33053639456c47.cardbox_api.2391d6uc-cgu.8.rcgu.o" "/tmp/codon/tmp/cache/target/release/deps/cardbox_api-1b33053639456c47.cardbox_api.2391d6uc-cgu.9.rcgu.o" "-o" "/tmp/codon/tmp/cache/target/release/deps/cardbox_api-1b33053639456c47" "/tmp/codon/tmp/cache/target/release/deps/cardbox_api-1b33053639456c47.xdi22qyw1jm4dgn.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-Wl,-O1" "-nodefaultlibs" "-L" "/tmp/codon/tmp/cache/target/release/deps" "-L" "/tmp/codon/tmp/cache/target/release/build/ring-0f13c32780184988/out" "-L" "/tmp/codon/tmp/cache/multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/tmp/codon/tmp/cache/target/release/deps/libuuid-ce4969afc97ad8b9.rlib" "/tmp/codon/tmp/cache/target/release/deps/libjsonwebtoken-44a266ecba46fbf1.rlib" "/tmp/codon/tmp/cache/target/release/deps/libpem-d45dd6ee3de1c97b.rlib" "/tmp/codon/tmp/cache/target/release/deps/libregex-c1e1617462b9257c.rlib" "/tmp/codon/tmp/cache/target/release/deps/libthread_local-3948ce50dadeb546.rlib" "/tmp/codon/tmp/cache/target/release/deps/libregex_syntax-54ff6446d5044f96.rlib" "/tmp/codon/tmp/cache/target/release/deps/libaho_corasick-c99fa63c4b172ad4.rlib" "/tmp/codon/tmp/cache/target/release/deps/libsimple_asn1-4334711a5a537225.rlib" "/tmp/codon/tmp/cache/target/release/deps/libnum_bigint-109e809cd264f00a.rlib" "/tmp/codon/tmp/cache/target/release/deps/libchrono-3405124ec15564a1.rlib" "/tmp/codon/tmp/cache/target/release/deps/libnum_integer-137bdd49e20d58ff.rlib" "/tmp/codon/tmp/cache/target/release/deps/libnum_traits-2d6f0e657d8b410e.rlib" "/tmp/codon/tmp/cache/target/release/deps/libring-fea6120cdf068f14.rlib" "/tmp/codon/tmp/cache/target/release/deps/libspin-8b88071a74fd1146.rlib" "/tmp/codon/tmp/cache/target/release/deps/libuntrusted-07c812cecbdda234.rlib" "/tmp/codon/tmp/cache/target/release/deps/libreqwest-b54031f22b1a4160.rlib" "/tmp/codon/tmp/cache/target/release/deps/libhyper_tls-b12b7cccc6f3158b.rlib" "/tmp/codon/tmp/cache/target/release/deps/libipnet-5dd6b6b4ddc5ef77.rlib" "/tmp/codon/tmp/cache/target/release/deps/libtokio_tls-50f6bfe1206058f6.rlib" "/tmp/codon/tmp/cache/target/release/deps/libserde_urlencoded-b45320924fa23eeb.rlib" "/tmp/codon/tmp/cache/target/release/deps/libencoding_rs-9c06080874b247fd.rlib" "/tmp/codon/tmp/cache/target/release/deps/libbase64-a69b0bd0ffc84f09.rlib" "/tmp/codon/tmp/cache/target/release/deps/libmime_guess-90ce58d79a8765e7.rlib" "/tmp/codon/tmp/cache/target/release/deps/libunicase-420baa79e66eb7be.rlib" "/tmp/codon/tmp/cache/target/release/deps/libmime-0c405423f2f6d82d.rlib" "/tmp/codon/tmp/cache/target/release/deps/libnative_tls-cb230d67fabb8e5d.rlib" "/tmp/codon/tmp/cache/target/release/deps/libopenssl_probe-9ce2191185e4de74.rlib" "/tmp/codon/tmp/cache/target/release/deps/libopenssl-f4e1d41159b2a15c.rlib" "/tmp/codon/tmp/cache/target/release/deps/libopenssl_sys-d761d87b2bc00b93.rlib" "/tmp/codon/tmp/cache/target/release/deps/libforeign_types-289696442456e97a.rlib" "/tmp/codon/tmp/cache/target/release/deps/libforeign_types_shared-81fde169aac187d8.rlib" "/tmp/codon/tmp/cache/target/release/deps/libbitflags-ad0a1f0454a30088.rlib" "/tmp/codon/tmp/cache/target/release/deps/libhyper-7e6648b4650fe710.rlib" "/tmp/codon/tmp/cache/target/release/deps/libwant-852cffc58ffe3e6c.rlib" "/tmp/codon/tmp/cache/target/release/deps/libtry_lock-0d0e456c3c6f815b.rlib" "/tmp/codon/tmp/cache/target/release/deps/libh2-c84ec7b5ed846947.rlib" "/tmp/codon/tmp/cache/target/release/deps/libtracing_futures-79d6686b1765ad62.rlib" "/tmp/codon/tmp/cache/target/release/deps/libpin_project-aca85cf2e90e6668.rlib" "/tmp/codon/tmp/cache/target/release/deps/libtokio_util-31d259494e95e968.rlib" "/tmp/codon/tmp/cache/target/release/deps/libfutures_sink-37e79a2d3fc2a2f5.rlib" "/tmp/codon/tmp/cache/target/release/deps/libhttpdate-ec985aa61aaac5ed.rlib" "/tmp/codon/tmp/cache/target/release/deps/libsocket2-f092214f6231a7aa.rlib" "/tmp/codon/tmp/cache/target/release/deps/libtower_service-a31ecf311ec0a4e7.rlib" "/tmp/codon/tmp/cache/target/release/deps/libfutures_channel-45ffa01c0944bd39.rlib" "/tmp/codon/tmp/cache/target/release/deps/libtracing-cf742b6b1580f84f.rlib" "/tmp/codon/tmp/cache/target/release/deps/libtracing_core-4b501e5d197e1da0.rlib" "/tmp/codon/tmp/cache/target/release/deps/libtokio-5267c2e05320b616.rlib" "/tmp/codon/tmp/cache/target/release/deps/libmio-cfe69088ae62c7d6.rlib" "/tmp/codon/tmp/cache/target/release/deps/libiovec-9d674a86d4abd964.rlib" "/tmp/codon/tmp/cache/target/release/deps/libnet2-f13f190e6b162b14.rlib" "/tmp/codon/tmp/cache/target/release/deps/libpin_project_lite-ed875ae37bdc6cb3.rlib" "/tmp/codon/tmp/cache/target/release/deps/libpin_project_lite-72a128b5049f8c7c.rlib" "/tmp/codon/tmp/cache/target/release/deps/libhttp_body-2f3775be87dfaef4.rlib" "/tmp/codon/tmp/cache/target/release/deps/libfutures_util-1de6efb75e7fe6b4.rlib" "/tmp/codon/tmp/cache/target/release/deps/libfutures_io-53fa8ca8b9791d4d.rlib" "/tmp/codon/tmp/cache/target/release/deps/libslab-314cf7e98398e4c0.rlib" "/tmp/codon/tmp/cache/target/release/deps/libpin_project-486c6ceef64cfb50.rlib" "/tmp/codon/tmp/cache/target/release/deps/libfutures_task-ecf44cca64d39c5f.rlib" "/tmp/codon/tmp/cache/target/release/deps/libonce_cell-bc62e82218494945.rlib" "/tmp/codon/tmp/cache/target/release/deps/libpin_utils-8ea4b6a999ca85d6.rlib" "/tmp/codon/tmp/cache/target/release/deps/libfutures_core-ef7d112a948d9544.rlib" "/tmp/codon/tmp/cache/target/release/deps/liblazy_static-72fd4c50b9d3882e.rlib" "/tmp/codon/tmp/cache/target/release/deps/liburl-bdb51ad60a81f567.rlib" "/tmp/codon/tmp/cache/target/release/deps/libidna-2cff8351c96b71bb.rlib" "/tmp/codon/tmp/cache/target/release/deps/libform_urlencoded-6c027baec4c4b4b3.rlib" "/tmp/codon/tmp/cache/target/release/deps/libhttp-5600fc8dad0affc6.rlib" "/tmp/codon/tmp/cache/target/release/deps/libbytes-9bbef4070681ce0a.rlib" "/tmp/codon/tmp/cache/target/release/deps/libfnv-b63504f5018cc108.rlib" "/tmp/codon/tmp/cache/target/release/deps/librocket_contrib-cba39fdd66586fdc.rlib" "/tmp/codon/tmp/cache/target/release/deps/libserde_json-7e7f02c69d41a7c1.rlib" "/tmp/codon/tmp/cache/target/release/deps/libryu-b04ad59bf2ec6b7b.rlib" "/tmp/codon/tmp/cache/target/release/deps/libitoa-553452e4c159d751.rlib" "/tmp/codon/tmp/cache/target/release/deps/librocket-6517ef464b93fe21.rlib" "/tmp/codon/tmp/cache/target/release/deps/libatty-8e61528b57500acf.rlib" "/tmp/codon/tmp/cache/target/release/deps/libmemchr-6c817d998b0df8da.rlib" "/tmp/codon/tmp/cache/target/release/deps/libtoml-466f4ac1f73ff753.rlib" "/tmp/codon/tmp/cache/target/release/deps/libserde-1883d0398c1c65c4.rlib" "/tmp/codon/tmp/cache/target/release/deps/libyansi-0b1185001ec1bea1.rlib" "/tmp/codon/tmp/cache/target/release/deps/librocket_http-139bf580f4665612.rlib" "/tmp/codon/tmp/cache/target/release/deps/libhyper-d7f34df2825d890d.rlib" "/tmp/codon/tmp/cache/target/release/deps/libmime-d0060301e3786d04.rlib" "/tmp/codon/tmp/cache/target/release/deps/liblog-da4ae0efbcc6b0c2.rlib" "/tmp/codon/tmp/cache/target/release/deps/liblanguage_tags-76e6eed428a583a8.rlib" "/tmp/codon/tmp/cache/target/release/deps/libtypeable-e833b24097d2df79.rlib" "/tmp/codon/tmp/cache/target/release/deps/libtraitobject-9347322b3a1d51bf.rlib" "/tmp/codon/tmp/cache/target/release/deps/libnum_cpus-1d370d01f26ec5c2.rlib" "/tmp/codon/tmp/cache/target/release/deps/libhttparse-6f0db3eff7258637.rlib" "/tmp/codon/tmp/cache/target/release/deps/libunicase-2a7911adf2b9d806.rlib" "/tmp/codon/tmp/cache/target/release/deps/liburl-b126357f4d0d4ecf.rlib" "/tmp/codon/tmp/cache/target/release/deps/libidna-ee1ff6ebcefa9e2b.rlib" "/tmp/codon/tmp/cache/target/release/deps/libunicode_normalization-815d148452844814.rlib" "/tmp/codon/tmp/cache/target/release/deps/libtinyvec-295d5ad3fc0cbc9c.rlib" "/tmp/codon/tmp/cache/target/release/deps/libtinyvec_macros-7830452eb45edc19.rlib" "/tmp/codon/tmp/cache/target/release/deps/libunicode_bidi-41abae14da234d1b.rlib" "/tmp/codon/tmp/cache/target/release/deps/libmatches-32581ec9f6412ebd.rlib" "/tmp/codon/tmp/cache/target/release/deps/libbase64-e81130a5f1619be7.rlib" "/tmp/codon/tmp/cache/target/release/deps/libsafemem-dff7afbb6aa66a1b.rlib" "/tmp/codon/tmp/cache/target/release/deps/libunicode_xid-caeae2de0f8b5463.rlib" "/tmp/codon/tmp/cache/target/release/deps/libstate-a5c8be246304bd29.rlib" "/tmp/codon/tmp/cache/target/release/deps/libindexmap-1e55b735637bcc6a.rlib" "/tmp/codon/tmp/cache/target/release/deps/libhashbrown-c723dee100e54a5e.rlib" "/tmp/codon/tmp/cache/target/release/deps/libcookie-4b124e3056be9a1b.rlib" "/tmp/codon/tmp/cache/target/release/deps/libhkdf-2560e81ed4cbcd59.rlib" "/tmp/codon/tmp/cache/target/release/deps/libhmac-9d85fffb0d093356.rlib" "/tmp/codon/tmp/cache/target/release/deps/libcrypto_mac-cf605242fc7734e3.rlib" "/tmp/codon/tmp/cache/target/release/deps/libsubtle-44a12f187f6d2fc6.rlib" "/tmp/codon/tmp/cache/target/release/deps/libsha2-a965625e9b4b1d77.rlib" "/tmp/codon/tmp/cache/target/release/deps/libdigest-30da3c50b4689178.rlib" "/tmp/codon/tmp/cache/target/release/deps/libfake_simd-3756b16c63a82254.rlib" "/tmp/codon/tmp/cache/target/release/deps/libblock_buffer-ec72f459c0678688.rlib" "/tmp/codon/tmp/cache/target/release/deps/libblock_padding-2ed51b72affadbdd.rlib" "/tmp/codon/tmp/cache/target/release/deps/libbyte_tools-212432e5188e0eb9.rlib" "/tmp/codon/tmp/cache/target/release/deps/libaes_gcm-c5efb1474636768e.rlib" "/tmp/codon/tmp/cache/target/release/deps/libzeroize-2d4cd4499b23fe5d.rlib" "/tmp/codon/tmp/cache/target/release/deps/libghash-ede53737e70539aa.rlib" "/tmp/codon/tmp/cache/target/release/deps/libpolyval-141b670c6170d563.rlib" "/tmp/codon/tmp/cache/target/release/deps/libuniversal_hash-10f59e96e255cff0.rlib" "/tmp/codon/tmp/cache/target/release/deps/libsubtle-f4e27560cc2cc6cc.rlib" "/tmp/codon/tmp/cache/target/release/deps/libaes-970b959d7ddcb22f.rlib" "/tmp/codon/tmp/cache/target/release/deps/libaes_soft-f4d5f375503c69d8.rlib" "/tmp/codon/tmp/cache/target/release/deps/libopaque_debug-b3511308285898cb.rlib" "/tmp/codon/tmp/cache/target/release/deps/libaead-f00469a5862cc6db.rlib" "/tmp/codon/tmp/cache/target/release/deps/libblock_cipher_trait-38b510971dd0cef9.rlib" "/tmp/codon/tmp/cache/target/release/deps/libgeneric_array-8c74a886c0bfa1b8.rlib" "/tmp/codon/tmp/cache/target/release/deps/libtypenum-8754dce572e25207.rlib" "/tmp/codon/tmp/cache/target/release/deps/libbase64-7ad18e9add804d1e.rlib" "/tmp/codon/tmp/cache/target/release/deps/librand-5028676d61a551aa.rlib" "/tmp/codon/tmp/cache/target/release/deps/librand_chacha-61ee5a941a395a97.rlib" "/tmp/codon/tmp/cache/target/release/deps/libppv_lite86-a6feee9ed6f337c0.rlib" "/tmp/codon/tmp/cache/target/release/deps/librand_core-405e37eb109d2505.rlib" "/tmp/codon/tmp/cache/target/release/deps/libgetrandom-e61e52431766a293.rlib" "/tmp/codon/tmp/cache/target/release/deps/libtime-f621877706c13ab8.rlib" "/tmp/codon/tmp/cache/target/release/deps/libpercent_encoding-a93af9c56752979f.rlib" "/tmp/codon/tmp/cache/target/release/deps/libpercent_encoding-027fc70817b8b184.rlib" "/tmp/codon/tmp/cache/target/release/deps/libpear-c1de2330d615ed19.rlib" "/tmp/codon/tmp/cache/target/release/deps/libdiesel-36fcc1d4d85c33cb.rlib" "/tmp/codon/tmp/cache/target/release/deps/liblibsqlite3_sys-947f19b33c42a82f.rlib" "/tmp/codon/tmp/cache/target/release/deps/libr2d2-9e686ca6dd2cfb64.rlib" "/tmp/codon/tmp/cache/target/release/deps/libscheduled_thread_pool-660da798946ab8fd.rlib" "/tmp/codon/tmp/cache/target/release/deps/libparking_lot-890602ac3a7f5c68.rlib" "/tmp/codon/tmp/cache/target/release/deps/libparking_lot_core-216fb31250c05844.rlib" "/tmp/codon/tmp/cache/target/release/deps/liblibc-5f2395bf90310631.rlib" "/tmp/codon/tmp/cache/target/release/deps/libsmallvec-fe9b70472fb1b09d.rlib" "/tmp/codon/tmp/cache/target/release/deps/liblock_api-46f35b0cc374c311.rlib" "/tmp/codon/tmp/cache/target/release/deps/libscopeguard-680be5d68e26570b.rlib" "/tmp/codon/tmp/cache/target/release/deps/libinstant-1d59ba381bc156aa.rlib" "/tmp/codon/tmp/cache/target/release/deps/libcfg_if-cb3a90c6c918d108.rlib" "/tmp/codon/tmp/cache/target/release/deps/liblog-fe5eb1ec3d35d5a3.rlib" "/tmp/codon/tmp/cache/target/release/deps/libcfg_if-e0361196973a0e81.rlib" "/tmp/codon/tmp/cache/target/release/deps/libbyteorder-696e60eb23609a9a.rlib" "-Wl,--start-group" "/tmp/codon/tmp/cache/multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-25c6acf8063a3802.rlib" "/tmp/codon/tmp/cache/multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-539f13c9442f1597.rlib" "/tmp/codon/tmp/cache/multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-37db28e905edb56b.rlib" "/tmp/codon/tmp/cache/multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-9ef2480568df55af.rlib" "/tmp/codon/tmp/cache/multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-1e0f0992cdbecd66.rlib" "/tmp/codon/tmp/cache/multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-6c8e02b8fedc1e5f.rlib" "/tmp/codon/tmp/cache/multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-807e5ad203594490.rlib" "/tmp/codon/tmp/cache/multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-083fce1bea11612a.rlib" "/tmp/codon/tmp/cache/multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-1af568081add9042.rlib" "/tmp/codon/tmp/cache/multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-1395b54a3b3f45bf.rlib" "/tmp/codon/tmp/cache/multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-caba820045f178d5.rlib" "/tmp/codon/tmp/cache/multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-512eb53291f6de7e.rlib" "/tmp/codon/tmp/cache/multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-5efacc5025f9f3d8.rlib" "/tmp/codon/tmp/cache/multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-9c4002b5f79ba0e1.rlib" "/tmp/codon/tmp/cache/multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-90996f4879673567.rlib" "/tmp/codon/tmp/cache/multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-9ea09a899c3eda46.rlib" "-Wl,--end-group" "/tmp/codon/tmp/cache/multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-ef2408da76957905.rlib" "-Wl,-Bdynamic" "-lssl" "-lcrypto" "-lsqlite3" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc"
= note: /usr/bin/ld: cannot find -lsqlite3
collect2: error: ld returned 1 exit status
error: aborting due to previous error; 9 warnings emitted
error: could not compile `cardbox_api`
Looks like the compiler cannot find lsqlite3? How do I specify the location? How do I even find where lsqlite3 is installed?
As the error message indicates your build system is missing libsqlite3.
There are two ways to solve this problem:
Add libsqlite3-sys = { version = "0.18", features = ["bundled"]} to your Cargo.toml. This instructs the cargo to also build libsqlite3 as part of your application build. The library is statically linked using this method.
Install libsqlite3 on the build system and use the SQLITE3_LIB_DIR environment variable to point the compiler to the correct directory. libsqlite3 will be linked dynamically, which means you also need to provide this library on the system you are running your application afterwards.
I want to link a framework, that I made myself called VideoCapturer, to another project through its VideoCapturerConfig.cmake.
But I can't get the "usage requirement" / "target_link_libraries" correctly.
When I give the full path, hardcoded, to the location of the install framework, it works!
target_link_libraries( myprojectA
PUBLIC -framework /install/path/to/videocapturer.framework )
I would rather do that with a target provided by find_package() for more robustness.
Here is the piece of CMake I wrote to build and install the framework
# MyVideoCapturer framework
project( MyVideoCapturer )
### General variables
set( myvideocapturer_targets_export_name "${CMAKE_PROJECT_NAME}Targets" )
set( myvideocapturer_config_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}" )
set( myvideocapturer_project_config "${CMAKE_PROJECT_NAME}Config.cmake" )
set( myvideocapturer_version_config "${CMAKE_PROJECT_NAME}ConfigVersion.cmake" )
add_library( VideoCapturer "" )
add_library( MyVideoCapturer::VideoCapturer ALIAS VideoCapturer )
add_subdirectory( src ) # Mostly target_sources( VideoCapturer PRIVATE someSrcFiles.cpp )
list( APPEND _pubheaders "macVideoCapturer/VideoCapturer.h" )
set_target_properties( VideoCapturer PROPERTIES
FRAMEWORK TRUE
PUBLIC_HEADER "${_pubheaders}"
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer"
)
### Install targets, headers and export
include( GNUInstallDirs )
install(
TARGETS VideoCapturer
EXPORT "${myvideocapturer_targets_export_name}"
FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(
EXPORT "${myvideocapturer_targets_export_name}"
DESTINATION "${myvideocapturer_config_install_dir}"
NAMESPACE MyVideoCapturer::
FILE ${myvideocapturer_targets_export_name}.cmake
)
### Config file for Packaging
include( CMakePackageConfigHelpers )
configure_package_config_file(
"Config.cmake.in"
"${myvideocapturer_project_config}"
INSTALL_DESTINATION ${myvideocapturer_config_install_dir}
PATH_VARS
myvideocapturer_config_install_dir
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
in my Config.cmake.in
#PACKAGE_INIT#
include( "${CMAKE_CURRENT_LIST_DIR}/#myvideocapturer_targets_export_name#.cmake" )
After installation of that framework :
in MyVideoCapturerTargets.cmake :
# Create imported target CppMacVideoCapturer::VideoCapturer
add_library(CppMacVideoCapturer::VideoCapturer SHARED IMPORTED)
set_property(TARGET CppMacVideoCapturer::VideoCapturer PROPERTY FRAMEWORK 1)
to my understanding, 2 lines should be enough to get it right :
find_package( myvideocapturer REQUIRED )
target_link_libraries( myprojectA
PUBLIC -framework videocapturer )
when I try that, the project can't find the headers located in Videocapturer.framework/Headers
and if I try :
target_link_libraries( myprojectA
PUBLIC -framework MyVideoCapturer::myvideocapturer )
CMake doesn't find the target.
Any idea how can I export my framework ?
Thanks a lot
EDIT
Thanks to tsyvarev I found a way to solve it. I am not sure if this is the "proper" way to do it though.
In the base project :
if( APPLE )
target_include_directories( VideoCapturer
PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_LIBDIR}/VideoCapturer.framework>
)
else() # Framework is Apple-only
target_include_directories( VideoCapturer
PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
endif()
EDIT 1/4/19 : the right way seems to do :
target_include_directories( VideoCapturer
PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_LIBDIR}/VideoCapturer.framework>
)
last edit : Please read my own answer
The right way to install / export or package a framework is something like this : https://github.com/forexample/ios-dynamic-framework
However, it does contain a workaround, there is no find_package
This repository has a lot of good examples for "modern" CMake. check it out!
I'm trying to build a particular example that came with CGAL but it fails to find BOOST for some reason.
I successfully compiled CGAL itself in a similar manner.
I followed this guide on how to build it on windows.
I'm sure setted up BOOST_ROOT environment variable correctly.
Edit2: I recreated cmake file with given script for Core example as follows.
cd temp
cgal_create_CMakeLists -s delunay
In cmake UI I set Boost_DEBUG=ON and Configure.
I get error as follows (I've edited out irrelevant parts):
cmake-2.8/Modules/FindBoost.cmake:476 ] _boost_TEST_VERSIONS = 1.56.1;/* ... omitted*/
cmake-2.8/Modules/FindBoost.cmake:478 ] Boost_USE_MULTITHREADED = TRUE
cmake-2.8/Modules/FindBoost.cmake:480 ] Boost_USE_STATIC_LIBS = OFF
cmake-2.8/Modules/FindBoost.cmake:482 ] Boost_USE_STATIC_RUNTIME =
cmake-2.8/Modules/FindBoost.cmake:484 ] Boost_ADDITIONAL_VERSIONS = 1.56.1; /*... omitted*/
cmake-2.8/Modules/FindBoost.cmake:486 ] Boost_NO_SYSTEM_PATHS =
cmake-2.8/Modules/FindBoost.cmake:538 ] Declared as CMake or Environmental Variables:
cmake-2.8/Modules/FindBoost.cmake:540 ] BOOST_ROOT =
cmake-2.8/Modules/FindBoost.cmake:542 ] BOOST_INCLUDEDIR =
cmake-2.8/Modules/FindBoost.cmake:544 ] BOOST_LIBRARYDIR =
cmake-2.8/Modules/FindBoost.cmake:546 ] _boost_TEST_VERSIONS = 1.56.1;1.56.0; /*... omitted*/
cmake-2.8/Modules/FindBoost.cmake:639 ] location of version.hpp: D:/dev/boost_1_54_0/boost/version.hpp
cmake-2.8/Modules/FindBoost.cmake:663 ] version.hpp reveals boost 1.54.0
cmake-2.8/Modules/FindBoost.cmake:739 ] guessed _boost_COMPILER = -vc110
cmake-2.8/Modules/FindBoost.cmake:749 ] _boost_MULTITHREADED = -mt
cmake-2.8/Modules/FindBoost.cmake:792 ] _boost_RELEASE_ABI_TAG = -
cmake-2.8/Modules/FindBoost.cmake:794 ] _boost_DEBUG_ABI_TAG = -gd
cmake-2.8/Modules/FindBoost.cmake:842 ] _boost_LIBRARY_SEARCH_DIRS = D:/dev/boost_1_54_0/lib32-msvc-11.0;D:/dev/boost_1_54_0/lib;D:/dev/boost_1_54_0/stage/lib;D:/dev/boost_1_54_0/lib;D:/dev/boost_1_54_0/../lib;D:/dev/boost_1_54_0/stage/lib;PATHS;C:/boost/lib;C:/boost;/sw/local/lib
cmake-2.8/Modules/FindBoost.cmake:1017 ] Boost_FOUND = 1
Boost version: 1.54.0
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
Boost_INCLUDE_DIR (ADVANCED)
used as include directory in directory D:/dev/CGAL-4.3/scripts/temp
Configuring incomplete, errors occurred!
See also "D:/dev/CGAL-4.3/scripts/temp/build/CMakeFiles/CMakeOutput.log".
Core's generated cmake file:
# Created by the script cgal_create_cmake_script_with_options
# This is the CMake script for compiling a set of CGAL applications.
project( delaunay )
cmake_minimum_required(VERSION 2.6.2)
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" VERSION_GREATER 2.6)
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER 2.8.3)
cmake_policy(VERSION 2.8.4)
else()
cmake_policy(VERSION 2.6)
endif()
endif()
set( CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true )
if ( COMMAND cmake_policy )
cmake_policy( SET CMP0003 NEW )
endif()
# CGAL and its components
find_package( CGAL QUIET COMPONENTS )
if ( NOT CGAL_FOUND )
message(STATUS "This project requires the CGAL library, and will not be compiled.")
return()
endif()
# include helper file
include( ${CGAL_USE_FILE} )
# Boost and its components
find_package( Boost REQUIRED )
if ( NOT Boost_FOUND )
message(STATUS "This project requires the Boost library, and will not be compiled.")
return()
endif()
# include for local directory
# include for local package
include_directories( BEFORE ../include )
# Creating entries for target: delaunay
# ############################
add_executable( delaunay delaunay.cpp )
add_to_cached_list( CGAL_EXECUTABLE_TARGETS delaunay )
# Link the executable to CGAL and third-party libraries
target_link_libraries(delaunay ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES} )
Anyone have a clue what could be wrong?
Indeed that CMakeLists.txt does not try to find Boost libraries and headers. That is why the Boost_DEBUG variable has no effect. It seems that the CGAL libraries configuration was not correct. You should rerun CMake in your build directory of CGAL libraries, and check that there is no error.