Last active
August 28, 2016 15:20
-
-
Save zhmz90/00297564d3c048eaa7dccb2279a237c6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#include "add2.h" | |
extern "C" { | |
int add2(int a , int b){ | |
return a+b; | |
} | |
} |
This file contains hidden or 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
#ifdef __cplusplus | |
extern "C" { | |
#endif | |
int add2(int, int); | |
#ifdef __cplusplus | |
} | |
#endif |
This file contains hidden or 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
#include <stdio.h> | |
#include "add2.h" | |
int add3(int a, int b, int c){ | |
return a+b+c; | |
} | |
int main(){ | |
printf("test %d", add2(1,2)); | |
} |
This file contains hidden or 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
add.so:*.c *.cpp *.h | |
gcc main.c add2.h add2.cpp -fpic -shared -o add.so |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
使用
make
编译好shared library。在Julia REPL中测试:
或者执行 julia test_shared_library_in_julia.jl.