Author Topic: add-stdcall-alias  (Read 22949 times)

iorec

  • Guest
add-stdcall-alias
« on: November 02, 2006, 01:30:26 am »
helo.

i have a dev-cpp project that compiles a .dll with the --add-stdcall-alias linker option. the .dll then exports my function twice as expected.

when i import the project in codeblocks it compiles but the .dll only has the function exported once. i checked and the linker options in codeblocks also have the --add-stdcall-alias option set.

any ideas?

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2807
Re: add-stdcall-alias
« Reply #1 on: November 02, 2006, 01:33:55 am »
Could you turn on full compiler logging and post the relevant info here.

   //-- Full Compile Logging --
   Main Menu->Settings->Compiler and Debugger->"Other"->Compiler logging = "Full command line".

In future, would you please mention in your messages the full
CodeBlocks version you're using and the system you're running.
You can find this info in the menu item Help/About/Information.

Or double click the "Version" banner on the Start Here Page, causing it to copy to your clipboard..
« Last Edit: November 02, 2006, 01:39:47 am by Pecan »

iorec

  • Guest
Re: add-stdcall-alias
« Reply #2 on: November 02, 2006, 03:31:59 pm »
ok. i am using:
Version 1.0 revision 3164 (2006-11-01 12:09:43)   gcc 3.4.5 Windows/unicode

the same problem appears with RC1.

i am not sure which is the relevant info of the compiler log, but here you see that i really specified --add-stdcall-alias:

mingw32-g++.exe -shared -Wl,--output-def=libFiducialTracker.def -Wl,--out-implib=libFiducialTracker.a -Wl,--dll -LC:\Dev\Dev-Cpp\lib  .objs\FiducialObject.o .objs\FiducialTracker.o .objs\FreeFrame.o .objs\libfidtrack\dump_graph.o .objs\libfidtrack\fidtrack120.o .objs\libfidtrack\fidtrackX.o .objs\libfidtrack\segment.o .objs\libfidtrack\threshold.o .objs\libfidtrack\tiled_bernsen_threshold.o .objs\libfidtrack\topologysearch.o .objs\libfidtrack\treeidmap.o   -o FiducialTracker.dll --add-stdcall-alias  -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32
Creating library file: libFiducialTracker.a
Process terminated with status 0 (0 minutes, 3 seconds)

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2807
Re: add-stdcall-alias
« Reply #3 on: November 02, 2006, 04:00:20 pm »
Isn't it supposed to be "-Wl,-add-stdcall-alias" ?


Googling:" -add-stdcall-alias"

This may be of some help:
Stdcall and DLL tools of MSVC and MinGW

what does your .def file look like?

There have been other dicussions on this forum about dll symbols. Did a search help?
« Last Edit: November 02, 2006, 04:33:07 pm by Pecan »

iorec

  • Guest
Re: add-stdcall-alias
« Reply #4 on: November 02, 2006, 04:59:21 pm »
i also tried with
-Wl, -add-stdcall-alias
but still i only get my function exportet once.

http://www.willus.com/mingw/yongweiwu_stdcall.html
also only tells me to use:
--add-stdcall-alias

all searches on the problem end in the resolution to add
--add-stdcall-alias
to the linker options, which i already have.

i don't use a .def file, they seem to be optional. but a .def file is always created when i compile. it looks as follows:
EXPORTS
    plugMain@12 @1

note, that the same unchanged code/project exports 2 functions correctly with dev-cpp.


Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2807
Re: add-stdcall-alias
« Reply #5 on: November 02, 2006, 05:26:13 pm »
What compile/linker is dev-cpp using?

Could it be a compiler version problem?

iorec

  • Guest
Re: add-stdcall-alias
« Reply #6 on: November 02, 2006, 05:34:28 pm »
codeblocks autodetected the mingw32 files in my \Dev-cpp directory. therefore the compiler/linker used is the same. how can i find out their version?



Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2807
Re: add-stdcall-alias
« Reply #7 on: November 02, 2006, 11:44:31 pm »
Sorry, I'm stumped. Since the compiler is the same for Dev-cpp and CodeBlocks, I don't understand why it doesn't work.

