Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   Error while trying to setup NetworkTables on PC (http://www.chiefdelphi.com/forums/showthread.php?t=153195)

Darksainor 08-01-2017 00:03

Error while trying to setup NetworkTables on PC
 
Hello, my team and I are currently trying to implement vision processing on our robot, in order to do so we will have a PC perform all the work and send the data to the roboRio through a NetworkTable, the problem is that i cant seem to build the .cpp file for setting up the PC side of the program. Here are both the program and the output when I attempt to build it.

Program (This is just for testing and learning purposes):
#include <ntcore.h>
#include <networktables/NetworkTable.h>
using std::shared_ptr;

int main() {
NetworkTable::SetClientMode();
NetworkTable::SetIPAddress("10.46.35.2");
NetworkTable::Initialize();
shared_ptr<NetworkTable> myTable = NetworkTable::GetTable("SmartDashboard");
myTable->PutString("ExampleString", "Sample Text");
NetworkTable::Shutdown();
return 0;
}


Output:
https://drive.google.com/file/d/0By8...NIYnVTeEU/view

I see that the problem is related to something caller llvm, but I cant seem to find a way to fix this, please help :c

fsilberberg 08-01-2017 00:26

Re: Error while trying to setup NetworkTables on PC
 
You'll want to link against libwpiutil.so as well, add
Code:

-lwpiutil
to your flags. We split out a lot of the functions we use across all of our C++ codebase into a separate library, that's where all those missing functions are defined.

Peter Johnson 08-01-2017 12:40

Re: Error while trying to setup NetworkTables on PC
 
Quote:

Originally Posted by Darksainor (Post 1626955)

Program (This is just for testing and learning purposes):
Code:

#include <ntcore.h>
#include <networktables/NetworkTable.h>
using std::shared_ptr;

int main() {
        NetworkTable::SetClientMode();
        NetworkTable::SetIPAddress("10.46.35.2");
        NetworkTable::Initialize();
        shared_ptr<NetworkTable> myTable = NetworkTable::GetTable("SmartDashboard");
        myTable->PutString("ExampleString", "Sample Text");
        NetworkTable::Shutdown();
        return 0;
}


After you fix the build error, you'll find that this program won't actually set a value. All NetworkTables calls are non-blocking, so the program will exit before it has a chance to connect to the server. You'll need to put the PutString in a loop or add a few seconds delay at the end. Note you'll want a loop for image processing anyway.

Darksainor 08-01-2017 16:24

Re: Error while trying to setup NetworkTables on PC
 
Yes, thanks, I was able to compile and test it :D

jreneew2 09-01-2017 11:53

Re: Error while trying to setup NetworkTables on PC
 
Hello all, I have been trying to compile ntcore and cscore on a raspberry pi 3 and can not figure out the issue. Whenever I compile with

Code:

g++ -std=c++0x -I/home/pi/ntcore/include -lwpilibutil -lntcore test.cpp -o test `pkg-config --cflags --libs opencv`
The error I get is:

Code:

fatal error: llvm/ArrayRef.h: No such file or directory
I was able to successfully build the ntcore libs by doing

Code:

./gradlew :arm:build
All I have in the cpp file is #include<ntcore.h> and #include<networktables/NetworkTable.h>

Any help is appreciated

Thad House 09-01-2017 14:32

Re: Error while trying to setup NetworkTables on PC
 
Quote:

Originally Posted by jreneew2 (Post 1627871)
Hello all, I have been trying to compile ntcore and cscore on a raspberry pi 3 and can not figure out the issue. Whenever I compile with

Code:

g++ -std=c++0x -I/home/pi/ntcore/include -lwpilibutil -lntcore test.cpp -o test `pkg-config --cflags --libs opencv`
The error I get is:

Code:

fatal error: llvm/ArrayRef.h: No such file or directory
I was able to successfully build the ntcore libs by doing

Code:

./gradlew :arm:build
All I have in the cpp file is #include<ntcore.h> and #include<networktables/NetworkTable.h>

Any help is appreciated

You need to add the wpiutil include path "wpiutil/include" to your build command as well. Also you need to be linking with wpiutil, not wpilibutil.

One thing to note is that roborio builds built with ./gradlew :arm:ntcore:build will NOT work with a raspberry pi. They are completely separate architectures. We provide some (untested) artifacts for pi and other hf devices on our maven repo. Our recommendation for Pi is to download the 3 artifacts (cscore, wpiutil and ntcore) from our maven repo, and build locally on the Pi using those artifacts. You can find more information here regarding which artifacts to use and how to find the right ones for your specific device.

If you do want to build your own builds, download the repositories and run "./gradlew :arm:ntcore:build -PcompilerPrefix=" on the pi itself with nothing specified after the compiler prefix. That will trick the build system into building the arm artifacts with the built in compiler.

jreneew2 09-01-2017 15:12

Re: Error while trying to setup NetworkTables on PC
 
Quote:

Originally Posted by Thad House (Post 1628014)
You need to add the wpiutil include path "wpiutil/include" to your build command as well. Also you need to be linking with wpiutil, not wpilibutil.

One thing to note is that roborio builds built with ./gradlew :arm:ntcore:build will NOT work with a raspberry pi. They are completely separate architectures. We provide some (untested) artifacts for pi and other hf devices on our maven repo. Our recommendation for Pi is to download the 3 artifacts (cscore, wpiutil and ntcore) from our maven repo, and build locally on the Pi using those artifacts. You can find more information here regarding which artifacts to use and how to find the right ones for your specific device.

If you do want to build your own builds, download the repositories and run "./gradlew :arm:ntcore:build -PcompilerPrefix=" on the pi itself with nothing specified after the compiler prefix. That will trick the build system into building the arm artifacts with the built in compiler.

Thanks! I figured it out with your help!


All times are GMT -5. The time now is 14:13.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi