Open-RIO / GradleRIO-C

Managing FRC C++ Projects, the Gradle way
MIT License
7 stars 2 forks source link

Build fails to link with CTRE symbols #5

Closed yabberyabber closed 7 years ago

yabberyabber commented 7 years ago

When I use the Quickstart as provided, it compiles just fine. However, if I change HelloRobot.cpp to contain the following:

#include "WPILib.h"
#include "HelloRobot.hpp"
#include "CANTalon.h"               //this line was added

#include <iostream>

int add(int a, int b) {
    return a + b;
}

class Robot: public SampleRobot {
public:
    Robot() { }

    void RobotInit() {
        CANTalon *a = new CANTalon(8);          //this line was added
        std::cout << "Hello World" << std::endl;
        std::cout << add(1, 2) << std::endl;
    }
};

START_ROBOT_CLASS(Robot)

I get the following error:

:linkMy_programExecutable
/usr/lib/x86_64-linux-gnu/gcc/arm-frc-linux-gnueabi/4.9.3/../../../../../arm-frc-linux-gnueabi/bin/ld: /home/andrew/Downloads/gradle_frc/build/dependencies/wpi/lib/libwpilibc.so: undefined reference to symbol '_ZN14ITableListener14ValueChangedExEP6ITableN4llvm9StringRefESt10shared_ptrIN2nt5ValueEEj'
/home/andrew/Downloads/gradle_frc/build/dependencies/wpi/Linux/arm/libntcore.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

I tried adding wpi { talonSrxVersion = "4.4.1.9" } into my build.gradle, but that gave me the same output.

Building with wpi { talonSrxVersion = "4.4.1.11" } gives the same output.

JaciBrunning commented 7 years ago

This is an issue I'm working on, and follows the same symptoms as #3. I've found the root cause of it, I'll add it to my pipeline to fix this week.

For now, add the following line to your build.gradle, underneath targetPlatform in your component:

binaries.withType(NativeBinarySpec) {
                linker.args "-lntcore", "-lFRC_NetworkCommunication"
            }
yabberyabber commented 7 years ago

This fixed it. Thanks!

JaciBrunning commented 7 years ago

This issue should now be fixed. Upgrade to GradleRIO 2017.3.1 for this to be fixed, and you can remove the above workaround in your build.gradle