Skip to content

Commit

Permalink
Problem: absolute path inside dylib (fix #123)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
leejw51crypto committed Jun 24, 2022
1 parent 2c7ec3a commit 37316dd
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 25 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/mac-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
otool -L ./lib/libplay_cpp_sdk.dylib
tar zcvf ../play_cpp_sdk_${PLATFORM}.tar.gz *
cd ..
shasum -a 256 *.tar.gz > "checksums-$PLATFORM.txt"
Expand Down
17 changes: 6 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,22 @@ The following build events are included in the project file:
- Post-Build event (`demo`): `copy $(ProjectDir)lib\play_cpp_sdk.dll $(TargetDir)`

### Mac
1. Clone the current repository
1. Clone the current repository
``` sh
git clone https://github.com/crypto-com/play-cpp-sdk.git
```
2. Unzip the archive file into `demo` folder
3. Copy the dynamic library to `/usr/local/lib`
``` sh
cd demo
cp lib/libplay_cpp_sdk.dylib /usr/local/lib
```
4. Under `demo` folder and build the `demo` project
``` sh
make
2. or Unzip the archive file into `demo` folder
3. and run
```sh
make cppx86_64
```

### Linux
1. Clone the current repository
``` sh
git clone https://github.com/crypto-com/play-cpp-sdk.git
```
2. Unzip the archive file into `demo` folder
2. or Unzip the archive file into `demo` folder
3. Under `demo` folder and build the `demo` project
``` sh
make
Expand Down
38 changes: 36 additions & 2 deletions demo/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,14 @@ dynamic: easywsclient.o
$(FLAGS) \
-L lib \

x86_64_build: prepare_x86_64 easywsclient.o.x86_64
x86_64_test_dylib:
./demo test

x86_64_build: x86_64_build_static x86_64_build_dynamic x86_64_test_dylib

x86_64_build_static: prepare_x86_64 easywsclient.o.x86_64
arch -x86_64 \
g++ -o demo \
g++ -o demostatic \
easywsclient.o \
main.cc \
chainmain.cc \
Expand All @@ -65,6 +70,35 @@ x86_64_build: prepare_x86_64 easywsclient.o.x86_64
-std=c++14 \
$(FLAGS)

# use -rpath option to add the path to the dynamic library loading path
# -rpath lib in gcc or
# 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
otool -L ./lib/libplay_cpp_sdk.dylib
arch -x86_64 \
g++ -o demo \
easywsclient.o \
main.cc \
chainmain.cc \
cronos.cc \
extra.cc \
./include/walletconnectcallback.cc \
./include/nft.cc \
./include/pay.cc \
./include/defi-wallet-core-cpp/src/contract.rs.cc \
./include/defi-wallet-core-cpp/src/core.cc \
./include/defi-wallet-core-cpp/src/nft.rs.cc \
./include/defi-wallet-core-cpp/src/uint.rs.cc \
./include/extra-cpp-bindings/src/lib.rs.cc \
lib/libplay_cpp_sdk.dylib \
lib/libcxxbridge1.a \
-std=c++14 \
-rpath lib
$(FLAGS)


run_static:
. ./.env && ./demostatic

Expand Down
36 changes: 24 additions & 12 deletions demo/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,33 @@
#include <thread>

int main(int argc, char *argv[]) {
try {
chainmain_process(); // chain-main
test_chainmain_nft(); // chainmain nft tests
test_login(); // decentralized login
cronos_process(); // cronos
test_cronos_testnet(); // cronos testnet
} catch (const rust::cxxbridge1::Error &e) {
// Use `Assertion failed`, the same as `assert` function
if (argc >= 2) {
if ("test" == std::string(argv[1])) {
// check wheter calling works
try {
test_wallet_connect();
} catch (const std::exception &e) {
std::cout << "Assertion failed: " << e.what() << std::endl;
}
return 0;
}
}

test_interval();
try {
chainmain_process(); // chain-main
test_chainmain_nft(); // chainmain nft tests
test_login(); // decentralized login
cronos_process(); // cronos
test_cronos_testnet(); // cronos testnet
} catch (const rust::cxxbridge1::Error &e) {
// Use `Assertion failed`, the same as `assert` function
std::cout << "Assertion failed: " << e.what() << std::endl;
}

test_blackscout_cronoscan();
test_wallet_connect();
test_interval();

return 0;
test_blackscout_cronoscan();
test_wallet_connect();

return 0;
}

0 comments on commit 37316dd

Please sign in to comment.