1

I am trying to compile the demo for the Acontis etherCAT master stack, but G++ is reporting a number of undefined references when trying to compile, without giving any clue as to which headers or libraries need be included to correct the problem. Since G++ is not reporting any referenced missing headers, how can I figure out which files are required to satisfy the undefined references?

If it matters, I can create the object files from source, the errors occur during linking. Acontis did not provide a makefile.

The documentation provided by Acontis for linux is as follows: 2.5.1 Compiling the demo Linux Compilation

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: g++ terminal 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.

g++ terminal output

3
  • 1
    "extra library paths" would usually mean a directive like -L <Install_Location>/SDK/LIB/Linux/x64/ (the linker equivalent of the pre-processor's -I directives), with "extra libraries (in this order)" then being specified as -lAtemRasSrv -lEcMaster -pthread -ldl -lrt – steeldriver Jan 13 at 20:41
  • Thank you. That definitely seems to have helped a number of the undefined references! – JDD Jan 15 at 3:59
  • 4
    I rolled back your recent edit. If the question has a solution, then consider posting it as a proper answer. Once you've done that, you may "accept" that answer. This marks the question as resolved. See e.g. unix.stackexchange.com/help/self-answer and unix.stackexchange.com/help/someone-answers – Kusalananda Jan 15 at 7:13
1

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.

Once these issues were corrected, the program built correctly in GCC according to the demo source file list provided by the programmers earlier in the documentation.

For reference and since Acontis does not provide compiler examples, these are the G++ arguments that allowed the Acontis etherCAT master demo to build on ubuntu linux 20.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 -Wall

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.