[帮助]使用 webots 库编译 g++ (Linux)

问题描述 投票:0回答:0

我知道这听起来很简单,但我正要把头撞到墙上,所以请帮助我。
使用此命令:\

g++ 
/home/james/Documents/Programming/Robot/Learn/Lesson1/controllers/HelloWorld/HelloWorld.cpp
-I /usr/local/webots/include/controller/cpp/
-L /usr/local/webots/lib/controller/
-L /usr/local/webots/lib/controller/libController.so
-L /usr/local/webots/lib/controller/libCppController.so
-l /usr/local/webots/lib/controller/libController.so
-l /usr/local/webots/lib/controller/libCppController.so
-o /home/james/Documents/Programming/Robot/Learn/Lesson1/controllers/HelloWorld/HelloWorld

编译时出现如下错误:

"undefined reference to webots::Robot::getMotor"

etc, stuffs along that nature, 看起来 g++ 找不到链接器的目标,因此错误。\

      • -L 好像找不到文件,所以我用了-l,结果一样,它有编译时错误。
  • 那些文件在那里,目录是正确的。

  • 我试过 -L,-l 直接到文件,一般目录,args 的切换位置,比如 -I 在 -L 前面,在 cpp 前面,反之亦然,... 各种各样的东西。 如果我使用 --include 而不是 -I,同样的事情也发生在 include 中,不知道为什么。

  • 我正在使用 vscode,起初,我尝试了 GNU make,但无论我做什么,它都说

Makefile:72: /resources/Makefile.include: No such file or directory
make: *** No rule to make target '/resources/Makefile.include'.  Stop.

所以我手动切换到 g++。

  • 请发送帮助,我正在失去理智 fr
c++ g++ precompiled-headers webots
© www.soinside.com 2019 - 2024. All rights reserved.