es-ude / EmbeddedSystemsBuildScripts

Bazel build scripts used for all projects of the embedded systems department
MIT License
4 stars 5 forks source link

Compile with avr-g++ instead of avr-gcc #22

Closed markd666 closed 4 years ago

markd666 commented 4 years ago

Hi, I'm struggling to compile a C++ program as compiler defaults to avr-gcc. Is there a way to specify the use of avr-g++ for certain platforms?

glencoe commented 4 years ago

Hi Mark,

we never specifically implemented or tested the toolchain for c++ (since no one here uses it), although if all apects of the toolchain were created correctly on our side, compiling c++ should just work and it does for me... The only problem i see when compiling a small test application is that the compiler complains that -std=gnu99 is an invalid flag for c++. You can try checking in

bazel-<your-project-folder-name>/external/AvrToolchain/cc_toolchain/BUILD

whether your avr-g++ compiler was detected correctly. This was my testing setup btw.


default_embedded_binary(
    name = "CPP",
    srcs = [
        "test.cpp",
    ],
    deps = [":testlib"],
)

cc_library(
    name = "testlib",
    hdrs = [
        "test.hpp",
    ],
)
markd666 commented 4 years ago

Hi Glencoe, thanks for the response and code example. Realised it was compiling c++ fine but build failed because I was trying to include STL files and avr toolchain doesn't support them.

Forked this repo and trying to build STLport with bazel as an experiment.

Thanks, Mark