Guidance
指路人
g.yi.org
Guidance Forums / wxWidgets (wxWindows) in C++ / exporting functions from dll

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. exporting functions from dll
#3044
Posted by: 2003-12-03 04:37:34
Hello again,

I have a problem with exporting function from dll:

int Hallo (int i)
{
  return 5;
}

#define TGZLIB_API __declspec(dllexport)
TGZLIB_API int Hallo (int i);

and in the dll, the exported functions name
"_Z5Halloi" instead of "Hallo" (also in .a and .o)

with __declspec(dllexport) __stdcall, there is no difference
there is always this _Znumber in front of the function name.

have I forgotten or overseen a parameter?

Compiler: Default compiler
Building Makefile: "C:ProgrammeDev-CppMakefile.win"
Executing  make clean
rm -f dllmain.o  Project1.dll

g++.exe -c dllmain.cpp -o dllmain.o -I"C:/Programme/Dev-Cpp/include/c++"  -I"c:/Programme/Dev-Cpp/include/c++/mingw32"  -I"c:/Programme/wxWindows-2.4.2/include" 

dllwrap.exe --output-def libProject1.def --driver-name c++ --implib libProject1.a dllmain.o  -L"C:/Programme/Dev-Cpp/lib" -L"c:/Programme/wxWindows-2.4.2/lib" --no-export-all-symbols --add-stdcall-alias   -o Project1.dll

dllwrap.exe: no export definition file provided.
Creating one, but that may not be what you want

Execution terminated
Compilation successful

Is this the problem with the "no export definition file"?
but if I provide in Link --def xy.def, then is the error,
the file does not exist.

thank you again in advance

--
Francesco
Message2. Re: exporting functions from dll
#3046
Posted by: upCASE 2003-12-03 05:45:27
Hi!
Try creating a .def file like this

LIBRARY			SOMETHING
DESCRIPTION		'Killer DLL with some cool functions'
EXPORTS			Hallo

and use --def geilesdeffile.def :)

BTW: You can add a different name for the function, too. Like when you want a function called "main" you normally couldn't create it, because "main" serves as the entry point. But with a line in your def file
EXPORTS          main=main_dummy
and calling your function main_dummy in your code it works.

upcase
upCASE
-----------------------------------
If it was hard to write, it should be hard to read!- Do. Or do not. There is no try!
Message3. Re: exporting functions from dll
#3049
Posted by: 2003-12-04 04:24:35
Thank you upCASE,


i have suceeded :)

important was:
  extern "c" in header file
  and linker: --add-stdcall-alias --def hel.def

--
Francesco
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Sat 2023-2-4  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0