1

As I am currently working on an application that uses the iota.c library, I have been using the example from last years master branch of this repo, which worked fine up until now, but seems to stop working. Transactions are failing and I don't know if this is the result of the chrysalis update. However, I want to update my lib adapter to the newest "dev" commit as the repository has some working example application which are also working fine. When building and linking the iota.c lib (which produces 7 static lib files) to my own app though, I get a some undefined references. After looking into the iota.c cmake recipes it looks like, the examples are linking the object files of the source files directly with the example app and not from the static library.

Is that something that might be fixed soon?

I know that the iota.c library is still under development, but the iota roadmap does not say when a beta is released.

I appreciate your help.

emDave
  • 57
  • 6

1 Answers1

1

you mainly get 4 static libs providing different needs for applications:

  • libiota_crypto.a
  • libiota_core.a
  • libiota_client.a
  • libiota_wallet.a

In general, the client application links with libiota_client.a to interact with nodes directly. Examples link with libiota_wallet.a demonstrating wallet functionality and some tests link with libiota_client.a in the repo.

Please check your CMake script making sure targets link to the correct lib.

Sam Chen
  • 21
  • 2
  • Thanks Sam for you quick feedback. I've already tried to use the code from your "wallet_get_balance" example and linked to the libiota_client.a. The examples work fine. However, using "nm libiota_client" on the lib file shows that many symbols are defined but not referenced e.g. "byte_buf_clonen". Looking into the cmake recipe of the tests, I can still see, that the they are compiled using the source code and not by linking the static library. Thats why compilation does not fail. I assume, that some source files are missing when "iota_client" is compiled. Maybe I'm wrong though. – emDave May 10 '21 at 17:51
  • byte_buf_clonen is part of libiota_core.a. seems your script didn't link dependency libs. don't know your cmake configuration and running operating system but iota.c can be imported as an external lib via FetchContent module, it will auto-link dependency libs. see https://github.com/oopsmonk/iota_cmder/blob/chrysalis/CMakeLists.txt – Sam Chen May 11 '21 at 06:07
  • Thanks. FetchContent is not compatibe with my dependency management though. Just to make it a bit more clear. I am building the library and installing them by CMAKE_INSTALL_PREFIX in /opt/iota.c. I would expect, that when I include the header files and link the libraries, that I can use them. However, when trying to execute wallet_create (just an example) I still get an undefined reference in the lib files. Even though I link all four lib files to my main app. There are a lot of ways to make a dependency management but using the installation path should be a standard option. I use Ubuntu – emDave May 16 '21 at 07:41
  • By the way: With this library version, everything worked find: https://github.com/iotaledger/iota.c/tree/master/cclient/api/examples – emDave May 16 '21 at 07:44
  • the flexibility of CMake allows the designer to have diverse configurations on the application and libraries. iota.c library is designed for building the application in a sandbox, FetchContent helps to solve dependency issues as well. In your case, linking all dependent libraries is needed in cmake script, the error indicates missing libs. I don't have a problem when iota.c installed in /opt/iota.c on Ubuntu. – Sam Chen May 19 '21 at 04:27
  • as a simple wallet application, make sure it links with these libs.

    target_link_libraries(iota_app PRIVATE iota_wallet iota_client iota_core iota_crypto cjson sodium curl )

    – Sam Chen May 19 '21 at 04:31
  • Thanks Sam! I really appreciate your help. I'll try it later today. Even though I am pretty sure, that I have done everything right. If I'm still facing the same issue I'll create a public example repository. – emDave May 19 '21 at 11:32
  • Hi Sam. It looks like it works now. I'm not really sure why, but I want to thank you for your time and help. Maybe I was working on an old commit or branch. Nevertheless thank you and keep up with the good work! – emDave May 21 '21 at 19:48