-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from AtelierArith/hello-example-without-cmake
Hello example without cmake
- Loading branch information
Showing
8 changed files
with
40 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Get Julia installation paths | ||
cmake -S . -B ./build -DCMAKE_BUILD_TYPE=Release | ||
cmake --build ./build --config Release -j `nproc` | ||
./build/hello | ||
JULIA_DIR=`julia -e 'print(dirname(Sys.BINDIR))'` | ||
gcc -o ./main -fPIC -I$JULIA_DIR/include/julia -L$JULIA_DIR/lib -Wl,-rpath,$JULIA_DIR/lib main.c -ljulia | ||
./main |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Hello World with C | ||
|
||
- Install Julia in advance | ||
- Just run the following command: | ||
|
||
```sh | ||
$ bash run.sh | ||
1.4142135623730951 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include <julia.h> | ||
JULIA_DEFINE_FAST_TLS // only define this once, in an executable (not in a shared library) if you want fast code. | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
/* required: setup the Julia context */ | ||
jl_init(); | ||
|
||
/* run Julia commands */ | ||
jl_eval_string("print(sqrt(2.0))"); | ||
|
||
/* strongly recommended: notify Julia that the | ||
program is about to terminate. this allows | ||
Julia time to cleanup pending write requests | ||
and run all finalizers | ||
*/ | ||
jl_atexit_hook(0); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Get Julia installation paths | ||
cmake -S . -B ./build -DCMAKE_BUILD_TYPE=Release | ||
cmake --build ./build --config Release -j `nproc` | ||
./build/hello |