Created
April 20, 2018 02:58
-
-
Save jeffotoni/4f74ae6e55fb3e13687ab9c3e6f6809e 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
/** | |
* @autor [email protected] | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <dlfcn.h> | |
int main() | |
{ | |
///declara ponteiro para receber lib | |
void *handle; | |
///assinatura da funcao Multi | |
unsigned long int (*Multi)(unsigned long int f); | |
///capturar o valor na tela.. | |
int valorToGerar; | |
int n , i = 0, c; | |
///erro para tratar dlopen | |
char *error; | |
///dlopen => abrindo biblioteca | |
handle = dlopen("./C/libmulti.so",RTLD_LAZY); | |
if(!handle) | |
{ | |
fprintf(stderr, "Erro: %s\n", dlerror()); | |
exit(1); | |
} | |
///chando a funcao fibonancci | |
Multi = dlsym(handle, "Multi"); | |
if((error = dlerror()) != NULL) | |
{ | |
fprintf(stderr,"Erro: %s\n", error); | |
exit(1); | |
} | |
printf("Quantidade de termos da sequencia Multi:\n"); | |
scanf("%d", &n); | |
for ( c = 1 ; c <= n ; c++ ) | |
{ | |
valorToGerar = c; | |
printf("Sequencia: %d * 2 = %lu\n",valorToGerar,(*Multi)(c)); | |
i++; | |
} | |
dlclose(handle); | |
return 0; | |
} |
python
import ctypes
lib = ctypes.CDLL("libmulti.so")
lib.Multi(100)
200
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
golang
package main
import "fmt"
import "github.com/rainycape/dl"
import "log"
func main() {
}