-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when linking a static library #27
Comments
Maybe I'm using your project in a wrong way? Maybe I'm somehow doing something wrong with CMake scripts? |
I would also like to draw attention to the main
If this is not done, then with a simple use of the library, when I include |
Have you confirmed that monero-cpp fully builds standalone? It only fails building from an external project? |
Yes, |
Have you solved this? |
I fixed it by compiling monero-cpp library from external libs in monero-ts repo and not straight from monero-cpp repo |
I'm having some trouble linking the monero-cpp library to my simple project. I created a simple test project to help you figure out what exactly is going wrong. We are talking about MSYS2 MinGW64 assembly on Windows 10 x64.
And so what needs to be done:
Then you need to replace
monero-test/external/monero-cpp/CMakeLists.txt
with themonero-test/patch/CMakeLists.txt
file. This file contains some fixes that allow you to addmonero-cpp
viaadd_subdirectory
to your project.With the help of
${CMAKE_CURRENT_LIST_DIR}
I simply indicate that I want to build the rest of the paths relative to the current position of the file in the system. If this is not done, thenadd_subdirectory
will not work correctly.I also change the building of the dynamic library to a static one. I think this should not break anything, because all other libraries are imported from
monero-project
asstatic
and themonero-cpp
library itself can also bestatic
.Okay now we are ready to assemble. I use a customized QtCreator for building, which pulls the MSYS2 MinGW64 environment (which can be taken in
monero-test/env/msys64/mingw64/paths.txt
). Or you can do it through the MSYS2 MinGW64 terminal:And now I'm getting an error that I can't do anything about and don't understand why it's happening at all:
In fact, I simply copied the contents of
monero-test/external/monero-cpp/test/sample_code.cpp
into mymain.cpp
file. And it is worth noting thatsample_code.cpp
itself compiles without problems.And also it is worth noting the problem with inclusions. In my main.cpp, I need to add the following includes at the very beginning:
This is some kind of well-known problem. If this is not done, then we get a million errors. And what is again strange in
sample_code.cpp
there is no such problem. This issue is pulled from#include "wallet/monero_wallet_full.h"
.Interestingly, if in
monero-test/external/monero-cpp/CMakeLists.txt
one or only onemonero-cpp
static lib is linked to thesample_code
target, thensample_code
compilation will end with the same error:undefined reference to hmac_keccak_hash
.In my opinion, this is very strange behavior. I can't explain it. In essence, the
monero-cpp
andsample_code
targets contain the same set of static libraries intarget_link_libraries
, with only one difference, an additionalunbound
is linked to themonero-cpp
target, which can also be removed and nothing bad will happen. That is, if intarget_link_libraries
for themonero-cpp
target, register all the static libraries that are in thetarget_link_libraries
for thesample_code
target, and link themonero-cpp
static library throughtarget_link_libraries
to thesample_code
target, then this breaks compilation. If, instead, the entire list of static libraries is directly linked to the targetsample_code
(as is done now), then this does not break anything.The text was updated successfully, but these errors were encountered: