我正在尝试编译Acontis etherCAT主堆栈的演示程序,但是G++在试图编译时报告了许多未定义的引用,而没有给出纠正问题所需包含的头或库的任何线索。既然G++没有报告任何引用的丢失的标头,那么我如何才能确定需要哪些文件来满足未定义的引用呢?
如果有关系,我可以从源文件中创建对象文件,在链接过程中会出现错误。Acontis没有提供makefile。
Acontis为linux提供的文档如下:


我尝试使用g++并查找标题位置(简化格式使其更具可读性,并插入,使每个参数适合于一行):
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这是输出的一个简短片段:

我使用4.14.213- RT 103 #1 SMP运行Ubuntu20.04,为内核抢占RT。g++是9.3.0版
修复-l参数后的更新(谢谢steeldriver)
执行的命令:
/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它似乎固定了一些未定义的引用,但仍然存在很多。

发布于 2021-01-15 20:29:33
有两个问题妨碍了程序的编写。
首先,正如steeldriver所回答的,GCC没有正确地包含图书馆的路径,也没有正确地引用libs。
其次,有几个cpp源文件丢失了,要么是意外删除,要么是第一次没有成功地从存档中解压缩。
一旦这些问题得到纠正,程序在GCC中正确构建,根据程序员在文档前面提供的演示源文件列表。
作为参考,并且由于Acontis没有提供编译器示例,这些G++参数允许Acontis etherCAT主演示在ubuntuLinux20.04上构建:
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 -Wallhttps://unix.stackexchange.com/questions/629039
复制相似问题