0

I'm trying to use a sample cpp program from my university for a Roboteq motor controller. It comes with some headerfiles, but vscode will not recognize them. When trying to compile the program, I get the output:

C:\Users\joost\AppData\Local\Temp\ccLEV7F8.o: In function `main':
c:/Users/joost/Documents/School shit/OOP/Roboteq/sample.cpp:14: undefined reference to `RoboteqDevice::RoboteqDevice()'
c:/Users/joost/Documents/School shit/OOP/Roboteq/sample.cpp:15: undefined reference to `RoboteqDevice::Connect(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
c:/Users/joost/Documents/School shit/OOP/Roboteq/sample.cpp:24: undefined reference to `RoboteqDevice::SetConfig(int, int, int)'
c:/Users/joost/Documents/School shit/OOP/Roboteq/sample.cpp:30: undefined reference to `sleepms(int)'
c:/Users/joost/Documents/School shit/OOP/Roboteq/sample.cpp:34: undefined reference to `RoboteqDevice::GetConfig(int, int, int&)'
c:/Users/joost/Documents/School shit/OOP/Roboteq/sample.cpp:40: undefined reference to `sleepms(int)'
c:/Users/joost/Documents/School shit/OOP/Roboteq/sample.cpp:43: undefined reference to `RoboteqDevice::GetValue(int, int, int&)'
c:/Users/joost/Documents/School shit/OOP/Roboteq/sample.cpp:49: undefined reference to `sleepms(int)'
c:/Users/joost/Documents/School shit/OOP/Roboteq/sample.cpp:52: undefined reference to `RoboteqDevice::SetCommand(int, int, int)'
c:/Users/joost/Documents/School shit/OOP/Roboteq/sample.cpp:57: undefined reference to `RoboteqDevice::Disconnect()'
c:/Users/joost/Documents/School shit/OOP/Roboteq/sample.cpp:14: undefined reference to `RoboteqDevice::~RoboteqDevice()'
c:/Users/joost/Documents/School shit/OOP/Roboteq/sample.cpp:14: undefined reference to `RoboteqDevice::~RoboteqDevice()'

In tasks.json I have added -I${workspaceFolder} to the args, and in c_cpp_properties.json I have added the path to the project folder to includePath. What can I do to solve this?

Yksisarvinen
  • 18,008
  • 2
  • 24
  • 52
  • 2
    The problem is not with header files. Did you link the library? – Yksisarvinen Nov 27 '20 at 13:47
  • Does [this](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) answer your question? – n. m. could be an AI Nov 27 '20 at 14:18
  • You edit your `tasks.json` file to add the additional linker settings. `-L` is the folder of the library `-l` is the library – drescherjm Nov 27 '20 at 14:43
  • If you have more than 1 cpp file in your project perhaps you did not modify your tasks.json to support that. The default setting builds only the active file. – drescherjm Nov 27 '20 at 14:47
  • @drescherjm the library does come with one cpp file, how would I modify the tasks.json to include that? – HeadlessHamster Nov 28 '20 at 14:18

0 Answers0