-
Notifications
You must be signed in to change notification settings - Fork 5
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
Problem: absolute path inside dylib (fix #123) #124
Conversation
Does user still need to copy to /usr/local/lib? |
Maybe tag a temporary version and test the binary release. |
nope , don't need /usr/local/lib
|
@@ -40,6 +40,8 @@ jobs: | |||
cp ./LICENSE build | |||
cp ./CHANGELOG.md build | |||
cd build | |||
install_name_tool -id @rpath/libplay_cpp_sdk.dylib ./lib/libplay_cpp_sdk.dylib |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modifying the path in packing probably has a side effect: the binary was not tested in integration test.
It is better to modify the build.rs
or setup .cargo/config
and pass the the option to compiler: rust-lang/cargo#5077
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, i'm checking now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checked with tag, now released with @rpath like this
otool -L libplay_cpp_sdk.dylib
libplay_cpp_sdk.dylib:
@rpath/libplay_cpp_sdk.dylib (compatibility version 0.0.0, current version 0.0.0)
886615e
to
f461135
Compare
after using @rpath, in packaged app, libplay_cpp_sdk.dylib should be copied in app's default rpath ref: https://users.rust-lang.org/t/need-help-linking-to-third-party-dynamic-library/47817 it's only mac specific, windows searches dll from the same folder with exe, PATH etc.. , in order |
demo/Makefile
Outdated
@@ -53,9 +53,14 @@ dynamic: easywsclient.o | |||
$(FLAGS) \ | |||
-L lib \ | |||
|
|||
x86_64_build: prepare_x86_64 easywsclient.o.x86_64 | |||
x86_64_run: x86_64_build | |||
export DYLD_LIBRARY_PATH=$(PWD)/lib && ./demo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be tested in CI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree dylib should be copied into @rpath
. We build in g++, unfortunately it is not an app bundle. Override DYLD_LIBRARY_PATH seems can not verify rpath
works. So how about setup LD_RUNPATH_SEARCH_PATH
(not tested) instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, i'll add to mac-build.yml , checking whether dynamic dylib can be called correctly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested LD_RUNPATH_SEARCH_PATH
, can not work..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passing -rpath lib
to g++ can fix the issue. No need to export env.
g++ -o demo \
easywsclient.o \
main.cc \
chainmain.cc \
cronos.cc \
extra.cc \
include/*.cc \
include/extra-cpp-bindings/src/*.cc \
include/defi-wallet-core-cpp/src/*.cc \
lib/libcxxbridge1.a \
-lplay_cpp_sdk \
-std=c++14 \
$(FLAGS) \
-rpath lib \
-L lib \
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So unreal and g++ can both use the same rpath setting like you mentioned before.
otool -L libplay_cpp_sdk.dylib
libplay_cpp_sdk.dylib:
@rpath/libplay_cpp_sdk.dylib (compatibility version 0.0.0, current version 0.0.0)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add rlib option and also comment, too.
7659c7d
to
8063ece
Compare
demo/Makefile
Outdated
@@ -53,9 +53,14 @@ dynamic: easywsclient.o | |||
$(FLAGS) \ | |||
-L lib \ | |||
|
|||
x86_64_build: prepare_x86_64 easywsclient.o.x86_64 | |||
x86_64_test_dylib: | |||
export DYLD_LIBRARY_PATH=$(PWD)/lib && ./demo test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need DYLD_LIBRARY_PATH?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, i'll remove it
036aa61
to
6b71dc0
Compare
@@ -40,6 +40,8 @@ jobs: | |||
cp ./LICENSE build | |||
cp ./CHANGELOG.md build | |||
cd build | |||
install_name_tool -id @rpath/libplay_cpp_sdk.dylib ./lib/libplay_cpp_sdk.dylib |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we pack @rpath in CI for users, the binary will be used in demo (starts from a clean repository clone), so we should keep consistent in the setup:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, i'll modify
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think libplay_cpp_sdk.dylib should be delivered with @rpath, because it is not system dylib.
it will be invalid in user's envrironment.
d1ff7f7
to
75fa69f
Compare
README.md
Outdated
``` sh | ||
cd demo | ||
cp lib/libplay_cpp_sdk.dylib /usr/local/lib | ||
cp lib/libplay_cpp_sdk.dylib $HOME/lib |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$HOME/lib maybe make things complicated... See https://stackoverflow.com/questions/57318463/macos-whats-the-correct-place-to-install-a-dylib-on-a-users-system#:~:text=%2FLibrary%2FApplication%20Support%20or%20%2FLibrary%2FFrameworks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course, it is ok to add a new $HOME/lib and export it with DYLD_LIBRARY_PATH
. It is still a workaround... Ideally, most users just simply run the program in terminal (like other programs) without touching the env.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, i'll removed it, now just make
will work
37316dd
to
e63c990
Compare
README.md
Outdated
4. Under `demo` folder and build the `demo` project | ||
``` sh | ||
make | ||
2. or Unzip the archive file into `demo` folder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why or
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After cloning the repository, demo folder doesn't have the include and lib folder, it is a must
to unzip the folders and files into demo
folder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
git clone or
unzip the archive file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, but archive file
here refers to the https://github.com/cronos-labs/play-cpp-sdk/blob/main/README.md?plain=1#L25, not the source codes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or did I get the wrong thing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't that git clone first, then unzip for example play_cpp_sdk_Darwin_x86_64.tar.gz?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, git clone then unzip or untar,
modified
d78a0c0
to
189b950
Compare
copy to /usr/local/lib not necessary |
separated mac build test, and checking now |
e1616f9
to
9cd3cf5
Compare
fixed bug in Makefile (in flags..) (no \ before $(FALGS) ) |
74ce1ef
to
536b841
Compare
dylib linking is incorrect, I am checking. run
|
.github/workflows/mac-test.yml
Outdated
|
||
- name: Build demo project | ||
working-directory: demo | ||
run: make x86_64_build_test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this command run in mac-build.yml
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, i'll move it
# install_name_tool -add_rpath @executable_path/lib ./demo | ||
# in mac, to use DYLD_LIBRARY_PATH, it is normalized to use $rpath in dylib | ||
x86_64_build_dynamic : prepare_x86_64 easywsclient.o.x86_64 | ||
install_name_tool -id @rpath/libplay_cpp_sdk.dylib ./lib/libplay_cpp_sdk.dylib |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
g++ has -install_name option.
ok, i'll fix |
checked on apple m1 could you clone again? i think lib.rs.cc is not copied from target correctly. |
In #129, there may be some conflicts:
|
18f5c87
to
c9f320f
Compare
add x86_64 dylib build update Makefile test dylib works fix main reformat add rpath option add rpath comment add more comment remove un-necessary change readme make simple add or typo add or for windows restore readme untar restore disable test separate test change name tidyup test fix compile option add comment remove mac-test
c9f320f
to
235f945
Compare
rebased |
ok, i'll rebase |
it still has problems on crypto-com/defi-wallet-core-rs#461, it is better to rebase after both finish... |
Ok, I will fix rapth in #129 |
thanks , after #129 merged, i'll close this one. |
#129 was merged, so closing this one |
Solution: remove absolute path, use relative path instead