compiling network tables

I am using ubuntu 16.04 and have cloned the git hub for network tables repository. I have tried it with ./gradlew build -PrereleaseBuild, ./gradlew build, and ./gradlew build -PskipAthena. It completes with the test connecting a server and client. However when I type #include <NetworkTable.h> into eclipse it says unresolved inclusion and when trying to compile it fails. Any ideas why this is happening?

How are you linking to the build you did?

I tried to copy the networktables.h to usr/local/include and when I ran pkg-config --cflags --libs networktables it said nothing found. Probably the wrong thing to do but the best guess I had.

I ran into a similar problem when I tried to compile network tables for our team’s Nvidia Jetson TX2 without using java.

The way I was able to fix it was to downgrade from v4-beta to 3.1.7


git clone https://github.com/wpilibsuite/ntcore.git
git reset --hard e6656326a821dc3069fca57f736883594be61d7b

and then compile it with cmake by adding

set (WITHOUT_JAVA true)

to the end of CMakeLists.txt and then entering


cmake .
make

and finally add the below line to ~/.bashrc (be sure to change the directory to the ntcore directory you created)


export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"/path/to/ntcore/"

I hope this is helpful

Thank you I will try later tonight.

I tried and everything seemed to work however it still says unresolved in Eclipse. How do I know if it took effect in ~/.bashrc

EDIT:

NT: client: CONNECTED to server 127.0.0.1 port 10000
NT: server: client CONNECTED: 127.0.0.1 port 33252
NT: client: CONNECTED to server 127.0.0.1 port 10000
NT: server: client CONNECTED: 127.0.0.1 port 33254
NT: client: CONNECTED to server 127.0.0.1 port 10000
NT: server: client CONNECTED: 127.0.0.1 port 33256

This is the output I get from gradle along with build successful so I believe that gcc is not recognizing the install. Also if I manually point gcc with the -I tag to NetworkTables.h it sees it and gives me another missing dependency which I can fix again with -I but it seems like a ton of work.

I believe you need to append -lntcore to your gcc command along with the -I part that you’ve been adding.

I’ve actually been working on a Cmake based build for 2018 to help solve some of these issues. The build supports wpiutil, ntcore and cscore. In addition, it builds Java bindings as well, however in your use case this might not be necessary. There are cmake flags to disable both of these options. If you already have OpenCV on your system, I do recommend building cscore just in case you need it.

The repo is located here
https://github.com/ThadHouse/CmakeWpilib

It uses git submodules, so you need to clone using the following command
git clone --recursive https://github.com/ThadHouse/CmakeWpilib.git

Once this is done, create a build folder somewhere, and initialize the cmake build. To disable java use the following flag.

-DWITHOUT_JAVA=ON

To skip cscore if you don’t have OpenCV, use

-DWITHOUT_CSCORE=ON

At this point, you can either add your code into the vision_app folder in that repo, which already properly links to all libraries. If you want a separate app, you can run

sudo make install

and it will install the built libraries so another cmake project can find them. After that, the following can be used in your own CMakeLists.txt to include the libraries

find_package(wpilib REQUIRED)
target_link_libraries(YOUR_EXECUTABLE_HERE ntcore wpiutil cscore)

removing cscore if you didnt install that.

gcc now recognizes networktables with adding -Intcore however it doesnt recognize networktable functions

Are you adding the ntcore header directories? And by extension the wpiutul header directories as well? -lntcore only adds the link library, and not the headers. Is there a specific reason to be manually running gcc rather then using the cmake find_package?

so I used cmake and successfully build when I am not trying to call a network table. However I when attempting to call network tables it does not seem to work.

Here is my CMakeLists.txt -> image is the name and image.cpp is the program

cmake_minimum_required(VERSION 2.8)
project( image )
find_package( OpenCV REQUIRED )
include_directories( ${OpenCV_INCLUDE_DIRS} )
add_executable( image image.cpp )
target_link_libraries( image ${OpenCV_LIBS} )
find_package(wpilib REQUIRED)
target_link_libraries(image ntcore wpiutil cscore)

At this point I am wondering if it is my code. It seems that network tables has been changed from last year. I am including “ntcore.h” and <NetworkTableInstance.h>. Is this correct? When called without anything such as start client it compiles successfully.

UPDATE:
When running the included vision_app I get this error:

error: ‘NT_GetDefaultInstance’ was not declared in this scope
   auto inst = NT_GetDefaultInstance();