我正在尝试为 Acontis etherCAT 主堆栈编译演示,但 G++ 在尝试编译时报告了许多未定义的引用,但没有提供任何关于需要包含哪些头文件或库来纠正问题的线索。由于 G++ 没有报告任何引用的缺失标头,我如何确定需要哪些文件来满足未定义的引用?
如果重要,我可以从源创建目标文件,链接期间会发生错误。Acontis 没有提供生成文件。
I have tried using g++ and hunting down the header locations (Format simplified to make it more readable and <Install_Location> inserted so that each argument fits on a single line):
g++
-I <Install_Location>/Examples/EcMasterDemo/
-I <Install_Location>/SDK/INC/
-I <Install_Location>/SDK/INC/Linux
-I <Install_Location>/Examples/Common/Linux
-I <Install_Location>/Examples/Common/
-I <Install_Location>/Sources/Common
-o test
EcDemoApp.cpp
<Install_Location>/Examples/Common/Linux/EcDemoMain.cpp
<Install_Location>/Sources/Common/EcTimer.cpp
<Install_Location>/SDK/LIB/Linux/x64/libAtemRasSrv.a
<Install_Location>/SDK/LIB/Linux/x64/libEcMaster.a
-pthread
This is a short snippet of the output:
I am running Ubuntu 20.04 with 4.14.213-rt103 #1 SMP PREEMPT RT for Kernel. g++ is version 9.3.0
Update after fixing the -l arguments (thank you steeldriver)
command executed:
/ClassB/Examples/EcMasterDemo$ gcc
<Install_Dir>/ClassB/Examples/Common/Linux/EcDemoMain.cpp
<Install_Dir>/ClassB/Examples/EcMasterDemo/EcDemoApp.cpp
<Install_Dir>/ClassB/Sources/Common/EcTimer.cpp
-o test
-I <Install_Dir>/ClassB/Examples/EcMasterDemo
-I <Install_Dir>/ClassB/SDK/INC/Linux
-I <Install_Dir>/ClassB/SDK/INC
-I <Install_Dir>/ClassB/Sources/Common
-I <Install_Dir>/ClassB/Examples/Common
-I <Install_Dir>/ClassB/Examples/Common/Linux
-L <Install_Dir>/ClassB/SDK/LIB/Linux/x64
-lAtemRasSrv -lEcMaster -pthread -ldl -lrt
Which seemed to have fixed a few undefined references, but a lot still exist.
There were two issues preventing the compiling of the program.
First, as answered by steeldriver, the library path was not correctly included and the libs were not correctly referenced in GCC.
Second, several cpp source files were missing, either accidentally deleted or not successfully decompressed from the archive the first time.
一旦这些问题得到纠正,程序就会根据程序员在文档前面提供的演示源文件列表在 GCC 中正确构建。
作为参考,由于 Acontis 不提供编译器示例,这些是允许 Acontis etherCAT 主演示在 ubuntu linux 20.04 上构建的 G++ 参数:
g++
<Install_Dir>/ClassB/Examples/Common/Linux/EcDemoMain.cpp
<Install_Dir>/ClassB/Examples/EcMasterDemo/EcDemoApp.cpp
<Install_Dir>/ClassB/Examples/Common/EcDemoParms.cpp
<Install_Dir>/ClassB/Examples/Common/EcSelectLinkLayer.cpp
<Install_Dir>/ClassB/Examples/Common/EcNotification.cpp
<Install_Dir>/ClassB/Examples/Common/EcSdoServices.cpp
<Install_Dir>/ClassB/Examples/Common/EcSlaveInfo.cpp
<Install_Dir>/ClassB/Examples/Common/EcLogging.cpp
<Install_Dir>/ClassB/Sources/Common/EcTimer.cpp
-o test
-I <Install_Dir>/ClassB/Examples/EcMasterDemo
-I <Install_Dir>/ClassB/SDK/INC/Linux
-I <Install_Dir>/ClassB/SDK/INC
-I <Install_Dir>/ClassB/Sources/Common
-I <Install_Dir>/ClassB/Examples/Common
-I <Install_Dir>/ClassB/Examples/Common/Linux
-L <Install_Dir>/ClassB/SDK/LIB/Linux/x64
-lAtemRasSrv -lEcMaster -pthread -ldl -lrt -Wall
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句