Could you paste the Dev-cpp compiler command line here also so we might detect the difference between the options going out for one as opposed to the other.

iorec

  • Guest
Re: add-stdcall-alias
« Reply #8 on: November 03, 2006, 01:49:58 am »
right. here is dev-cpps compile log:

g++.exe -c FiducialObject.cpp -o FiducialObject.o -I"C:/Dev/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"  -I"C:/Dev/Dev-Cpp/include/c++/3.4.2/backward"  -I"C:/Dev/Dev-Cpp/include/c++/3.4.2/mingw32"  -I"C:/Dev/Dev-Cpp/include/c++/3.4.2"  -I"C:/Dev/Dev-Cpp/include"  -I"libfidtrack"  -D__GNUWIN32__ -W -DWIN32 -DNDEBUG -D_WINDOWS -D_MBCS -D_USRDLL -DFREEFRAME_EXPORTS   -O3

dllwrap.exe --output-def libFiducialTracker.def --driver-name c++ --implib libFiducialTracker.a FreeFrame.o FiducialTracker.o libfidtrack/dump_graph.o libfidtrack/fidtrack120.o libfidtrack/fidtrackX.o libfidtrack/segment.o libfidtrack/threshold.o libfidtrack/tiled_bernsen_threshold.o libfidtrack/topologysearch.o libfidtrack/treeidmap.o FiducialObject.o  -L"C:/Dev/Dev-Cpp/lib" -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 --add-stdcall-alias    -o FiducialTracker.dll

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

Execution terminated
Compilation successful

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2807
Re: add-stdcall-alias
« Reply #9 on: November 03, 2006, 02:56:50 am »
Well... you notice that Dev-cpp is running dllwrap.exe after a compile. It looks to me like dllwrap calls  the linker, creating a dll from the .def file.

So we're right back to here: http://www.willus.com/mingw/yongweiwu_stdcall.html

Either you're going to have to create your dll using the following:

if you want to build a dll with import names, that are consistent between different compilers, you need
to build it as C code, which then uses the C naming conventions.

use

Code
#ifdef __cplusplus
extern "C"
{
#endif
    .... // here are your exported function names
#ifdef __cplusplus
}
#endif


infos
http://www.parashift.com/c++-faq-lite/mixing-c-and-cpp.html

or you're going to have to learn to use dllwrap in CodeBlocks.
To learn more, do a search on "__cplusplus"

iorec

  • Guest
Re: add-stdcall-alias
« Reply #10 on: November 04, 2006, 05:58:19 am »
thanks for your comments.

i finally got it working with a .def file like this:
EXPORTS
    plugMain = plugMain@12 @2
    plugMain@12 @1

and the additional linker option:
--input-def my.def

dGrishin

  • Guest
Re: add-stdcall-alias
« Reply #11 on: March 07, 2007, 04:22:05 pm »
thanks for your comments.

i finally got it working with a .def file like this:
EXPORTS
    plugMain = plugMain@12 @2
    plugMain@12 @1

and the additional linker option:
--input-def my.def

I got it working without a .def file.

Main menu: Project -> Build options -> GNU GCC Compiler -> Linker settings -> Other linker options: -Wl,--kill-at

« Last Edit: March 07, 2007, 04:26:47 pm by dGrishin »

Offline TDragon

  • Lives here!
  • ****
  • Posts: 943
    • TDM-GCC
Re: add-stdcall-alias
« Reply #12 on: March 07, 2007, 04:36:49 pm »
i also tried with
-Wl, -add-stdcall-alias
but still i only get my function exportet once.
I wonder if this would all have been resolved much more easily if someone else had noticed the extraneous space and missing dash here. It should be "-Wl,--add-stdcall-alias".
https://jmeubank.github.io/tdm-gcc/ - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

dGrishin

  • Guest
Re: add-stdcall-alias
« Reply #13 on: March 07, 2007, 09:03:50 pm »
It should be "-Wl,--add-stdcall-alias".

i tried both cases, with
-Wl, --add-stdcall-alias
and
-Wl,--kill-at

result in the picture below...

[attachment deleted by admin]