problem with g_module_symbol

Hello everybody. 

I'm trying to load libraries with g_module_open in windows and linux, I don't have problems in Windows, can load perfectly the libraries. but when I do it in linux tells me that don't find the function 

I am compile mi with

float xfun(int d){

	float res;

	res = d * 3;

return res;



#ifndef __MILIB_H_

#define __MILIB_H_

float xfun(int d);


//makefile of
CFLAGS=-Wall -I. file1.o 

	ld -o file1.o -shared

file1.o : file1.cpp

	g++ -c $?

//program for load libraries is
#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include <gtk/gtk.h>

#include <glib.h>

#include <gmodule.h>

typedef float (*xfun)(int d);

xfun auxFun;

int main(){

	GError    **error;

	char xlib[300];

        char namefun[30];

	float res;

        FILE *fp;

	GModule  *milib=NULL;






        //fp = fopen(xlib,"rb");

        fp = fopen("","rb");


          printf("\nI can open");



           printf("\nI can't open");




	//Check supported


		printf("\nNo supported\n");

		return 0;


	//Load lib

	milib = g_module_open (xlib, G_MODULE_BIND_LAZY);


		printf("\nCan't load library: %s",xlib);

		printf("\nError: %s",g_module_error ());

		printf("\nCan't load modules, You can't use user function\n");

		return 0;



		//Load function

		if (!g_module_symbol (milib,namefun, (gpointer *)&auxFun)){

			printf("\nUnable load function in: %s",xlib);

			printf("\nError: %s", g_module_error ());

			printf("\nCan't load modules, You can't use user function\n");

			if (!g_module_close (milib)) g_warning ("\nm: %s", g_module_error ());

			return 0;



			//Use function

			res = auxFun(3);

			printf("\nres = %f",res);



return 0;


//Makefile of  main program
CFGTK := `pkg-config --cflags --libs gtk+-2.0 gmodule-2.0`

prog : loadlib.cpp

	g++ ${CFGTK} $? -o prog

And rename function, and made a program that uses the library and works, but when I try to load the function with g_module_symbol, I can not

When I print the error, I have the following:

Error: `xfun': /home/shadown/Desktop/misProg/make_ejemplos/gmodule/lib/ undefined symbol: xfun

the function print between  ( ` )  and ( ' )

I do not know if this error there.

can somebody help me?

Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
Regístrate ya -

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]