Coder Social home page Coder Social logo

Comments (8)

lberki avatar lberki commented on June 16, 2024

This is very surprising. Couldn't reproduce with this BUILD file on Linux, though:

cc_library(
name = "a",
srcs = ["a.cpp"],
)

cc_library(
name = "b",
srcs = ["b.cpp"],
deps = [":a"],
)

cc_binary(
name = "main",
srcs = ["main.cpp"],
deps = [":b"],
)

Assigning to Damien since he knows a tad more about Mac than I do.

from bazel.

damienmg avatar damienmg commented on June 16, 2024

Cannot reproduce:

    # Regression test for https://github.com/google/bazel/issues/67
    # C++ library depedending on C++ library fails to compile on Darwin
    function test_cpp_libdeps() {
        mkdir -p pkg
        cat <<'EOF' >pkg/BUILD
    cc_library(
      name = "a",
      srcs = ["a.cc"],
    )

    cc_library(
      name = "b",
      srcs = ["b.cc"],
      deps = [":a"],
    )

    cc_binary(
      name = "main",
      srcs = ["main.cc"],
      deps = [":b"],
    )
    EOF

        cat <<'EOF' >pkg/a.cc
    #include <string>

    std::string get_hello(std::string world) {
      return "Hello, " + world + "!";
    }
    EOF

        cat <<'EOF' >pkg/b.cc
    #include <string>
    #include <iostream>

    std::string get_hello(std::string);

    void print_hello(std::string world) {
      std::cout << get_hello(world) << std::endl;
    }
    EOF

        cat <<'EOF' >pkg/main.cc
    #include <string>
    void print_hello(std::string);

    int main() {
       print_hello(std::string("World"));
    }
    EOF

        bazel build //pkg:a >& $TEST_log \
            || fail "Failed to build //pkg:a"
        bazel build //pkg:b >& $TEST_log \
            || fail "Failed to build //pkg:b"
        bazel run //pkg:main >& $TEST_log \
            || fail "Failed to run //pkg:main"
        expect_log "Hello, World!";
    }

Succeed on my mac I will commit it to share it but the output is clean. I might have forgotten a flag though

EDIT NOTE: I added the two build to the test case to have a failing test case for future reference.

from bazel.

damienmg avatar damienmg commented on June 16, 2024

\o/ I have a failing test

from bazel.

pmbethe09 avatar pmbethe09 commented on June 16, 2024

Add an a.h which b.cc includes and calls a function from.
On Mar 27, 2015 6:45 AM, "lberki" [email protected] wrote:

This is very surprising. Couldn't reproduce with this BUILD file on Linux,
though:

cc_library(
name = "a",
srcs = ["a.cpp"],
)

cc_library(
name = "b",
srcs = ["b.cpp"],
deps = [":a"],
)

cc_binary(
name = "main",
srcs = ["main.cpp"],
deps = [":b"],
)

Assigning to Damien since he knows a tad more about Mac than I do.


Reply to this email directly or view it on GitHub
#67 (comment).

from bazel.

damienmg avatar damienmg commented on June 16, 2024

The problem is that darwin clang expect to have all the dependency provided at compile time. It is not going to be fast to fix.

from bazel.

damienmg avatar damienmg commented on June 16, 2024

I edited the test case in my previous message to have an actually failing one for future reference.

from bazel.

kayasoze avatar kayasoze commented on June 16, 2024

I've encountered this issue as well.

from bazel.

aimeeble avatar aimeeble commented on June 16, 2024

I've been hitting this too. I've worked around the issue by adding:

linker_flag: "-undefined"
linker_flag: "dynamic_lookup"

into my CROSSTOOL file. Not sure the larger implications of this style lookup though. But, it's enough for me to actually compile, so I'm happy for now.

from bazel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.