ton-blockchain / ton

Main TON monorepo
Other
2.95k stars 891 forks source link

Linking of lite-client failing in OpenBSD/adJ 7.1a1 #337

Closed vtamara closed 1 year ago

vtamara commented 2 years ago

Platform:

Problem

  1. In OpenBSD/adJ -ldl is not needed during linking.
  2. Linking problems with lite-client

Detail

I was able to compile and link func and fift as described at: https://github.com/vtamara/ton/wiki/Compiling-in-OpenBSD-distribution-adJ-7.1a1

However during the linking of lite-client I obtained:

Consolidate compiler generated dependencies of target lite-client                                                                                               
[100%] Linking CXX executable lite-client                                                                                                                       
ld: error: undefined symbol: ton::ton_api::liteclient_config_global::liteclient_config_global()                                                                 
>>> referenced by lite-client.cpp:115 (/home/vtamara/comp/ton/ton/lite-client/lite-client.cpp:115)                                                              
>>>               CMakeFiles/lite-client.dir/lite-client.cpp.o:(TestNode::run())                                                                                

ld: error: undefined symbol: vtable for ton::ton_api::liteclient_config_global                                                                                  
>>> referenced by ton_api.h:5396 (/home/vtamara/comp/ton/ton/tl/generate/auto/tl/ton_api.h:5396)                                                                
>>>               CMakeFiles/lite-client.dir/lite-client.cpp.o:(ton::ton_api::liteclient_config_global::~liteclient_config_global())                            
>>> the vtable symbol may be undefined because the class is missing its key function (see https://lld.llvm.org/missingkeyfunction)                              

ld: error: undefined symbol: vtable for ton::ton_api::validator_config_global                                                                                   
>>> referenced by ton_api.h:7516 (/home/vtamara/comp/ton/ton/tl/generate/auto/tl/ton_api.h:7516)                                                                
>>>               CMakeFiles/lite-client.dir/lite-client.cpp.o:(ton::ton_api::validator_config_global::~validator_config_global())                              
>>> the vtable symbol may be undefined because the class is missing its key function (see https://lld.llvm.org/missingkeyfunction)                              

ld: error: undefined symbol: vtable for ton::ton_api::liteserver_desc                                                                                           
>>> referenced by ton_api.h:5421 (/home/vtamara/comp/ton/ton/tl/generate/auto/tl/ton_api.h:5421)                                                                
>>>               CMakeFiles/lite-client.dir/lite-client.cpp.o:(ton::ton_api::liteserver_desc::~liteserver_desc())                                              
>>> the vtable symbol may be undefined because the class is missing its key function (see https://lld.llvm.org/missingkeyfunction)      

ld: error: undefined symbol: ton::ton_api::tcp_pong::fetch(td::TlParser&)                                                                                       
>>> referenced by common-utils.hpp:60 (/home/vtamara/comp/ton/ton/adnl/../tl-utils/common-utils.hpp:60)                                                         
>>>               adnl-ext-client.cpp.o:(td::Result<std::__1::unique_ptr<std::__1::enable_if<std::is_constructible<ton::ton_api::tcp_pong>::value, ton::ton_api:
:tcp_pong>::type, std::__1::default_delete<std::__1::enable_if<std::is_constructible<ton::ton_api::tcp_pong>::value, ton::ton_api::tcp_pong>::type> > > ton::fet
ch_tl_object<ton::ton_api::tcp_pong>(td::BufferSlice const&, bool)) in archive ../adnl/libadnllite.a                                                            
>>> referenced by tl_object_parse.h:154 (/home/vtamara/comp/ton/ton/tl/tl/tl_object_parse.h:154)                                                                
>>>               adnl-ext-client.cpp.o:(std::__1::unique_ptr<ton::ton_api::tcp_pong, std::__1::default_delete<ton::ton_api::tcp_pong> > ton::TlFetchObject<ton:
:ton_api::tcp_pong>::parse<td::TlBufferParser>(td::TlBufferParser&)) in archive ../adnl/libadnllite.a                                                           

ld: error: undefined symbol: ton::ton_api::tcp_authentificationNonce::fetch(td::TlParser&)                                                                      
>>> referenced by common-utils.hpp:60 (/home/vtamara/comp/ton/ton/adnl/../tl-utils/common-utils.hpp:60)                                                         
>>>               adnl-ext-client.cpp.o:(td::Result<std::__1::unique_ptr<std::__1::enable_if<std::is_constructible<ton::ton_api::tcp_authentificationNonce>::val
ue, ton::ton_api::tcp_authentificationNonce>::type, std::__1::default_delete<std::__1::enable_if<std::is_constructible<ton::ton_api::tcp_authentificationNonce>:
:value, ton::ton_api::tcp_authentificationNonce>::type> > > ton::fetch_tl_object<ton::ton_api::tcp_authentificationNonce>(td::BufferSlice const&, bool)) in arch
ive ../adnl/libadnllite.a                                                                                                                                       
>>> referenced by tl_object_parse.h:154 (/home/vtamara/comp/ton/ton/tl/tl/tl_object_parse.h:154)                                                                
>>>               adnl-ext-client.cpp.o:(std::__1::unique_ptr<ton::ton_api::tcp_authentificationNonce, std::__1::default_delete<ton::ton_api::tcp_authentificati
onNonce> > ton::TlFetchObject<ton::ton_api::tcp_authentificationNonce>::parse<td::TlBufferParser>(td::TlBufferParser&)) in archive ../adnl/libadnllite.a        

ld: error: undefined symbol: ton::ton_api::tcp_authentificationComplete::tcp_authentificationComplete(std::__1::unique_ptr<ton::ton_api::PublicKey, std::__1::de
fault_delete<ton::ton_api::PublicKey> >&&, td::BufferSlice&&)                                                                                                   
>>> referenced by TlObject.h:122 (/home/vtamara/comp/ton/ton/tl/tl/TlObject.h:122) 
>>>               adnl-ext-client.cpp.o:(std::__1::unique_ptr<ton::ton_api::tcp_authentificationComplete, std::__1::default_delete<ton::ton_api::tcp_authentific
ationComplete> > ton::create_tl_object<ton::ton_api::tcp_authentificationComplete, std::__1::unique_ptr<ton::ton_api::PublicKey, std::__1::default_delete<ton::t
on_api::PublicKey> >, td::BufferSlice>(std::__1::unique_ptr<ton::ton_api::PublicKey, std::__1::default_delete<ton::ton_api::PublicKey> >&&, td::BufferSlice&&)) 
in archive ../adnl/libadnllite.a                                                                                                                                

ld: error: undefined symbol: ton::ton_api::tcp_authentificate::tcp_authentificate(td::BufferSlice&&)                                                            
>>> referenced by TlObject.h:122 (/home/vtamara/comp/ton/ton/tl/tl/TlObject.h:122)                                                                              
>>>               adnl-ext-client.cpp.o:(std::__1::unique_ptr<ton::ton_api::tcp_authentificate, std::__1::default_delete<ton::ton_api::tcp_authentificate> > ton
::create_tl_object<ton::ton_api::tcp_authentificate, td::BufferSlice>(td::BufferSlice&&)) in archive ../adnl/libadnllite.a                                      

ld: error: undefined symbol: ton::ton_api::tcp_ping::tcp_ping(long long)                                                                                        
>>> referenced by TlObject.h:122 (/home/vtamara/comp/ton/ton/tl/tl/TlObject.h:122)                                                                              
>>>               adnl-ext-client.cpp.o:(std::__1::unique_ptr<ton::ton_api::tcp_ping, std::__1::default_delete<ton::ton_api::tcp_ping> > ton::create_tl_object<t
on::ton_api::tcp_ping, unsigned long long>(unsigned long long&&)) in archive ../adnl/libadnllite.a                                                              

ld: error: undefined symbol: vtable for ton::ton_api::tcp_authentificationNonce                                                                                 
>>> referenced by ton_api.h:6489 (/home/vtamara/comp/ton/ton/tl/generate/auto/tl/ton_api.h:6489)                                                                
>>>               adnl-ext-client.cpp.o:(ton::ton_api::tcp_authentificationNonce::~tcp_authentificationNonce()) in archive ../adnl/libadnllite.a                
>>> the vtable symbol may be undefined because the class is missing its key function (see https://lld.llvm.org/missingkeyfunction)                              

ld: error: undefined symbol: vtable for ton::ton_api::tcp_authentificationComplete                                                                              
>>> referenced by ton_api.h:6513 (/home/vtamara/comp/ton/ton/tl/generate/auto/tl/ton_api.h:6513)
>>>               adnl-ext-client.cpp.o:(ton::ton_api::tcp_authentificationComplete::~tcp_authentificationComplete()) in archive ../adnl/libadnllite.a          
>>> the vtable symbol may be undefined because the class is missing its key function (see https://lld.llvm.org/missingkeyfunction)                              

ld: error: undefined symbol: vtable for ton::ton_api::tcp_authentificate                                                                                        
>>> referenced by ton_api.h:6465 (/home/vtamara/comp/ton/ton/tl/generate/auto/tl/ton_api.h:6465)                                                                
>>>               adnl-ext-client.cpp.o:(ton::ton_api::tcp_authentificate::~tcp_authentificate()) in archive ../adnl/libadnllite.a                              
>>> the vtable symbol may be undefined because the class is missing its key function (see https://lld.llvm.org/missingkeyfunction)                              

ld: error: undefined symbol: vtable for ton::ton_api::pk_unenc                                                                                                  
>>> referenced by ton_api.h:965 (/home/vtamara/comp/ton/ton/tl/generate/auto/tl/ton_api.h:965)                                                                  
>>>               ton_api_json.cpp.o:(ton::ton_api::pk_unenc::~pk_unenc()) in archive ../tl/libtl_api.a                                                         
>>> the vtable symbol may be undefined because the class is missing its key function (see https://lld.llvm.org/missingkeyfunction)                              

ld: error: undefined symbol: vtable for ton::ton_api::pk_overlay                                                                                                
>>> referenced by ton_api.h:1037 (/home/vtamara/comp/ton/ton/tl/generate/auto/tl/ton_api.h:1037)                                                                
>>>               ton_api_json.cpp.o:(ton::ton_api::pk_overlay::~pk_overlay()) in archive ../tl/libtl_api.a                                                     
>>> the vtable symbol may be undefined because the class is missing its key function (see https://lld.llvm.org/missingkeyfunction)                              

ld: error: undefined symbol: ton::ton_api::pub_unenc::pub_unenc()                                                                                               
>>> referenced by TlObject.h:122 (/home/vtamara/comp/ton/ton/tl/tl/TlObject.h:122)                                                                              
>>>               ton_api_json.cpp.o:(std::__1::unique_ptr<ton::ton_api::pub_unenc, std::__1::default_delete<ton::ton_api::pub_unenc> > ton::create_tl_object<to
n::ton_api::pub_unenc>()) in archive ../tl/libtl_api.a                                            

ld: error: undefined symbol: vtable for ton::ton_api::pub_unenc                                                                                                 
>>> referenced by ton_api.h:1067 (/home/vtamara/comp/ton/ton/tl/generate/auto/tl/ton_api.h:1067)                                                                
>>>               ton_api_json.cpp.o:(ton::ton_api::pub_unenc::~pub_unenc()) in archive ../tl/libtl_api.a                                                       
>>> the vtable symbol may be undefined because the class is missing its key function (see https://lld.llvm.org/missingkeyfunction)                              

ld: error: undefined symbol: ton::ton_api::pub_ed25519::pub_ed25519()                                                                                           
>>> referenced by TlObject.h:122 (/home/vtamara/comp/ton/ton/tl/tl/TlObject.h:122)                                                                              
>>>               ton_api_json.cpp.o:(std::__1::unique_ptr<ton::ton_api::pub_ed25519, std::__1::default_delete<ton::ton_api::pub_ed25519> > ton::create_tl_objec
t<ton::ton_api::pub_ed25519>()) in archive ../tl/libtl_api.a                                                                                                    

ld: error: undefined symbol: ton::ton_api::pub_aes::pub_aes()                                                                                                   
>>> referenced by TlObject.h:122 (/home/vtamara/comp/ton/ton/tl/tl/TlObject.h:122)                                                                              
>>>               ton_api_json.cpp.o:(std::__1::unique_ptr<ton::ton_api::pub_aes, std::__1::default_delete<ton::ton_api::pub_aes> > ton::create_tl_object<ton::t
on_api::pub_aes>()) in archive ../tl/libtl_api.a                                                                                                                

ld: error: undefined symbol: ton::ton_api::pub_overlay::pub_overlay()                                                                                           
>>> referenced by TlObject.h:122 (/home/vtamara/comp/ton/ton/tl/tl/TlObject.h:122)                                                                              
>>>               ton_api_json.cpp.o:(std::__1::unique_ptr<ton::ton_api::pub_overlay, std::__1::default_delete<ton::ton_api::pub_overlay> > ton::create_tl_objec
t<ton::ton_api::pub_overlay>()) in archive ../tl/libtl_api.a                                                                                                    

ld: error: undefined symbol: vtable for ton::ton_api::pub_overlay 
>>> referenced by ton_api.h:1139 (/home/vtamara/comp/ton/ton/tl/generate/auto/tl/ton_api.h:1139)                                                                
>>>               ton_api_json.cpp.o:(ton::ton_api::pub_overlay::~pub_overlay()) in archive ../tl/libtl_api.a                                                   
>>> the vtable symbol may be undefined because the class is missing its key function (see https://lld.llvm.org/missingkeyfunction)                              

ld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)                                                                         
c++: error: linker command failed with exit code 1 (use -v to see invocation)

Trying to fix I added for example to tl/generate/auto/tl/ton_api.cpp:

liteclient_config_global::~liteclient_config_global()                            
{                                                                              
  // FIXME: Needs implementation                                                 
}  

and in the declaration of the class lass liteclient_config_global final : public Object { in tl/generate/auto/tl/ton_api.h I added:

virtual ~liteclient_config_global();

However after this change during linking it complains with:

[100%] Linking CXX executable lite-client                                                                                                                                                                             
ld: error: undefined symbol: ton::ton_api::liteclient_config_global::liteclient_config_global()                                                                                                                       
>>> referenced by lite-client.cpp:115 (/home/vtamara/comp/ton/ton/lite-client/lite-client.cpp:115)                                                                                                                    
>>>               CMakeFiles/lite-client.dir/lite-client.cpp.o:(TestNode::run())

ld: error: undefined symbol: ton::ton_api::liteclient_config_global::~liteclient_config_global()
>>> referenced by lite-client.cpp:133 (/home/vtamara/comp/ton/ton/lite-client/lite-client.cpp:133)
>>>               CMakeFiles/lite-client.dir/lite-client.cpp.o:(TestNode::run())
>>> referenced by lite-client.cpp:133 (/home/vtamara/comp/ton/ton/lite-client/lite-client.cpp:133)
>>>               CMakeFiles/lite-client.dir/lite-client.cpp.o:(TestNode::run())

ld: error: undefined symbol: ton::ton_api::tcp_pong::fetch(td::TlParser&)
>>> referenced by common-utils.hpp:60 (/home/vtamara/comp/ton/ton/adnl/../tl-utils/common-utils.hpp:60)
>>>               adnl-ext-client.cpp.o:(td::Result<std::__1::unique_ptr<std::__1::enable_if<std::is_constructible<ton::ton_api::tcp_pong>::value, ton::ton_api::tcp_pong>::type, std::__1::default_delete<std::__1::e
nable_if<std::is_constructible<ton::ton_api::tcp_pong>::value, ton::ton_api::tcp_pong>::type> > > ton::fetch_tl_object<ton::ton_api::tcp_pong>(td::BufferSlice const&, bool)) in archive ../adnl/libadnllite.a
>>> referenced by tl_object_parse.h:154 (/home/vtamara/comp/ton/ton/tl/tl/tl_object_parse.h:154)
>>>               adnl-ext-client.cpp.o:(std::__1::unique_ptr<ton::ton_api::tcp_pong, std::__1::default_delete<ton::ton_api::tcp_pong> > ton::TlFetchObject<ton::ton_api::tcp_pong>::parse<td::TlBufferParser>(td::TlB
ufferParser&)) in archive ../adnl/libadnllite.a

ld: error: undefined symbol: ton::ton_api::tcp_authentificationNonce::fetch(td::TlParser&)
>>> referenced by common-utils.hpp:60 (/home/vtamara/comp/ton/ton/adnl/../tl-utils/common-utils.hpp:60)
vtamara commented 2 years ago

Finally I could compile as described at https://github.com/pasosdeJesus/ton/wiki/Compiling-in-OpenBSD-distribution-adJ