Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ Seemingly not linking in Eclipse Neon with WPILib for 2017 #6

Closed
icecube45 opened this issue Jan 10, 2017 · 16 comments
Closed

C++ Seemingly not linking in Eclipse Neon with WPILib for 2017 #6

icecube45 opened this issue Jan 10, 2017 · 16 comments

Comments

@icecube45
Copy link

icecube45 commented Jan 10, 2017

Hi!
This library looks exactly like what I've been looking for, my only issue is that it doesn't appear to link in eclipse neon.

My project outputs the errors of

..\src/Robot.cpp:58: undefined reference to `d2r(double)'
..\src/Robot.cpp:66: undefined reference to `pf_fit_hermite_cubic(Waypoint, Waypoint, Spline*)'
..\src/Robot.cpp:66: undefined reference to `pf_fit_hermite_cubic(Waypoint, Waypoint, Spline*)'
..\src/Robot.cpp:66: undefined reference to `pathfinder_prepare(Waypoint*, int, void (*)(Waypoint,Waypoint,Spline*), int, double, double, double, double, TrajectoryCandidate*)'
..\src/Robot.cpp:71: undefined reference to `pathfinder_generate(TrajectoryCandidate*, Segment*)'
..\src/Robot.cpp:77: undefined reference to `pathfinder_modify_tank(Segment*, int, Segment*, Segment*, double)'

I'm pretty sure I'm linking it correctly, the lib folder is in my search paths for libraries, and the pathfinder library is on the top of my list.

Any help would be greatly appreciated.

@JaciBrunning
Copy link
Owner

Are you using the 2017 Plugins?

@icecube45
Copy link
Author

Indeed I am

@JaciBrunning
Copy link
Owner

Try putting the pathfinder libraries in ~/wpilib/user/java, the same place the SRX libraries are stored (if you installed them).

@icecube45
Copy link
Author

I'm using cpp, but putting the includes and library under the cpp section of the wpilib folder (where the third party libraries are) results in no change.

@JaciBrunning
Copy link
Owner

I've found the issue. It turns out WPILib doesn't link .a files, only .so files. Hold tight and I'll build a .so version for you to include

@JaciBrunning
Copy link
Owner

Head to the releases and download the C++ fix, export this into your ~/wpilib/user/cpp folder and it should work.

@icecube45
Copy link
Author

Great! I'll try it out tomorrow and report back

@Sloth7
Copy link

Sloth7 commented Jan 28, 2017

Did you get this working? We are having problems linking the .so following the instructions in the wiki.

@Kython89
Copy link

Working with @Sloth7 on this. The .so file in the most recent release is only 27KB. Is this correct? It seems small.

@JaciBrunning
Copy link
Owner

@Kython89 Yes, this is correct. Pathfinder doesn't have any dependencies so the binary is fairly small. 27KB seems nominal

@Sloth7 don't use the Wiki instructions for this. Put the .so library under ~/wpilib/user/cpp/lib and the header files under ~/wpilib/user/cpp/include

@j0n5m1th
Copy link

My team has been working on getting this integrated to a 2017 C++ Command Base project and have been running into the same issue.

I believe the issue is due to name mangling between C and C++.
The errors were resolved by adding extern "C" around all of the includes in pathfinder.h. (gist)
A clean of the project after adding extern allows the project to build successfully.

I have pulled in both the most recent release with the .so and the previous release with the .a binaries at different times. Both seem to work just fine as far as compiling goes. CTRE, SF2, etc. all seem to have .a binaries and can be pulled in just fine.

Thoughts?

@JaciBrunning
Copy link
Owner

@CaptainGeneric Pathfinder is designed to be a C library, that can be imported into C++ projects. Does it build successfully if, in your robot program, you use

extern "C" #include "pathfinder.h"

instead of

#include "pathfinder.h"

@j0n5m1th
Copy link

Yeah, I wasn't a fan of modifying the header file to get the project to compile. That's definitely not the resolution.

I did try your suggestion (and a few other things) and didn't have any luck by changing the way the robot project includes the library. I'll try to pick this back up tomorrow to see if I can figure out anything else.

Let me know if you have any other ideas. I would be happy to give them a shot.

@JaciBrunning
Copy link
Owner

Hmm, if adding extern "C" seems to fix it in the pathfinder.h file, I'll put in an ifdef __cplusplus for it. Hold tight, I'll work on something soon

@JaciBrunning
Copy link
Owner

There's now a fix up that allows Pathfinder to be included with WPILib C++ projects. Get the release here and extract it to ~/wpilib/user/cpp. This should close this issue, if there's anything else related to this issue please reopen it or create a new one

@Kython89
Copy link

@JacisNonsense The latest release you provided works great and we can now link.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants